Bug 2295428 - python3-libselinux generate segmentation fault
Summary: python3-libselinux generate segmentation fault
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: libselinux
Version: rawhide
Hardware: x86_64
OS: Linux
urgent
medium
Target Milestone: ---
Assignee: Petr Lautrbach
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2024-07-03 13:54 UTC by Katerina Koukiou
Modified: 2024-07-10 08:21 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2024-07-10 08:21:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Katerina Koukiou 2024-07-03 13:54:22 UTC
With recent update of libselinux  python3-libselinux to 3.7-1.fc41 the unit tests from https://github.com/rhinstaller/anaconda repository caught a regression in the python bindings.

Let me know if the traceback is not helpful and I can try to find a reproducer.

unit_tests/pyanaconda_tests/modules/storage/test_module_storage.py::StorageTasksTestCase::test_mount_filesystems Fatal Python error: Segmentation fault

Current thread 0x00007fa0b658db80 (most recent call first):
  File "/usr/lib64/python3.13/site-packages/selinux/__init__.py", line 887 in matchpathcon
  File "/usr/lib/python3.13/site-packages/blivet/util.py", line 491 in match_path_context
  File "/usr/lib/python3.13/site-packages/blivet/util.py", line 550 in reset_file_context
  File "/usr/lib/python3.13/site-packages/blivet/formats/fs.py", line 661 in _post_setup
  File "/usr/lib/python3.13/site-packages/blivet/threads.py", line 49 in run_with_lock
  File "/usr/lib/python3.13/site-packages/blivet/formats/__init__.py", line 602 in setup
  File "/usr/lib/python3.13/site-packages/blivet/threads.py", line 49 in run_with_lock
  File "/tmp/anaconda/pyanaconda/modules/storage/devicetree/fsset.py", line 601 in mount_filesystems
  File "/tmp/anaconda/pyanaconda/modules/storage/devicetree/model.py", line 476 in mount_filesystems
  File "/usr/lib/python3.13/site-packages/blivet/threads.py", line 49 in run_with_lock
  File "/tmp/anaconda/pyanaconda/modules/storage/installation.py", line 244 in run
  File "/tmp/anaconda/tests/unit_tests/pyanaconda_tests/modules/storage/test_module_storage.py", line 1497 in test_mount_filesystems
  File "/usr/lib64/python3.13/unittest/mock.py", line 1423 in patched
  File "/usr/lib64/python3.13/unittest/case.py", line 606 in _callTestMethod
  File "/usr/lib64/python3.13/unittest/case.py", line 651 in run
  File "/usr/lib64/python3.13/unittest/case.py", line 707 in __call__
  File "/usr/local/lib/python3.13/site-packages/_pytest/unittest.py", line 344 in runtest
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 173 in pytest_runtest_call
  File "/usr/local/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/usr/local/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 241 in <lambda>
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 341 in from_call
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 240 in call_and_report
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 135 in runtestprotocol
  File "/usr/local/lib/python3.13/site-packages/_pytest/runner.py", line 116 in pytest_runtest_protocol
  File "/usr/local/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/usr/local/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/usr/local/lib/python3.13/site-packages/_pytest/main.py", line 364 in pytest_runtestloop
  File "/usr/local/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/usr/local/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/usr/local/lib/python3.13/site-packages/_pytest/main.py", line 339 in _main
  File "/usr/local/lib/python3.13/site-packages/_pytest/main.py", line 285 in wrap_session
  File "/usr/local/lib/python3.13/site-packages/_pytest/main.py", line 332 in pytest_cmdline_main
  File "/usr/local/lib/python3.13/site-packages/pluggy/_callers.py", line 103 in _multicall
  File "/usr/local/lib/python3.13/site-packages/pluggy/_manager.py", line 120 in _hookexec
  File "/usr/local/lib/python3.13/site-packages/pluggy/_hooks.py", line 513 in __call__
  File "/usr/local/lib/python3.13/site-packages/_pytest/config/__init__.py", line 178 in main
  File "/usr/local/lib/python3.13/site-packages/_pytest/config/__init__.py", line 206 in console_main
  File "/usr/local/bin/pytest", line 8 in <module>

Reproducible: Always

Comment 1 Petr Lautrbach 2024-07-03 14:35:53 UTC
Where do I find the test? and the run? How do I reproduce it locally?

Comment 3 Petr Lautrbach 2024-07-03 14:38:29 UTC
Do you have libselinux backtrace? or coredump?

Comment 4 Katerina Koukiou 2024-07-03 15:11:03 UTC
(gdb) bt
#0  closef (rec=<optimized out>) at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/label_file.c:915
#1  0x00007f215fb59e5e in selabel_close (rec=0x563b58589860) at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/label.c:364
#2  0x00007f215fb5a01b in selabel_open (backend=<optimized out>, opts=0x7f21703d18f8, nopts=6) at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/label.c:228
#3  0x00007f215fb67630 in matchpathcon_init_prefix (path=0x0, subset=0x0) at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/matchpathcon.c:364
#4  0x00007f215fb67811 in matchpathcon_internal (path=path@entry=0x7f214e7e1888 "/dev", mode=mode@entry=16384, con=con@entry=0x7ffcc5e533e0)
    at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/matchpathcon.c:443
#5  0x00007f215fb67839 in matchpathcon (path=path@entry=0x7f214e7e1888 "/dev", mode=mode@entry=16384, con=con@entry=0x7ffcc5e533e0)
    at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/matchpathcon.c:461
