public inbox for linux-kbuild@vger.kernel.org
 help / color / mirror / Atom feed
From: David Disseldorp <ddiss@suse.de>
To: linux-kbuild@vger.kernel.org
Cc: David Disseldorp <ddiss@suse.de>
Subject: [PATCH v2 1/2] scripts: headers_install: filter ignored configs via sed
Date: Thu,  8 Jan 2026 07:39:42 +1100	[thread overview]
Message-ID: <20260107205239.6390-2-ddiss@suse.de> (raw)
In-Reply-To: <20260107205239.6390-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.

INFILE may carry a prefix for e.g. make headers_install O=build_dir .
Therefore, don't anchor the <file-name>:<CONFIG-option> match against
the beginning of INFILE.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 scripts/headers_install.sh | 55 +++++++++++++-------------------------
 1 file changed, 19 insertions(+), 36 deletions(-)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 0e4e939efc940..2181abd1c9b70 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -42,7 +42,7 @@ 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:
@@ -53,48 +53,31 @@ configs=$(sed -e '
 	N
 	b comment
 :print
+	# The entries in the following list do not result in an error.
+	# Please do not add a new entry. This list is only for existing ones.
+	# The list will be reduced gradually, and deleted eventually.
+	#
+	# The format is s@<file-name>:<CONFIG-option>\n@@ in each line.
+	s@arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE\n@@
+	s@arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8\n@@
+	s@arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO\n@@
+	s@arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT\n@@
+	s@arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION\n@@
+	s@arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64\n@@
+
+	# Jump if any of the above filters applied, otherwise error out.
+	t check
+	s@^\(.*\)\n.*@error: \1 leak to user-space@
 	P
-	D
+	Q2
 :check
-	s:^\(CONFIG_[[:alnum:]_]*\):\1\n:
+	s@^\(CONFIG_[[:alnum:]_]*\)@'"$INFILE"':\1\n@
 	t print
 	s:^[[:alnum:]_][[:alnum:]_]*::
 	s:^[^[:alnum:]_][^[:alnum:]_]*::
 	t check
 	d
-' $OUTFILE)
-
-# The entries in the following list do not result in an error.
-# Please do not add a new entry. This list is only for existing ones.
-# The list will be reduced gradually, and deleted eventually. (hopefully)
-#
-# The format is <file-name>:<CONFIG-option> in each line.
-config_leak_ignores="
-arch/arc/include/uapi/asm/swab.h:CONFIG_ARC_HAS_SWAPE
-arch/arm/include/uapi/asm/ptrace.h:CONFIG_CPU_ENDIAN_BE8
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_NO
-arch/nios2/include/uapi/asm/swab.h:CONFIG_NIOS2_CI_SWAB_SUPPORT
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_IA32_EMULATION
-arch/x86/include/uapi/asm/auxvec.h:CONFIG_X86_64
-"
-
-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


  reply	other threads:[~2026-01-07 20:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-07 20:39 [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing David Disseldorp
2026-01-07 20:39 ` David Disseldorp [this message]
2026-01-12 10:51   ` [PATCH v2 1/2] scripts: headers_install: filter ignored configs via sed Thomas Weißschuh
2026-01-12 11:14     ` David Disseldorp
2026-01-07 20:39 ` [PATCH v2 2/2] scripts: headers_install: avoid extra sed call for license check David Disseldorp
2026-01-21 11:34   ` Nicolas Schier
2026-01-29 12:27     ` David Disseldorp
2026-01-08  8:38 ` [PATCH v2 0/2] scripts: headers_install: avoid some reprocessing 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=20260107205239.6390-2-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