From: Takashi Iwai <tiwai@suse.de>
To: Mark Brown <broonie@kernel.org>
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
tiwai@suse.com, perex@perex.cz, amade@asmblr.net,
kuninori.morimoto.gx@renesas.com, linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: control: Verify put() result when in debug mode
Date: Fri, 30 Jan 2026 15:29:08 +0100 [thread overview]
Message-ID: <87ikcjxjgr.wl-tiwai@suse.de> (raw)
In-Reply-To: <60f477d0-ea1f-435a-bd8c-4e7e06a1802b@sirena.org.uk>
On Fri, 30 Jan 2026 15:12:58 +0100,
Mark Brown wrote:
> > + struct snd_ctl_elem_value original;
>
> > + ret = kctl->get(kctl, &original);
> > + if (ret)
> > + return ret;
>
> > + retcmp = memcmp(&original.value.bytes.data[0], &control->value.bytes.data[0],
> > + sizeof(original.value.bytes.data[0]));
> > + if (retcmp)
> > + retcmp = 1;
>
> original was just allocated from the stack so who knows what values it
> had originally, and the get() is only going to write the part of the
> value that has data since the normal get() path has a memset() in the
> core. Similarly with the new value coming in from userspace there's no
> requirement for userspace to set anything that isn't part of the value
> being written to any particular value. This means we're liable to get
> spurious mismatches.
Yes, and if I understand correctly, the above memcmpy() just compare
the single byte from original and the result? Then it'll lead to
false-positive outputs.
We'll need to query the control info and check the relevant values
for each info->type and count.
Also, better to name it snd_ctl_put_verify() instead of
snd_ctl_write_verify(); it's an equivalent with snd_ctl_put() having
an additional verification.
thanks,
Takashi
next prev parent reply other threads:[~2026-01-30 14:29 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-30 13:55 [PATCH] ALSA: control: Verify put() result when in debug mode Cezary Rojewski
2026-01-30 14:12 ` Mark Brown
2026-01-30 14:29 ` Takashi Iwai [this message]
2026-01-30 15:00 ` Cezary Rojewski
2026-01-30 15:13 ` Mark Brown
2026-02-04 11:37 ` Cezary Rojewski
2026-01-30 15:14 ` Takashi Iwai
2026-02-04 11:33 ` Cezary Rojewski
2026-01-30 14:49 ` Cezary Rojewski
2026-02-02 0:20 ` Kuninori Morimoto
2026-02-04 11:30 ` Cezary Rojewski
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=87ikcjxjgr.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=amade@asmblr.net \
--cc=broonie@kernel.org \
--cc=cezary.rojewski@intel.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.