libselinux: be careful with non-portable LFS macro
PATCH v2 1/1 libselinux: be careful with non-portable LFS macro
musl does not provide the obsolete LFS64 APIs (like ino64_t) — ino_t has always been 64-bit on all platforms there. That means there's also no __INO_T_MATCHES_INO64_T macro, meaning the check would pass and reach the static asserts for the shim, which would fail due to there being no ino64_t to check the size of. Fix this by only assuming the absense of __INO_T_MATCHES_INO64_t is meaningful when another non-portable Glibc macro, __INO64_T_TYPE, is defined. If both are missing, that probably just means there is no ino64_t.
---
v2: Made the same change to the condition in the header, as suggested
in a GitHub comment. The omission didn't seem to break anything, but it makes sense to change it there too.
https://github.com/NixOS/nixpkgs/pull/391728#issuecomment-2832282846
libselinux/include/selinux/selinux.h | 2 +- libselinux/src/matchpathcon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
libselinux/include/selinux/selinux.h +1 -1
@@ -537,7 +537,7 @@ extern int matchpathcon_index(const char *path,with the same inode (e.g. due to multiple hard links). If so, then use the latter of the two specifications based on their order in the file contexts configuration. Return the used specification index. */ -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && !defined(__INO_T_MATCHES_INO64_T) +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)#define matchpathcon_filespec_add matchpathcon_filespec_add64#endif extern int matchpathcon_filespec_add (ino_t ino,int specind,const char *file);
libselinux/src/matchpathcon.c +1 -1
@@ -261,7 +261,7 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file)return -1 ; } -#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && !defined(__INO_T_MATCHES_INO64_T) +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)/* alias defined in the public header but we undefine it here */ #undef matchpathcon_filespec_add
base-commit: 2647cc0fdca326b81ee3c08718cbe19b7866b53a
Signature · 1 line
2.47.2
Quoted 10 lines · Alyssa Ross
musl does not provide the obsolete LFS64 APIs (like
ino64_t) —ino_thas always been 64-bit on all platforms there. That means there's also no__INO_T_MATCHES_INO64_Tmacro, meaning the check would pass and reach the static asserts for the shim, which would fail due to there being noino64_tto check the size of. Fix this by only assuming the absense of__INO_T_MATCHES_INO64_tis meaningful when another non-portable Glibc macro,__INO64_T_TYPE, is defined. If both are missing, that probably just means there is noino64_t.
Quoted 2 lines
Fixes 5c3fcbd9 ("Inject matchpathcon_filespec_add64() if !defined(__INO_T_MATCHES_INO64_T) instead of using __BITS_PER_LONG < 64 as proxy")Signed-off-by Alyssa Ross <[email protected]>
Quoted 41 lines
---
v2: Made the same change to the condition in the header, as suggested
in a GitHub comment. The omission didn't seem to break anything, but it makes sense to change it there too.
https://github.com/NixOS/nixpkgs/pull/391728#issuecomment-2832282846libselinux/include/selinux/selinux.h | 2 +- libselinux/src/matchpathcon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)libselinux/include/selinux/selinux.h +1
-1@@ -537,7 +537,7 @@ extern int matchpathcon_index(const char *path,with the same inode (e.g. due to multiple hard links). If so, then use the latter of the two specifications based on their order in the file contexts configuration. Return the used specification index. */ -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && !defined(__INO_T_MATCHES_INO64_T) +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)#define matchpathcon_filespec_add matchpathcon_filespec_add64#endif extern int matchpathcon_filespec_add (ino_t ino,int specind,const char *file);libselinux/src/matchpathcon.c +1
-1@@ -261,7 +261,7 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file)return -1 ; } -#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && !defined(__INO_T_MATCHES_INO64_T) +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)/* alias defined in the public header but we undefine it here */ #undef matchpathcon_filespec_addbase-commit:
2647cc0fdca326b81ee3c08718cbe19b7866b53a--
2.47.2
Quoted 12 lines · James Carter
Quoted 10 lines · Alyssa Ross
musl does not provide the obsolete LFS64 APIs (like
ino64_t) —ino_thas always been 64-bit on all platforms there. That means there's also no__INO_T_MATCHES_INO64_Tmacro, meaning the check would pass and reach the static asserts for the shim, which would fail due to there being noino64_tto check the size of. Fix this by only assuming the absense of__INO_T_MATCHES_INO64_tis meaningful when another non-portable Glibc macro,__INO64_T_TYPE, is defined. If both are missing, that probably just means there is noino64_t.
Quoted 5 lines
Quoted 2 lines
Fixes 5c3fcbd9 ("Inject matchpathcon_filespec_add64() if !defined(__INO_T_MATCHES_INO64_T) instead of using __BITS_PER_LONG < 64 as proxy")Signed-off-by Alyssa Ross <[email protected]>Acked-by James Carter <[email protected]>
Merged.
Thanks,
Jim
Quoted 41 lines
Quoted 41 lines
---
v2: Made the same change to the condition in the header, as suggested
in a GitHub comment. The omission didn't seem to break anything, but it makes sense to change it there too.
https://github.com/NixOS/nixpkgs/pull/391728#issuecomment-2832282846libselinux/include/selinux/selinux.h | 2 +- libselinux/src/matchpathcon.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)libselinux/include/selinux/selinux.h +1
-1@@ -537,7 +537,7 @@ extern int matchpathcon_index(const char *path,with the same inode (e.g. due to multiple hard links). If so, then use the latter of the two specifications based on their order in the file contexts configuration. Return the used specification index. */ -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && !defined(__INO_T_MATCHES_INO64_T) +#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)#define matchpathcon_filespec_add matchpathcon_filespec_add64#endif extern int matchpathcon_filespec_add (ino_t ino,int specind,const char *file);libselinux/src/matchpathcon.c +1
-1@@ -261,7 +261,7 @@ int matchpathcon_filespec_add(ino_t ino, int specind, const char *file)return -1 ; } -#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && !defined(__INO_T_MATCHES_INO64_T) +#if (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS ==64 ) && defined(__INO64_T_TYPE) && !defined(__INO_T_MATCHES_INO64_T)/* alias defined in the public header but we undefine it here */ #undef matchpathcon_filespec_addbase-commit:
2647cc0fdca326b81ee3c08718cbe19b7866b53a--
2.47.2