Skip to content

Commit 3838b0f

Browse files
Inject matchpathcon_filespec_add64() if !defined(__INO_T_MATCHES_INO64_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: #463 Closes: Debian#1098481 Signed-off-by: наб <[email protected]> Cc: Alba Mendez <[email protected]>
1 parent 71aec30 commit 3838b0f

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-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 && !defined(__INO_T_MATCHES_INO64_T)
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: 6 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) && !defined(__INO_T_MATCHES_INO64_T)
265265
/* alias defined in the public header but we undefine it here */
266266
#undef matchpathcon_filespec_add
267267

@@ -280,9 +280,13 @@ int matchpathcon_filespec_add(unsigned long ino, int specind,
280280
{
281281
return matchpathcon_filespec_add64(ino, specind, file);
282282
}
283+
#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || defined(__INO_T_MATCHES_INO64_T)
284+
285+
static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch");
286+
283287
#else
284288

285-
static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch");
289+
static_assert(sizeof(uint32_t) == sizeof(ino_t), "inode size mismatch");
286290

287291
#endif
288292

0 commit comments

Comments
 (0)