#6  0x00007f2161e0ce3e in _wrap_matchpathcon (self=<optimized out>, args=<optimized out>) at /usr/src/debug/libselinux-3.7-1.fc41.x86_64/src/selinuxswig_python_wrap.c:13202
#7  0x00007f2170851f4a in cfunction_call (func=0x7f215fbc16c0, args=0x7f214e7a35c0, kwargs=<optimized out>) at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/methodobject.c:551
#8  0x00007f2170819eeb in _PyObject_MakeTpCall (tstate=0x7f2170be07a0 <_PyRuntime+282784>, callable=0x7f215fbc16c0, args=<optimized out>, nargs=2, keywords=0x0)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:242
#9  0x00007f217082fffd in _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Python/generated_cases.c.h:813
#10 0x00007f21708880b7 in _PyEval_EvalFrame (tstate=0x7f2170be07a0 <_PyRuntime+282784>, frame=<optimized out>, throwflag=0)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Include/internal/pycore_ceval.h:119
#11 _PyEval_Vector (tstate=0x7f2170be07a0 <_PyRuntime+282784>, func=0x7f215d161800, locals=0x0, args=0x7f214e91c2d0, argcount=1, kwnames=0x1)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Python/ceval.c:1819
#12 _PyFunction_Vectorcall (func=0x7f215d161800, stack=0x7f214e91c2d0, nargsf=1, kwnames=0x1) at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:413
#13 _PyObject_VectorcallTstate (tstate=0x7f2170be07a0 <_PyRuntime+282784>, callable=0x7f215d161800, args=0x7f214e91c2d0, nargsf=1, kwnames=0x1)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Include/internal/pycore_call.h:168
#14 method_vectorcall (method=method@entry=0x7f214f002ac0, args=args@entry=0x7f214e91c2d8, nargsf=<optimized out>, kwnames=kwnames@entry=0x7f214e3e8880)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/classobject.c:62
#15 0x00007f217090afe8 in _PyVectorcall_Call
    (tstate=0x7f2170be07a0 <_PyRuntime+282784>, func=0x7f2170887d00 <method_vectorcall>, callable=0x7f214f002ac0, tuple=<optimized out>, kwargs=<optimized out>)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:285
#16 _PyObject_Call (tstate=0x7f2170be07a0 <_PyRuntime+282784>, callable=0x7f214f002ac0, args=<optimized out>, kwargs=<optimized out>)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:348
#17 0x00007f2170834b3a in PyObject_Call (callable=0x7f214f002ac0, args=0x7f2170bb0ef8 <_PyRuntime+88056>, kwargs=0x7f214e7a1b40)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:373
#18 PyCFunction_Call (callable=0x7f214f002ac0, args=0x7f2170bb0ef8 <_PyRuntime+88056>, kwargs=0x7f214e7a1b40) at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:381
#19 _PyEval_EvalFrameDefault (tstate=<optimized out>, frame=<optimized out>, throwflag=<optimized out>) at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Python/generated_cases.c.h:1353
#20 0x00007f21708880b7 in _PyEval_EvalFrame (tstate=0x7f2170be07a0 <_PyRuntime+282784>, frame=<optimized out>, throwflag=0)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Include/internal/pycore_ceval.h:119
#21 _PyEval_Vector (tstate=0x7f2170be07a0 <_PyRuntime+282784>, func=0x7f2161ad8040, locals=0x0, args=0x7f214f2a8ec0, argcount=1, kwnames=0x1)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Python/ceval.c:1819
#22 _PyFunction_Vectorcall (func=0x7f2161ad8040, stack=0x7f214f2a8ec0, nargsf=1, kwnames=0x1) at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:413
#23 _PyObject_VectorcallTstate (tstate=0x7f2170be07a0 <_PyRuntime+282784>, callable=0x7f2161ad8040, args=0x7f214f2a8ec0, nargsf=1, kwnames=0x1)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Include/internal/pycore_call.h:168
#24 method_vectorcall (method=method@entry=0x7f214f2b38c0, args=args@entry=0x7f214f2a8ec8, nargsf=<optimized out>, kwnames=kwnames@entry=0x7f214ec65840)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/classobject.c:62
#25 0x00007f217090afe8 in _PyVectorcall_Call
    (tstate=0x7f2170be07a0 <_PyRuntime+282784>, func=0x7f2170887d00 <method_vectorcall>, callable=0x7f214f2b38c0, tuple=<optimized out>, kwargs=<optimized out>)
    at /usr/src/debug/python3.13-3.13.0~b3-1.fc41.x86_64/Objects/call.c:285

Comment 5 Petr Lautrbach 2024-07-03 15:54:09 UTC
Outcomes from the side channel discussion:

- kkoukiou pointed on https://github.com/SELinuxProject/selinux/commit/5876aca0484f3b45636ef6337f06b914a8769cb4

- reproducer:

$ toolbox create --release 41
$ toolbox enter fedora-toolbox-41

toolbox $ sudo dnf install python3-libselinux
toolbox $ python3
>>> import selinux
>>> selinux.matchpathcon("/dev", 16384)
Segmentation fault (core dumped)

- workaround:

$ sudo dnf install selinux-policy-targeted

Comment 6 Milos Malik 2024-07-09 14:08:40 UTC
Test coverage for this bug exists in a form of PR:
 * https://src.fedoraproject.org/tests/selinux/pull-request/516

The PR waits for a review.


Note You need to log in before you can comment on or make changes to this bug.