Skip to contentSkip to conversation

libsemanage: Require LIBSO before SWIGSO and SWIGRUBYSO (bsc#1266385)

PATCH Superseded Cathy Hu 2 participants 3 messages Jun 1 – Jun 2 SELinux security module

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Cathy Hu

author
#0 lore raw

PATCH v3 1/1 libsemanage: Require LIBSO before SWIGSO and SWIGRUBYSO (bsc#1266385)

We encountered race conditions where the built order was:
1. libsemanage.a
2. python-3.13_semanage.so
3. libsemanage.so.*

That happened when make was called with -j2.

In this case, python-3.13_semanage.so tries to use libsemanage.a and
- on s390x: succeeds and builds an incorrect python-3.13_semanage.so (that one was found during product testing)
- on x86: fails (manually reproduced, never encountered IRL) Reproducer:

  ```
  cd selinux/libsemanage/src
  make clean
  make pywrap
  find . -wholename "*libsemanage.so*" -delete
  find . -wholename "*python*.so" -delete
  make python-3.13_semanage.so
  -> fails
  ```

Therefor hard-require "all" when DISABLE_SHARED=n
so that LIBSO is present before SWIGSO and
probably also SWIGRUBYSO.

---
 libsemanage/src/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsemanage/src/Makefile +2 -2
index f870dc68..0241ef71 100644
@@ -82,10 +82,10 @@ $(SWIGLOBJ): $(SWIGCOUT)
 $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(SWIGSO): $(SWIGLOBJ)
+$(SWIGSO): $(SWIGLOBJ) all
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $< -lsemanage $(PYLIBS)
 
-$(SWIGRUBYSO): $(SWIGRUBYLOBJ)
+$(SWIGRUBYSO): $(SWIGRUBYLOBJ) all
 	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $^ -lsemanage $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
Signature · 1 line
2.54.0
maintainer
#1 lore raw
Quoted 37 lines · Cathy Hu

We encountered race conditions where the built order was:
1. libsemanage.a
2. python-3.13_semanage.so
3. libsemanage.so.*

That happened when make was called with -j2.

In this case, python-3.13_semanage.so tries to use libsemanage.a and
- on s390x: succeeds and builds an incorrect python-3.13_semanage.so (that one was found during product testing)
- on x86: fails (manually reproduced, never encountered IRL) Reproducer:

  ```
  cd selinux/libsemanage/src
  make clean
  make pywrap
  find . -wholename "*libsemanage.so*" -delete
  find . -wholename "*python*.so" -delete
  make python-3.13_semanage.so
  -> fails
  ```

Therefor hard-require "all" when DISABLE_SHARED=n
so that LIBSO is present before SWIGSO and
probably also SWIGRUBYSO.

---
 libsemanage/src/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
libsemanage/src/Makefile +0 -0
index f870dc68..0241ef71 100644

libsemanage/src/Makefile $(SWIGLOBJ): $(SWIGCOUT) · line 89

Quoted 10 lines
libsemanage/src/Makefile +2 -2
@@ -82,10 +82,10 @@ $(SWIGLOBJ): $(SWIGCOUT)
 $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
        $(CC) $(CPPFLAGS) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
-$(SWIGSO): $(SWIGLOBJ)
+$(SWIGSO): $(SWIGLOBJ) all
        $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $< -lsemanage $(PYLIBS)
 
-$(SWIGRUBYSO): $(SWIGRUBYLOBJ)
+$(SWIGRUBYSO): $(SWIGRUBYLOBJ) all
        $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $^ -lsemanage $(RUBYLIBS)

This appears to break the build,
from https://github.com/stephensmalley/selinux/actions/runs/26775577869/job/78926174312
:

make[2]: Entering directory '/home/runner/work/selinux/selinux/libsemanage/src' swig -Wall -ruby -o semanageswig_ruby_wrap.c -outdir ./ semanageswig_ruby.i clang -fdeclspec -I/tmp/destdir/usr/include -I../include -I../../libselinux/include -D_GNU_SOURCE -Wno-error -Wno-unused-but-set-variable -Wno-unused-variable -Wno-shadow -Wno-unused-parameter -Wno-missing-prototypes -Wno-missing-field-initializers -I/opt/hostedtoolcache/Ruby/3.3.11/x64/include/ruby-3.3.0/x86_64-linux -I/opt/hostedtoolcache/Ruby/3.3.11/x64/include/ruby-3.3.0 -fPIC -DSHARED -c -o rubysemanageswig_ruby_wrap.lo semanageswig_ruby_wrap.c clang -fdeclspec -I/tmp/destdir/usr/include -I../include -I../../libselinux/include -D_GNU_SOURCE -L/tmp/destdir/usr/lib -L. -fPIC -shared -o ruby_semanage.so rubysemanageswig_ruby_wrap.lo all -lsemanage -L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib -L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib/x86_64-linux -Wl,-rpath,/opt/hostedtoolcache/Ruby/3.3.11/x64/lib -L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib -lruby
clang: error: no such file or directory: 'all'
make[2]: *** [Makefile:89: ruby_semanage.so] Error 1
make[2]: Target 'install-rubywrap' not remade because of errors. make[2]: Leaving directory '/home/runner/work/selinux/selinux/libsemanage/src' make[1]: *** [Makefile:23: install-rubywrap] Error 2
make[1]: Leaving directory '/home/runner/work/selinux/selinux/libsemanage'
make: *** [Makefile:45: install-rubywrap] Error 1
Error: Process completed with exit code 2.

author
#2 lore raw
Quoted 21 lines · Stephen Smalley

This appears to break the build,
from https://github.com/stephensmalley/selinux/actions/runs/26775577869/job/78926174312
:

make[2]: Entering directory '/home/runner/work/selinux/selinux/libsemanage/src' swig -Wall -ruby -o semanageswig_ruby_wrap.c -outdir ./ semanageswig_ruby.i clang -fdeclspec -I/tmp/destdir/usr/include -I../include

(quoted diff) +0 -7
-I../../libselinux/include -D_GNU_SOURCE -Wno-error
-Wno-unused-but-set-variable -Wno-unused-variable -Wno-shadow
-Wno-unused-parameter -Wno-missing-prototypes
-Wno-missing-field-initializers
-I/opt/hostedtoolcache/Ruby/3.3.11/x64/include/ruby-3.3.0/x86_64-linux
-I/opt/hostedtoolcache/Ruby/3.3.11/x64/include/ruby-3.3.0 -fPIC
-DSHARED -c -o rubysemanageswig_ruby_wrap.lo semanageswig_ruby_wrap.c

clang -fdeclspec -I/tmp/destdir/usr/include -I../include

(quoted diff) +0 -6
-I../../libselinux/include -D_GNU_SOURCE -L/tmp/destdir/usr/lib -L.
-fPIC -shared -o ruby_semanage.so rubysemanageswig_ruby_wrap.lo all
-lsemanage -L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib
-L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib/x86_64-linux
-Wl,-rpath,/opt/hostedtoolcache/Ruby/3.3.11/x64/lib
-L/opt/hostedtoolcache/Ruby/3.3.11/x64/lib -lruby
Quoted 8 lines

clang: error: no such file or directory: 'all'
make[2]: *** [Makefile:89: ruby_semanage.so] Error 1
make[2]: Target 'install-rubywrap' not remade because of errors. make[2]: Leaving directory '/home/runner/work/selinux/selinux/libsemanage/src' make[1]: *** [Makefile:23: install-rubywrap] Error 2
make[1]: Leaving directory '/home/runner/work/selinux/selinux/libsemanage'
make: *** [Makefile:45: install-rubywrap] Error 1
Error: Process completed with exit code 2.

Sorry, v4 should work now
https://github.com/ca-hu/selinux/actions/runs/26812140346/job/79044601969