Skip to content

Commit edf4812

Browse files
Don't inject matchpathcon_filespec_add64() ifdef __x86_64__
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: #463 Closes: Debian#1098481
1 parent 71aec30 commit edf4812

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

libselinux/include/selinux/selinux.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ extern int matchpathcon_index(const char *path,
537537
with the same inode (e.g. due to multiple hard links). If so, then
538538
use the latter of the two specifications based on their order in the
539539
file contexts configuration. Return the used specification index. */
540-
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
540+
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 && !defined(__x86_64__)
541541
#define matchpathcon_filespec_add matchpathcon_filespec_add64
542542
#endif
543543
extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file);

libselinux/src/matchpathcon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file)
261261
return -1;
262262
}
263263

264-
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
264+
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64 && !defined(__x86_64__)
265265
/* alias defined in the public header but we undefine it here */
266266
#undef matchpathcon_filespec_add
267267

@@ -282,7 +282,7 @@ int matchpathcon_filespec_add(unsigned long ino, int specind,
282282
}
283283
#else
284284

285-
static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch");
285+
static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch");
286286

287287
#endif
288288

0 commit comments

Comments
 (0)