kicad segmentation fault when trying to execute auxiliary kicad programs

Bug #1780549 reported by Guido Trentalancia
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
KiCad
Fix Released
Undecided
Unassigned

Bug Description

KiCad version 4 (4.0.7) always crashes with a segmentation fault while trying to execute auxiliary programs such as eeschema.

The problem is due to the following SELinux permission denial:

type=AVC msg=audit(1530958805.408:33743): avc: denied { execstack } for pid=16874 comm="kicad" scontext=user_u:user_r:user_t:s0 tcontext=user_u:user_r:user_t:s0 tclass=process permissive=0

The main KiCad process crashes because it cannot obtain the SELinux "execstack" permission (a permission which is often forbidden by SELinux policies because it is rather "dangerous" in terms of security).

The following KiCad 4 executables are currently marked as requiring to execute code on the stack:

_cvpcb.kiface
_eeschema.kiface
_gerbview.kiface
_pcbnew.kiface
_pl_editor.kiface

KiCad version 5 (5.0.0-rc3-dev-2-g101b68b) is not affected by this limitation.

Tags: selinux
Revision history for this message
Guido Trentalancia (guido.trentalancia-deactivatedaccount) wrote :

Here is the stack trace:

Thread 1 "kicad" received signal SIGSEGV, Segmentation fault.
0x00007ffff1fb42c8 in signal_emit_unlocked_R () from /usr/lib64/libgobject-2.0.so.0
(gdb) where
#0 0x00007ffff1fb42c8 in signal_emit_unlocked_R () at /usr/lib64/libgobject-2.0.so.0
#1 0x00007ffff1fbf186 in g_signal_emit_valist () at /usr/lib64/libgobject-2.0.so.0
#2 0x00007ffff1fbfc12 in g_signal_emit () at /usr/lib64/libgobject-2.0.so.0
#3 0x00007ffff3b123ec in gtk_widget_dispose () at /usr/lib64/libgtk-3.so.0
#4 0x00007ffff1fa6ea3 in g_object_unref () at /usr/lib64/libgobject-2.0.so.0
#5 0x00007ffff388c639 in gtk_container_remove () at /usr/lib64/libgtk-3.so.0
#6 0x00007ffff384a7ce in gtk_button_construct_child () at /usr/lib64/libgtk-3.so.0
#7 0x00007ffff384be24 in gtk_button_set_label () at /usr/lib64/libgtk-3.so.0
#8 0x00007ffff6cd9b21 in wxButton::SetLabel(wxString const&) () at /usr/lib64/libwx_gtk3u_core-3.0.so.0
#9 0x00007ffff6cd917a in wxButton::Create(wxWindow*, int, wxString const&, wxPoint const&, wxSize const&, long, wxValidator const&, wxString const&) () at /usr/lib64/libwx_gtk3u_core-3.0.so.0
#10 0x00007ffff6ec6c19 in wxLogDialog::wxLogDialog(wxWindow*, wxArrayString const&, wxArrayInt const&, wxArrayLong const&, wxString const&, long) ()
    at /usr/lib64/libwx_gtk3u_core-3.0.so.0
#11 0x00007ffff6ec811d in wxLogGui::Flush() () at /usr/lib64/libwx_gtk3u_core-3.0.so.0
#12 0x00007ffff63fc091 in wxLog::SetActiveTarget(wxLog*) () at /usr/lib64/libwx_baseu-3.0.so.0
#13 0x00007ffff63ea048 in wxEntryCleanup() () at /usr/lib64/libwx_baseu-3.0.so.0
#14 0x00007ffff63ea17c in wxUninitialize() () at /usr/lib64/libwx_baseu-3.0.so.0
#15 0x00007ffff63eaf7a in wxEntry(int&, wchar_t**) () at /usr/lib64/libwx_baseu-3.0.so.0
#16 0x000000000043b9ce in ()
#17 0x00007ffff40c9b67 in __libc_start_main () at /lib64/libc.so.6
#18 0x000000000044051a in _start ()

Revision history for this message
Guido Trentalancia (guido.trentalancia-deactivatedaccount) wrote :

Symptoms and stack trace are very similar, for example, to those reported in:

https://bugs.launchpad.net/kicad/+bug/1695005

and:

https://answers.launchpad.net/kicad/+question/645943

although the underlying cause is very different (SELinux execution permission denial).

Revision history for this message
Guido Trentalancia (guido.trentalancia-deactivatedaccount) wrote :

The quickest solution is to clear the executable stack flag using the "execstack" program:

https://launchpad.net/ubuntu/artful/+package/execstack

For example, provided that KiCad binaries are installed in /usr/bin, the following commands should be executed from a root shell:

execstack -c _cvpcb.kiface
execstack -c _eeschema.kiface
execstack -c _gerbview.kiface
execstack -c _pcbnew.kiface
execstack -c _pl_editor.kiface

Revision history for this message
Guido Trentalancia (guido.trentalancia-deactivatedaccount) wrote :

The proper stable solution is to compile the above mentioned programs using the "-z noexecstack" gcc option.

Revision history for this message
Seth Hillbrand (sethh) wrote :

4.0.7 will not be receiving updates at this point. Thank you for testing that v5 is not affected.

Changed in kicad:
status: New → Fix Committed
Revision history for this message
Guido Trentalancia (guido.trentalancia-deactivatedaccount) wrote :

Please build with the following cmake option:

-DCMAKE_CXX_FLAGS="-z noexecstack"

Changed in kicad:
assignee: nobody → Guido Trentalancia (guido.trentalancia)
tags: added: selinux
Changed in kicad:
assignee: Guido Trentalancia (guido.trentalancia) → nobody
Changed in kicad:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.