From: sashiko-bot@kernel.org
To: "Blaise Boscaccy" <bboscaccy@linux.microsoft.com>
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH v5 08/10] hornet: Add a light skeleton data extractor scripts
Date: Tue, 21 Apr 2026 03:06:38 +0000 [thread overview]
Message-ID: <20260421030638.AF502C2BCB6@smtp.kernel.org> (raw)
In-Reply-To: <20260420212653.438685-9-bboscaccy@linux.microsoft.com>
Sashiko AI review found 4 potential issue(s):
- [High] Payload data corruption due to grep matching multiple lines and printf format string reuse.
- [Medium] Scripts fail to preprocess headers because gcc is invoked without include paths.
- [Medium] Pipeline failure when processing BPF programs with empty map data.
- [Low] Copy-paste error in usage text and unsafe unquoted variable usage.
--
commit 5d4574520f6f666709ea15ecc132a023d9222886
Author: Blaise Boscaccy <bboscaccy@linux.microsoft.com>
hornet: Add a light skeleton data extractor scripts
This commit introduces bash scripts to extract instructions and map data from
autogenerated eBPF light skeleton headers. These payloads can be used for
signing light skeleton binaries.
> diff --git a/scripts/hornet/extract-insn.sh b/scripts/hornet/extract-insn.sh
> new file mode 100755
> index 0000000000000..52338f057ff6b
> --- /dev/null
> +++ b/scripts/hornet/extract-insn.sh
[ ... ]
> +if [ $ARGC -ne $EXPECTED_ARGS ] ; then
> + usage
> +else
> + printf $(gcc -E $1 | grep "opts_insn" | \
> + awk -F"=" '{print $2}' | sed 's/;\+$//' | sed 's/\"//g')
> +fi
Will this corrupt the binary payload if grep matches multiple lines?
Skeleton headers generated by bpftool typically contain additional
references like opts.insns_sz = sizeof(opts_insn) - 1; and
opts.insns = (void *)opts_insn;.
Because the $(...) command substitution is unquoted, Bash will split the
output into multiple arguments. Since printf doesn't receive format
specifiers, it will reuse the binary payload as the format string for each
extra argument (such as sizeof, -, 1), repeating the payload multiple times
in the output.
Also, because EXPECTED_ARGS=1 is strictly enforced, users cannot pass -I
flags. Since the generated headers unconditionally include <bpf/bpf.h> and
<bpf/skel_internal.h>, will gcc -E fail and terminate before emitting the
target variables if those headers are not in the default system include path?
Could $1 be quoted as "$1" to prevent failures when the file path
contains spaces?
> diff --git a/scripts/hornet/extract-map.sh b/scripts/hornet/extract-map.sh
> new file mode 100755
> index 0000000000000..c309f505c6238
> --- /dev/null
> +++ b/scripts/hornet/extract-map.sh
[ ... ]
> +function usage() {
> + echo "Sample script for extracting instructions"
This isn't a bug, but should this say "extracting map data" instead of
"instructions" since this is the map extractor script?
> + echo "autogenerated eBPF lskel headers"
> + echo ""
> + echo "USAGE: header_file"
> + exit
> +}
[ ... ]
> diff --git a/scripts/hornet/extract-skel.sh b/scripts/hornet/extract-skel.sh
> new file mode 100755
> index 0000000000000..6550a86b89917
> --- /dev/null
> +++ b/scripts/hornet/extract-skel.sh
[ ... ]
> +if [ $ARGC -ne $EXPECTED_ARGS ] ; then
> + usage
> +else
> + printf $(gcc -E $1 | grep "static const char opts_$2" | \
> + awk -F"=" '{print $2}' | sed 's/;\+$//' | sed 's/\"//g')
> +fi
If a BPF program uses no maps, the extracted skeleton will declare
static const char opts_data[] = "";. The awk and sed pipeline will strip
the quotes, resulting in an empty command substitution.
Since calling printf without arguments triggers a shell usage error
(bash: printf: usage: printf [-v var] format [arguments]) and returns a
non-zero exit status, will this break automated pipelines for map-less
BPF programs?
Additionally, since extract-skel.sh avoids the multiple-match issue by using
a stricter grep pattern (grep "static const char opts_$2"), does this make
extract-insn.sh and extract-map.sh redundant?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260420212653.438685-1-bboscaccy@linux.microsoft.com?part=8
next prev parent reply other threads:[~2026-04-21 3:06 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-20 21:26 [PATCH v5 00/10] Reintroduce Hornet LSM Blaise Boscaccy
2026-04-20 21:26 ` [PATCH v5 01/10] crypto: pkcs7: add flag for validated trust on a signed info block Blaise Boscaccy
2026-04-21 1:17 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 02/10] crypto: pkcs7: add ability to extract signed attributes by OID Blaise Boscaccy
2026-04-21 1:49 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 03/10] crypto: pkcs7: add tests for pkcs7_get_authattr Blaise Boscaccy
2026-04-21 2:06 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 04/10] lsm: framework for BPF integrity verification Blaise Boscaccy
2026-04-20 21:26 ` [PATCH v5 05/10] lsm: security: Add additional enum values for bpf integrity checks Blaise Boscaccy
2026-04-20 21:26 ` [PATCH v5 06/10] security: Hornet LSM Blaise Boscaccy
2026-04-21 0:08 ` Fan Wu
2026-04-21 4:29 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 07/10] hornet: Introduce gen_sig Blaise Boscaccy
2026-04-21 0:18 ` Fan Wu
2026-04-21 3:03 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 08/10] hornet: Add a light skeleton data extractor scripts Blaise Boscaccy
2026-04-21 3:06 ` sashiko-bot [this message]
2026-04-20 21:26 ` [PATCH v5 09/10] selftests/hornet: Add a selftest for the Hornet LSM Blaise Boscaccy
2026-04-21 3:04 ` sashiko-bot
2026-04-20 21:26 ` [PATCH v5 10/10] ipe: Add BPF program load policy enforcement via Hornet integration Blaise Boscaccy
2026-04-21 0:27 ` Fan Wu
2026-04-21 3:23 ` sashiko-bot
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=20260421030638.AF502C2BCB6@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bboscaccy@linux.microsoft.com \
--cc=bpf@vger.kernel.org \
--cc=sashiko@lists.linux.dev \
/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