Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Don't inject matchpathcon_filespec_add64() ifdef __x86_64__ (#463, Debian#1098481) #464

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nabijaczleweli
Copy link

As the code notes, it wants to add an

/* ABI backwards-compatible shim for non-LFS 32-bit systems */

it tries to detect these with

#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64

which is correct with the added precondition that the ino_t without
-D_FILE_OFFSET_BITS=64 was actually u32 (i.e. it conflates all ILP32 systems into being non-LFS).

This is not the case on x32, for example, which is LFS; thus, the

static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch");

assertion fails (__ino_t is the "kernel ino_t" type, which generally corresponds to the kernel's ulong, which is u64 on x32).

The correct spelling of the test for this is

#if ... && sizeof(__ino_t) == 4

but this is not statically solvable with the preprocessor.

Thus, we need to explicitly special-case this. __x86_64__ indicates one of two ABIs (LP64 (amd64) or ILP32 (x32)), both of which have ino_t=u64, and is the macro used for defining __INO_T_TYPE in the system headers, so it's the best fit here.

Fixes: commit 9395cc0 ("Always build for LFS mode on 32-bit archs.")
Closes: #463
Closes: Debian#1098481
Cc: @kainz


Insert -I../../libselinux/include and -L../../libselinux/src into subprograms where needed

These subprograms (sublibraries) use plain

#include <selinux/selinux.h>
cc ... -lselinux ...

&c. which includes/links to the system libselinux.

Naturally, this doesn't work if you don't have one.

These all came out of a plain build on x32.

@bachradsusi
Copy link
Member

Hello, thanks for the patch!

In order to get the patch reviewed and accepted, it's necessary to send it to selinux@vger.kernel.org mailing list. The best way is to use git send-email command, e.g.:

 git send-email --from='Your Name <your@email.address>' --to=selinux@vger.kernel.org --smtp-server=my.smtp.server --confirm=auto -1

See https://github.com/SELinuxProject/selinux/blob/main/CONTRIBUTING.md

As the code notes, it wants to add an
  /* ABI backwards-compatible shim for non-LFS 32-bit systems */
it tries to detect these with
  #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
which is correct with the added precondition that the ino_t /without/
-D_FILE_OFFSET_BITS=64 /was actually/ u32
(i.e. it conflates /all/ ILP32 systems into being non-LFS).

This is not the case on x32, for example, which is LFS; thus, the
  static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch");
assertion fails (__ino_t is the "kernel ino_t" type,
which generally corresponds to the kernel's ulong, which is u64 on x32).

The correct spelling of the test for this is
  #if (...) && sizeof(__ino_t) == 4
but this is not statically solvable with the preprocessor.

Thus, we need to explcitly special-case this.
__x86_64__ indicates one of two ABIs (LP64 (amd64) or ILP32 (x32)),
both of which have ino_t=u64, and is the macro used for defining
__INO_T_TYPE in the system headers, so it's the best fit here.

Fixes: commit 9395cc0 ("Always build for LFS mode on 32-bit archs.")
Closes: SELinuxProject#463
Closes: Debian#1098481
Signed-off-by: наб <nabijaczleweli@nabijaczleweli.xyz>
…programs where needed

These subprograms (sublibraries) use plain
  #include <selinux/selinux.h>
  cc ... -lselinux ...
&c. which includes/links to the system libselinux.

Naturally, this doesn't work if you don't have one.

All of these fell out of a plain make invocation,
yielding errors like
  cc  -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -I../include -D_GNU_SOURCE -c -o boolean_record.o boolean_record.c
  boolean_record.c:26:10: fatal error: selinux/selinux.h: No such file or directory
     26 | #include <selinux/selinux.h>
        |          ^~~~~~~~~~~~~~~~~~~
  compilation terminated.

  make[2]: Entering directory '/tmp/selinux/policycoreutils/sestatus'
  cc -O2 -Werror -Wall -Wextra -Wfloat-equal -Wformat=2 -Winit-self -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnull-dereference -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wunused -Wwrite-strings -fno-common -D_FILE_OFFSET_BITS=64   -c -o sestatus.o sestatus.c
  sestatus.c:12:10: fatal error: selinux/selinux.h: No such file or directory
     12 | #include <selinux/selinux.h>
        |          ^~~~~~~~~~~~~~~~~~~
  compilation terminated.

Signed-off-by: наб <nabijaczleweli@nabijaczleweli.xyz>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

selinux 3.8 build fails on x32 due to (erroneous?) asserts in matchpathcon.c
2 participants