mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hamdy Abou El Anein <info@daylightlinux.ch>
To: linux-kernel@vger.kernel.org
Cc: hamdy.aea@protonmail.com
Subject: [PATCH] scripts: check_extable: match allowlisted section names exactly
Date: Tue,  3 Nov 2026 17:42:05 +0100	[thread overview]
Message-ID: <20261103164205.129703-1-info@daylightlinux.ch> (raw)

From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>

The unanchored .text and .fixup expressions match more than the two
allowlisted sections. For example, relocations into non-executable
.text.data or .fixup_data sections are silently skipped. The unescaped
dot also matches a section called atext.

Filter the relocation target field with anchored, escaped section
names and an optional relocation addend. Apply the same exact match
after resolving a symbol to its section.

Tested assembled ELF objects with .text and .fixup targets, and with
non-executable .data, .text.data, .fixup_data and atext targets. The
allowlisted sections still pass; all non-executable targets are
reported and cause a nonzero exit.

AI assistance: ChatGPT/Codex identified the issue and prepared the
change, commit message and executable regression tests.

Fixes: c31e4b832f12 ("scripts: add check_extable.sh script.")
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
 scripts/check_extable.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/scripts/check_extable.sh b/scripts/check_extable.sh
index 4b380564cf7..eb299e182d9 100755
--- a/scripts/check_extable.sh
+++ b/scripts/check_extable.sh
@@ -10,10 +10,10 @@ file ${obj} | grep -q ELF || (echo "${obj} is not an ELF file." 1>&2 ; exit 0)
 objdump -hj __ex_table ${obj} 2> /dev/null > /dev/null
 [ $? -ne 0 ] && exit 0
 
-white_list=.text,.fixup
+white_list='(\.text|\.fixup)'
 
 suspicious_relocs=$(objdump -rj __ex_table ${obj}  | tail -n +6 |
-			grep -v $(eval echo -e{${white_list}}) | awk '{print $3}')
+			awk 'NF {print $3}' | grep -Ev "^${white_list}([+-]0x[0-9a-f]+)?$")
 
 # No suspicious relocs in __ex_table, jobs a good'un
 [ -z "${suspicious_relocs}" ] && exit 0
@@ -120,7 +120,7 @@ function diagnose()
 	# In this case objdump was presenting us with a reloc to a symbol
 	# rather than a section. Now that we've got the actual section,
 	# we can skip it if it's in the white_list.
-	if [ -z "$( echo $section | grep -v $(eval echo -e{${white_list}}))" ]; then
+	if [ -z "$( echo $section | grep -Ev "^${white_list}$")" ]; then
 	    continue;
 	fi
 

                 reply	other threads:[~2026-11-03 16:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20261103164205.129703-1-info@daylightlinux.ch \
    --to=info@daylightlinux.ch \
    --cc=hamdy.aea@protonmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®