From: David Disseldorp <ddiss@suse.de>
To: linux-kbuild@vger.kernel.org
Cc: David Disseldorp <ddiss@suse.de>
Subject: [RFC PATCH 2/3] scripts: headers_install: filter ignored configs via sed
Date: Wed, 12 Nov 2025 00:16:21 +1100 [thread overview]
Message-ID: <20251111132021.22809-3-ddiss@suse.de> (raw)
In-Reply-To: <20251111132021.22809-1-ddiss@suse.de>
The sed script currently prints any CONFIG_ entries carried in installed
headers. A subsequent shell script parses this output to check whether
the found CONFIG_ values should be ignored or not.
Drop the unnecessary sed output post-processing and instead skip over
ignored CONFIG_ values as part of initial processing.
Signed-off-by: David Disseldorp <ddiss@suse.de>
---
| 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
--git a/scripts/headers_install.sh b/scripts/headers_install.sh
index d64b01806a05e..f46e91aa416cf 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -54,11 +54,16 @@ arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
"
+# generate sed regex to filter out ignored configs.
+# A subsequent 't' branches if any of these filters match.
+sed_filter_ignores=$(echo "$config_leak_ignores" \
+ | sed -ne "s@$INFILE:\(.*\)"'@\ts:^\1\\n::@p')
+
scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ $TMPFILE > $OUTFILE
[ $? -gt 1 ] && exit 1
# Remove /* ... */ style comments, and find CONFIG_ references in code
-configs=$(sed -e '
+sed -e '
:comment
s:/\*[^*][^*]*:/*:
s:/\*\*\**\([^/]\):/*\1:
@@ -68,9 +73,12 @@ configs=$(sed -e '
/\/\*/! b check
N
b comment
-:print
+:print'"
+ $sed_filter_ignores
+ t check
+ s@^\(.*\)\n.*@error: $INFILE leak \1 to user-space@
P
- D
+ Q2"'
:check
s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
t print
@@ -78,25 +86,7 @@ configs=$(sed -e '
s:^[^[:alnum:]_][^[:alnum:]_]*::
t check
d
-' $OUTFILE)
-
-for c in $configs
-do
- leak_error=1
-
- for ignore in $config_leak_ignores
- do
- if echo "$INFILE:$c" | grep -q "$ignore$"; then
- leak_error=
- break
- fi
- done
-
- if [ "$leak_error" = 1 ]; then
- echo "error: $INFILE: leak $c to user-space" >&2
- exit 1
- fi
-done
+' $OUTFILE >&2 || exit 1
rm -f $TMPFILE
trap - EXIT
--
2.51.0
next prev parent reply other threads:[~2025-11-11 13:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 13:16 [RFC PATCH 0/3] scripts: headers_install: avoid some reprocessing David Disseldorp
2025-11-11 13:16 ` [RFC PATCH 1/3] scripts: headers_install: move config_leak_ignores assignment David Disseldorp
2025-11-11 13:16 ` David Disseldorp [this message]
2025-11-11 13:16 ` [RFC PATCH 3/3] scripts: headers_install: avoid license check fork David Disseldorp
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=20251111132021.22809-3-ddiss@suse.de \
--to=ddiss@suse.de \
--cc=linux-kbuild@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;
as well as URLs for NNTP newsgroup(s).