-
Notifications
You must be signed in to change notification settings - Fork 378
Don't inject matchpathcon_filespec_add64() ifdef __x86_64__ (#463, Debian#1098481) #464
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
base: main
Are you sure you want to change the base?
Conversation
Hello, thanks for the patch! In order to get the patch reviewed and accepted, it's necessary to send it to [email protected] mailing list. The best way is to use git send-email command, e.g.:
See https://github.com/SELinuxProject/selinux/blob/main/CONTRIBUTING.md |
@nabijaczleweli thank you for the patch, I was about to submit a very similar one for RV32. unfortunately this one doesn't fully fix the issue for all 32-bit LFS platforms, and I'm not sure what would be the best way to do that |
The definition is using -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __TIMESIZE < 64 or also #ifndef __INO_T_MATCHES_INO64_T |
I think you nailed it actually yeah |
perfect, thank you :) |
hi sorry to bother you again, just wanted to note that (if I'm not mistaken) this patch breaks builds with of course, the previous assertion static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch"); was also wrong... I'd suggest a third clause, e.g.: #if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) && !defined(__INO_T_MATCHES_INO64_T)
/*...*/
#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || !defined(__INO_T_MATCHES_INO64_T)
static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch");
#else
static_assert(sizeof(uint32_t) == sizeof(ino_t), "inode size mismatch");
#endif |
…4_T) instead of using __BITS_PER_LONG < 64 as proxy The __INO_T_MATCHES_INO64_T is defined if ino_t would be the same size as ino64_t if -D_FILE_OFFSET_BITS=64 were not defined. This is /exactly/ what /* ABI backwards-compatible shim for non-LFS 32-bit systems */ #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 is trying to get at, but currently fails because x32/RV32 are "LFS" with 32-bit longs and 64-bit time_ts natively. 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). glibc headers allow us to check the condition we care about directly. Fixes: commit 9395cc0 ("Always build for LFS mode on 32-bit archs.") Closes: SELinuxProject#463 Closes: Debian#1098481 Signed-off-by: наб <[email protected]> Cc: Alba Mendez <[email protected]>
…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: наб <[email protected]>
I can repro this on i386, yeah; https://lore.kernel.org/selinux/jxjamggy4xaie53uyfuvriryqj4mtdc7gqr4gmjveyhwoukrxm@tarta.nabijaczleweli.xyz/t/#u |
perfect, thanks again! |
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
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
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
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
&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.