Skip to contentSkip to conversation

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

PATCH In review Cathy Hu 3 participants 3 messages Jun 2 SELinux security module

lore
Share & tools
lore

Cathy Hu

author
#0 lore raw

PATCH v4 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.

For SWIGRUBYSO switch to using the first requisite only ($< instead of $^), as it should not include "all" and $(SWIGRUBYLOBJ) evaluates to one item only.

---
 libsemanage/src/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libsemanage/src/Makefile +3 -3
index f870dc68..9199bd39 100644
@@ -82,11 +82,11 @@ $(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)
-	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $^ -lsemanage $(RUBYLIBS)
+$(SWIGRUBYSO): $(SWIGRUBYLOBJ) all
+	$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $< -lsemanage $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
Signature · 1 line
2.54.0
maintainer Acked-by on v4 1/1
#1 lore raw
Quoted 27 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.

Quoted 5 lines

For SWIGRUBYSO switch to using the first requisite only ($< instead of $^), as it should not include "all" and $(SWIGRUBYLOBJ) evaluates to one item only.

Quoted 26 lines
---
 libsemanage/src/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libsemanage/src/Makefile +3 -4
index f870dc68..9199bd39 100644
@@ -82,11 +82,11 @@ $(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)
-       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $^ -lsemanage $(RUBYLIBS)
+$(SWIGRUBYSO): $(SWIGRUBYLOBJ) all
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $< -lsemanage $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
        $(AR) rcs $@ $^
--

2.54.0

#2 lore raw
Quoted 29 lines · Stephen Smalley
Quoted 27 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.

Quoted 8 lines
Quoted 5 lines

For SWIGRUBYSO switch to using the first requisite only ($< instead of $^), as it should not include "all" and $(SWIGRUBYLOBJ) evaluates to one item only.

Merged.
Thanks,
Jim

Quoted 27 lines
Quoted 26 lines
---
 libsemanage/src/Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
libsemanage/src/Makefile +3 -4
index f870dc68..9199bd39 100644
@@ -82,11 +82,11 @@ $(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)
-       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $^ -lsemanage $(RUBYLIBS)
+$(SWIGRUBYSO): $(SWIGRUBYLOBJ) all
+       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -L. -fPIC -shared -o $@ $< -lsemanage $(RUBYLIBS)
 
 $(LIBA): $(OBJS)
        $(AR) rcs $@ $^
--

2.54.0