···1-From 86211534862622124d26e8570034efc1f5d78823 Mon Sep 17 00:00:00 2001
2-From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= <nabijaczleweli@nabijaczleweli.xyz>
3-Date: Sat, 22 Feb 2025 23:09:30 +0100
4-Subject: [PATCH] Inject matchpathcon_filespec_add64() if
5- !defined(__INO_T_MATCHES_INO64_T) instead of using __BITS_PER_LONG < 64 as
6- proxy
7-MIME-Version: 1.0
8-Content-Type: text/plain; charset=UTF-8
9-Content-Transfer-Encoding: 8bit
10-11-The __INO_T_MATCHES_INO64_T is defined
12-if ino_t would be the same size as ino64_t
13-if -D_FILE_OFFSET_BITS=64 were not defined.
14-15-This is /exactly/ what
16- /* ABI backwards-compatible shim for non-LFS 32-bit systems */
17- #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
18-is trying to get at, but currently fails because x32/RV32 are "LFS"
19-with 32-bit longs and 64-bit time_ts natively.
20-21-Thus, the
22- static_assert(sizeof(unsigned long) == sizeof(__ino_t), "inode size mismatch");
23-assertion fails (__ino_t is the "kernel ino_t" type,
24-which generally corresponds to the kernel's ulong, which is u64 on x32).
25-26-glibc headers allow us to check the condition we care about directly.
27-28-Fixes: commit 9395cc0322 ("Always build for LFS mode on 32-bit archs.")
29-Closes: #463
30-Closes: Debian#1098481
31-Signed-off-by: наб <nabijaczleweli@nabijaczleweli.xyz>
32-Cc: Alba Mendez <me@alba.sh>
33----
34- libselinux/include/selinux/selinux.h | 2 +-
35- libselinux/src/matchpathcon.c | 4 ++--
36- 2 files changed, 3 insertions(+), 3 deletions(-)
37-38diff --git libselinux/include/selinux/selinux.h libselinux/include/selinux/selinux.h
39index f3cf5a209..f64896b7a 100644
40--- libselinux/include/selinux/selinux.h
···44 use the latter of the two specifications based on their order in the
45 file contexts configuration. Return the used specification index. */
46-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
47-+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && !defined(__INO_T_MATCHES_INO64_T)
48 #define matchpathcon_filespec_add matchpathcon_filespec_add64
49 #endif
50 extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file);
···57 }
5859-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
60-+#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && !defined(__INO_T_MATCHES_INO64_T)
61 /* alias defined in the public header but we undefine it here */
62 #undef matchpathcon_filespec_add
6364-@@ -282,7 +282,7 @@ int matchpathcon_filespec_add(unsigned long ino, int specind,
0065 }
000066 #else
6768-static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch");
69-+static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch");
7071 #endif
72
···00000000000000000000000000000000000001diff --git libselinux/include/selinux/selinux.h libselinux/include/selinux/selinux.h
2index f3cf5a209..f64896b7a 100644
3--- libselinux/include/selinux/selinux.h
···7 use the latter of the two specifications based on their order in the
8 file contexts configuration. Return the used specification index. */
9-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
10++#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)
11 #define matchpathcon_filespec_add matchpathcon_filespec_add64
12 #endif
13 extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file);
···20 }
2122-#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64 && __BITS_PER_LONG < 64
23++#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)
24 /* alias defined in the public header but we undefine it here */
25 #undef matchpathcon_filespec_add
2627+@@ -280,9 +280,13 @@ int matchpathcon_filespec_add(unsigned long ino, int specind,
28+ {
29+ return matchpathcon_filespec_add64(ino, specind, file);
30 }
31++#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || defined(__INO_T_MATCHES_INO64_T)
32++
33++static_assert(sizeof(uint64_t) == sizeof(ino_t), "inode size mismatch");
34++
35 #else
3637-static_assert(sizeof(unsigned long) == sizeof(ino_t), "inode size mismatch");
38++static_assert(sizeof(uint32_t) == sizeof(ino_t), "inode size mismatch");
3940 #endif
41