* Re: [PATCH] Fix known_glibc_specials comparison
2024-06-13 18:08 [PATCH] Fix known_glibc_specials comparison Tulio Magno Quites Machado Filho
@ 2024-06-14 8:53 ` Nick Clifton
2024-06-14 12:28 ` Tulio Magno Quites Machado Filho
0 siblings, 1 reply; 3+ messages in thread
From: Nick Clifton @ 2024-06-14 8:53 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho, annobin
[-- Attachment #1: Type: text/plain, Size: 832 bytes --]
Hi Tulio,
> Sometimes variable path stores a longer path instead of just the name of
> a file, e.g. /usr/lib/libfoo.so instead of libfoo.so.
Err, I think, based upon your code you mean that path should be "usr/lib/libfoo.so"
instead of just "libfoo.so". (ie without the leading forward slash - there is
already code at the start of is_special_glibc_binary that handles absolute paths).
> In those cases, we need to remove all the directories before calling
> strcmp().
I am reluctant to accept this change because it would treat, eg "build/getent"
as a glibc binary when it almost certainly should not. I would prefer it if
only a known set of path prefixes were allowed.
Instead, would you mind trying out the attached alternative patch and let me
know if it solves the problem that you were investigating ?
Cheers
Nick
[-- Attachment #2: glibc-abs-path.patch --]
[-- Type: text/x-patch, Size: 1533 bytes --]
diff --git a/annocheck/hardened.c b/annocheck/hardened.c
index 604b6a1..deeb084 100644
--- a/annocheck/hardened.c
+++ b/annocheck/hardened.c
@@ -1895,30 +1895,32 @@ is_special_glibc_binary (annocheck_data * data)
return true;
}
- /* If we are testing an uninstalled rpm then the paths will start with "."
- so skip this. */
+ /* If we are testing an uninstalled rpm then the paths will probably
+ start with "." so skip this. */
if (path[0] == '.')
++path;
-
if (path[0] == '/')
+ ++path;
+ /* Look for absolute paths to known glibc install locations.
+ If found, strip the prefix.
+ This allows us to cope with symbolic links and 32-bit/64-bit multilibs. */
+ if (strchr (path, '/'))
{
- /* If the path is absolute, then strip the prefix.
- This allows us to cope with symbolic links and 32-bit/64-bit multilibs. */
static const char * known_prefixes [] =
{
/* NB/ The terminating forward slash is important. */
- "/lib/",
- "/lib64/",
- "/sbin/",
- "/usr/bin/",
- "/usr/lib/",
- "/usr/lib/gconv/",
- "/usr/lib64/",
- "/usr/lib64/gconv/",
- "/usr/lib64/glibc-hwcaps/power10/",
- "/usr/libexec/",
- "/usr/libexec/getconf/",
- "/usr/sbin/"
+ "lib/",
+ "lib64/",
+ "sbin/",
+ "usr/bin/",
+ "usr/lib/",
+ "usr/lib/gconv/",
+ "usr/lib64/",
+ "usr/lib64/gconv/",
+ "usr/lib64/glibc-hwcaps/power10/",
+ "usr/libexec/",
+ "usr/libexec/getconf/",
+ "usr/sbin/"
};
for (i = ARRAY_SIZE (known_prefixes); i--;)
^ permalink raw reply [flat|nested] 3+ messages in thread