From: TAKANO Mitsuhiro via B4 Relay <devnull+takano32.gmail.com@kernel.org>
To: Vaibhav Agarwal <vaibhav.sr@gmail.com>,
Mark Greer <mgreer@animalcreek.com>,
Johan Hovold <johan@kernel.org>, Alex Elder <elder@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: greybus-dev@lists.linaro.org, linux-staging@lists.linux.dev,
linux-kernel@vger.kernel.org,
TAKANO Mitsuhiro <takano32@gmail.com>
Subject: [PATCH] staging: greybus: audio: bound sscanf() string widths to NAME_SIZE
Date: Sat, 28 Nov 2026 22:29:16 +0000 [thread overview]
Message-ID: <20261128-b4-greybus-audio-sscanf-bounds-v1-1-0477ec86d253@gmail.com> (raw)
From: TAKANO Mitsuhiro <takano32@gmail.com>
In gbaudio_module_update() and find_gb_module(), sscanf() reads strings
using unbounded "%s" specifiers into stack buffers of size NAME_SIZE (32).
If the input string contains a token of 32 bytes or longer, sscanf()
overflows the stack buffer.
Limit the string conversion widths to 31 characters so they always fit
within NAME_SIZE including the terminating NUL byte.
Signed-off-by: TAKANO Mitsuhiro <takano32@gmail.com>
---
Verification: compile-tested on x86_64 with CONFIG_GREYBUS_AUDIO=m
(drivers/staging/greybus/audio_codec.o with W=1, 0 warnings;
drivers/staging/greybus/audio_topology.o default build, 0 warnings) and
checked with scripts/checkpatch.pl --strict. Checked against linux-next
(next-20261127) and lore.kernel.org for duplicates. Not runtime-tested on
Greybus hardware.
The change and the changelog text were produced with an AI coding
assistant (Gemini) working from the tree; I reviewed the diff and the
reasoning, and I am responsible for the submission.
---
drivers/staging/greybus/audio_codec.c | 2 +-
drivers/staging/greybus/audio_topology.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/greybus/audio_codec.c b/drivers/staging/greybus/audio_codec.c
index 9a4f6bca8..2b3d834bb 100644
--- a/drivers/staging/greybus/audio_codec.c
+++ b/drivers/staging/greybus/audio_codec.c
@@ -311,7 +311,7 @@ int gbaudio_module_update(struct gbaudio_codec_info *codec,
}
/* parse dai_id from AIF widget's stream_name */
- if (sscanf(w->sname, "%s %d %s", intf_name, &dai_id, dir) != 3) {
+ if (sscanf(w->sname, "%31s %d %31s", intf_name, &dai_id, dir) != 3) {
dev_err(codec->dev, "Error while parsing dai_id for %s\n", w->name);
return -EINVAL;
}
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c
index 82d6339b2..a69e5e348 100644
--- a/drivers/staging/greybus/audio_topology.c
+++ b/drivers/staging/greybus/audio_topology.c
@@ -28,7 +28,7 @@ static struct gbaudio_module_info *find_gb_module(struct gbaudio_codec_info *cod
if (!name)
return NULL;
- if (sscanf(name, "%s %d", begin, &dev_id) != 2)
+ if (sscanf(name, "%31s %d", begin, &dev_id) != 2)
return NULL;
dev_dbg(codec->dev, "%s:Find module#%d\n", __func__, dev_id);
---
base-commit: f93eb7cfc4bfa5d46340f360873726e3e77f2365
change-id: 20261128-b4-greybus-audio-sscanf-bounds-3091c62b06d9
Best regards,
--
TAKANO Mitsuhiro <takano32@gmail.com>
next reply other threads:[~2026-11-28 22:29 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 22:29 TAKANO Mitsuhiro via B4 Relay [this message]
2026-11-29 19:10 ` TAKANO Mitsuhiro
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=20261128-b4-greybus-audio-sscanf-bounds-v1-1-0477ec86d253@gmail.com \
--to=devnull+takano32.gmail.com@kernel.org \
--cc=elder@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=greybus-dev@lists.linaro.org \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=mgreer@animalcreek.com \
--cc=takano32@gmail.com \
--cc=vaibhav.sr@gmail.com \
/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®