From: sashiko-bot@kernel.org
To: "Bill Wendling" <morbo@google.com>
Cc: linux-scsi@vger.kernel.org, conor+dt@kernel.org,
"Chuck Lever" <cel@kernel.org>,
intel-xe@lists.freedesktop.org, devicetree@vger.kernel.org,
media-ci@linuxtv.org, robh@kernel.org,
dri-devel@lists.freedesktop.org, dmitry.torokhov@gmail.com,
"Anna Schumaker" <anna@kernel.org>,
linux-input@vger.kernel.org, "Jeff Layton" <jlayton@kernel.org>
Subject: Re: [PATCH 05/28] ALSA: usb-audio: Refactor usb_audio_make_longname() to use seq_buf
Date: Thu, 17 Sep 2026 07:38:18 +0000 [thread overview]
Message-ID: <20260917073819.100061F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260915081910.4142719-6-morbo@google.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] alsa: usb-audio: string corruption in usb_audio_make_longname() on seq_buf overflow
--
commit 4261f1e1f38e25d5a907e1a1ad3aeefb3e4075ae
Author: Bill Wendling <morbo@google.com>
ALSA: usb-audio: Refactor usb_audio_make_longname() to use seq_buf
This commit refactors usb_audio_make_longname() to use struct seq_buf
instead of deprecated string functions like strlcat() for building the
device longname.
Link: https://github.com/KSPP/linux/issues/370 [1]
> diff --git a/sound/usb/card.c b/sound/usb/card.c
> index 9307da95efbef..bdca8085fca66 100644
> --- a/sound/usb/card.c
> +++ b/sound/usb/card.c
[ ... ]
> @@ -667,44 +670,61 @@ static void usb_audio_make_longname(struct usb_device *dev,
> s = preset->vendor_name;
> else if (quirk && quirk->vendor_name)
> s = quirk->vendor_name;
> - *card->longname = 0;
> +
> + seq_buf_init(&sb, card->longname, sizeof(card->longname));
> +
> if (s && *s)
> - strscpy(card->longname, s);
> + seq_buf_puts(&sb, s);
> else if (dev->manufacturer && *dev->manufacturer)
> - strscpy(card->longname, dev->manufacturer);
> -
> - if (*card->longname) {
> - strim(card->longname);
> - if (*card->longname)
> - strlcat(card->longname, " ", sizeof(card->longname));
> + seq_buf_puts(&sb, dev->manufacturer);
> +
> + if (seq_buf_used(&sb)) {
> + char *trimmed;
> +
> + seq_buf_str(&sb);
> + trimmed = strim(card->longname);
> + if (trimmed != card->longname)
> + memmove(card->longname, trimmed, strlen(trimmed) + 1);
> + sb.len = strlen(card->longname);
> + if (sb.len)
> + seq_buf_putc(&sb, ' ');
[Severity: Medium]
Does this seq_buf_putc() call leave the string without a null terminator if
the buffer subsequently overflows?
strim() and memmove() remove leading and trailing spaces by shifting the
string and inserting a null terminator, but they leave the old shifted
characters in the buffer immediately after the new null terminator.
seq_buf_putc() then overwrites the new null terminator with a space, but
does not append a new one to maintain string safety.
If any subsequent seq_buf_puts() calls (like shortname, path, or speed)
exceed the 80-byte capacity, they silently abort and place the buffer into
an overflow state without writing a new null terminator.
At the end of usb_audio_make_longname(), seq_buf_str() sees the overflow
state and places a null terminator only at the very end of the buffer, not
at the logical string end.
Can this expose duplicated characters or trailing spaces when the device
manufacturer string and subsequent concatenated parts exceed 80 bytes?
> }
>
> - strlcat(card->longname, card->shortname, sizeof(card->longname));
> + seq_buf_puts(&sb, card->shortname);
>
> - len = strlcat(card->longname, " at ", sizeof(card->longname));
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260915081910.4142719-1-morbo@google.com?part=5
next prev parent reply other threads:[~2026-09-17 7:38 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-15 8:18 [PATCH 00/28] Replace remaining strlcat() call sites with snprintf()/seq_buf() Bill Wendling
2026-09-15 8:18 ` [PATCH 01/28] ALSA: ac97: Refactor snd_ac97_get_name() to use snprintf() Bill Wendling
2026-09-15 18:39 ` Kees Cook
2026-09-16 9:29 ` David Laight
2026-09-15 8:18 ` [PATCH 02/28] sunrpc: Refactor rpc_sockaddr2uaddr() to use snprintf() instead of strlcat() Bill Wendling
2026-09-15 10:17 ` Jeff Layton
2026-09-15 8:18 ` [PATCH 03/28] ARM: atags: Replace strlcat() with snprintf() for cmdline extend Bill Wendling
2026-09-15 19:00 ` Kees Cook
2026-09-16 8:28 ` Bill Wendling
2026-09-17 7:38 ` sashiko-bot
2026-09-15 8:18 ` [PATCH 04/28] scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init() Bill Wendling
2026-09-17 7:38 ` sashiko-bot
2026-09-15 8:18 ` [PATCH 05/28] ALSA: usb-audio: Refactor usb_audio_make_longname() to use seq_buf Bill Wendling
2026-09-17 7:38 ` sashiko-bot [this message]
2026-09-15 8:18 ` [PATCH 06/28] comedi: comedi_bond: Refactor strlcat() to seq_buf in do_dev_config() Bill Wendling
2026-09-15 8:18 ` [PATCH 07/28] scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init() Bill Wendling
2026-09-15 8:18 ` [PATCH 08/28] devlink: Refactor strlcat() to seq_buf in __devlink_compat_running_version() Bill Wendling
2026-09-17 7:38 ` sashiko-bot
2026-09-15 8:18 ` [PATCH 09/28] drm/dp_mst: Refactor build_mst_prop_path() to use seq_buf Bill Wendling
2026-09-15 8:18 ` [PATCH 10/28] of/fdt: Replace strlcat() with snprintf() in early_init_dt_scan_chosen() Bill Wendling
2026-09-15 15:05 ` Rob Herring
2026-09-15 8:18 ` [PATCH 11/28] wifi: brcmfmac: Replace strlcat() with snprintf() in brcmf_fw_alloc_request() Bill Wendling
2026-09-15 8:18 ` [PATCH 12/28] fortify: Convert strlcat() to snprintf() in strcat() Bill Wendling
2026-09-17 7:38 ` sashiko-bot
2026-09-15 8:18 ` [PATCH 13/28] i40e: Replace strlcat() with snprintf() in i40e_nvm_version_str() Bill Wendling
2026-09-15 8:18 ` [PATCH 14/28] ALSA: usb-audio: Refactor append_ctl_name() to use snprintf() Bill Wendling
2026-09-15 8:18 ` [PATCH 15/28] orangefs: Use seq_buf for debug help string generation Bill Wendling
2026-09-15 8:18 ` [PATCH 16/28] pinctrl: samsung: Use snprintf() to construct pin bank names Bill Wendling
2026-09-16 6:01 ` Loktionov, Aleksandr
2026-09-15 8:18 ` [PATCH 17/28] MIPS: cmdline: Refactor bootcmdline_append() to use snprintf() Bill Wendling
2026-09-15 8:18 ` [PATCH 18/28] LoongArch: Refactor bootcmdline_init() to use seq_buf instead of strlcat() Bill Wendling
2026-09-15 8:18 ` [PATCH 19/28] x86/setup: Use snprintf() to concatenate builtin and boot command lines Bill Wendling
2026-09-17 7:38 ` sashiko-bot
2026-09-15 8:18 ` [PATCH 20/28] parisc: Refactor strlcat() to seq_buf in setup_cmdline() Bill Wendling
2026-09-15 8:18 ` [PATCH 21/28] NFS: nfsroot: Refactor root_nfs_cat() to use snprintf() Bill Wendling
2026-09-15 18:52 ` Kees Cook
2026-09-15 19:30 ` Bill Wendling
2026-09-15 8:18 ` [PATCH 22/28] media: si2165: Use snprintf() to format frontend name Bill Wendling
2026-09-16 6:02 ` Loktionov, Aleksandr
2026-09-15 8:18 ` [PATCH 23/28] Input: synaptics_usb - use seq_buf and snprintf() for name and phys Bill Wendling
2026-09-15 8:18 ` [PATCH 24/28] EDAC/thunderx: Fix stale error context in thunderx_l2c_threaded_isr() Bill Wendling
2026-09-16 6:02 ` Loktionov, Aleksandr
2026-09-15 8:18 ` [PATCH 25/28] EDAC/thunderx: Replace strlcat() with seq_buf Bill Wendling
2026-09-15 20:00 ` Kees Cook
2026-09-16 1:09 ` Borislav Petkov
2026-09-16 21:43 ` Bill Wendling
2026-09-15 8:18 ` [PATCH 26/28] wifi: wil6210: Refactor resume_triggers2string() to use seq_buf Bill Wendling
2026-09-15 8:18 ` [PATCH 27/28] drm/xe/pf: Convert strlcat() to seq_buf in control_read() Bill Wendling
2026-09-15 18:25 ` Kees Cook
2026-09-15 8:18 ` [PATCH 28/28] drm/xe/pf: Refactor strlcat() to seq_buf in sched_group_engines_read() Bill Wendling
2026-09-15 18:30 ` Kees Cook
2026-09-15 11:24 ` [PATCH 00/28] Replace remaining strlcat() call sites with snprintf()/seq_buf() Takashi Iwai
2026-09-15 18:05 ` Kees Cook
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=20260917073819.100061F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anna@kernel.org \
--cc=cel@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jlayton@kernel.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=media-ci@linuxtv.org \
--cc=morbo@google.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@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