-
Notifications
You must be signed in to change notification settings - Fork 367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
selinux 3.8 build fails on x32 due to (erroneous?) asserts in matchpathcon.c #463
Comments
This looks like it was added in 9395cc0 and it conflates The check bundle is
which correctly identifies what it wants to do, but fails to use the correct condition and triggers on LFS ILP32 systems as well. All the checks make sense (ulong=u32 is tautological, ino=ino64 confirms _F_O_B, ino64=u64 is tautological), ulong=__ino_t check ensures the ABI change is actually required, and fails on LFS ILP32 systems. To that extent the check is correct, except it wants to be lifted to the #if, because if ino_t=__ino_t=u64 then |
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
Regarding the commit, "Don't inject matchpathcon_filespec_add64() ifdef x86_64 (#463, Debian#1098481)"... I believe aarch64 will have a similar issue, so Unfortunately, I don't remember all the details. But I recall |
The correct spelling of this check is I don't know what you mean by the second paragraph here. x32 is defined as arm64 is unaffected because it fails |
selinux 3.8 fails to build on libc-x32 due to a mismatch in the assumptions of
sizeof(unsigned long)
,sizeof(uint32_t)
, andsizeof(__ino_t)
, as seen in https://github.com/SELinuxProject/selinux/blob/main/libselinux/src/matchpathcon.c#L270.Given the hijinks involved in x32 with the 32-bit address space, 64-bit registers, and 64-bit kernel, making
unsigned long
not 32 bits, I'm actually not sure what the right thing to do here is. Maybe avoid bareunsigned long
formathpathcon_filesppec_add
IAW sourceware's recommendations on x32/glibc at https://www.sourceware.org/glibc/wiki/x32?While not necessarily relevant here, this does hit at least the debian x32 port:
I suspect the 'right' thing to do is actually test on what x86_64-linux-gnux32/sys/types.h ends up declaring, but I don't know if that's sufficient for selinux. Hacking the
static_assert
s to do basically that seems to work, but I'm not in a spot where I can test that properly right now.The text was updated successfully, but these errors were encountered: