From: Nick Clifton <nickc@redhat.com>
To: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>,
annobin@sourceware.org
Subject: Re: [PATCH] Fix known_glibc_specials comparison
Date: Fri, 14 Jun 2024 09:53:14 +0100 [thread overview]
Message-ID: <05c81419-9577-469a-a8e7-7cccea0be9fc@redhat.com> (raw)
In-Reply-To: <20240613180811.126880-1-tuliom@ascii.art.br>
[-- 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--;)
next prev parent reply other threads:[~2024-06-14 8:53 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 18:08 Tulio Magno Quites Machado Filho
2024-06-14 8:53 ` Nick Clifton [this message]
2024-06-14 12:28 ` Tulio Magno Quites Machado Filho
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=05c81419-9577-469a-a8e7-7cccea0be9fc@redhat.com \
--to=nickc@redhat.com \
--cc=annobin@sourceware.org \
--cc=tuliom@ascii.art.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).