* [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
@ 2025-11-12 18:18 hariconscious
2025-11-12 19:20 ` Greg KH
0 siblings, 1 reply; 6+ messages in thread
From: hariconscious @ 2025-11-12 18:18 UTC (permalink / raw)
To: cezary.rojewski, liam.r.girdwood, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, broonie
Cc: perex, tiwai, amadeuszx.slawinski, sakari.ailus, khalid, shuah,
david.hunter.linux, linux-sound, linux-kernel, stable,
HariKrishna Sagala
From: HariKrishna Sagala <hariconscious@gmail.com>
snprintf() returns the would-be-filled size when the string overflows
the given buffer size, hence using this value may result in a buffer
overflow (although it's unrealistic).
This patch replaces it with a safer version, scnprintf() for papering
over such a potential issue.
Link: https://github.com/KSPP/linux/issues/105
'Fixes: 5a565ba23abe ("ASoC: Intel: avs: Probing and firmware tracing
over debugfs")'
Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
---
Thank you for the feedback and the suggestions.
Corrected the indentation & commit message.
V1:
https://lore.kernel.org/all/20251112120235.54328-2-hariconscious@gmail.com/
sound/soc/intel/avs/debugfs.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/sound/soc/intel/avs/debugfs.c b/sound/soc/intel/avs/debugfs.c
index 3534de46f9e4..cdb82392b9ee 100644
--- a/sound/soc/intel/avs/debugfs.c
+++ b/sound/soc/intel/avs/debugfs.c
@@ -119,9 +119,9 @@ static ssize_t probe_points_read(struct file *file, char __user *to, size_t coun
}
for (i = 0; i < num_desc; i++) {
- ret = snprintf(buf + len, PAGE_SIZE - len,
- "Id: %#010x Purpose: %d Node id: %#x\n",
- desc[i].id.value, desc[i].purpose, desc[i].node_id.val);
+ ret = scnprintf(buf + len, PAGE_SIZE - len,
+ "Id: %#010x Purpose: %d Node id: %#x\n",
+ desc[i].id.value, desc[i].purpose, desc[i].node_id.val);
if (ret < 0)
goto free_desc;
len += ret;
base-commit: 24172e0d79900908cf5ebf366600616d29c9b417
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
2025-11-12 18:18 [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf() hariconscious
@ 2025-11-12 19:20 ` Greg KH
2025-11-12 19:33 ` Mark Brown
2025-11-13 8:46 ` Cezary Rojewski
0 siblings, 2 replies; 6+ messages in thread
From: Greg KH @ 2025-11-12 19:20 UTC (permalink / raw)
To: hariconscious
Cc: cezary.rojewski, liam.r.girdwood, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, broonie,
perex, tiwai, amadeuszx.slawinski, sakari.ailus, khalid, shuah,
david.hunter.linux, linux-sound, linux-kernel, stable
On Wed, Nov 12, 2025 at 11:48:51PM +0530, hariconscious@gmail.com wrote:
> From: HariKrishna Sagala <hariconscious@gmail.com>
>
> snprintf() returns the would-be-filled size when the string overflows
> the given buffer size, hence using this value may result in a buffer
> overflow (although it's unrealistic).
unrealistic == impossible
So why make this change at all?
> This patch replaces it with a safer version, scnprintf() for papering
> over such a potential issue.
Don't "paper over", actually fix real things.
> Link: https://github.com/KSPP/linux/issues/105
> 'Fixes: 5a565ba23abe ("ASoC: Intel: avs: Probing and firmware tracing
> over debugfs")'
No, this is not a "fix".
Also please do not wrap lines of fixes tags.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
2025-11-12 19:20 ` Greg KH
@ 2025-11-12 19:33 ` Mark Brown
2025-11-13 6:31 ` Sakari Ailus
2025-11-13 8:46 ` Cezary Rojewski
1 sibling, 1 reply; 6+ messages in thread
From: Mark Brown @ 2025-11-12 19:33 UTC (permalink / raw)
To: Greg KH
Cc: hariconscious, cezary.rojewski, liam.r.girdwood, peter.ujfalusi,
yung-chuan.liao, ranjani.sridharan, kai.vehmanen,
pierre-louis.bossart, perex, tiwai, amadeuszx.slawinski,
sakari.ailus, khalid, shuah, david.hunter.linux, linux-sound,
linux-kernel, stable
[-- Attachment #1: Type: text/plain, Size: 225 bytes --]
On Wed, Nov 12, 2025 at 02:20:19PM -0500, Greg KH wrote:
> Also please do not wrap lines of fixes tags.
Someone probably ought to teach checkpatch about that one, it moans
about long lines without checking for Fixes: IIRC.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
2025-11-12 19:33 ` Mark Brown
@ 2025-11-13 6:31 ` Sakari Ailus
0 siblings, 0 replies; 6+ messages in thread
From: Sakari Ailus @ 2025-11-13 6:31 UTC (permalink / raw)
To: Mark Brown
Cc: Greg KH, hariconscious, cezary.rojewski, liam.r.girdwood,
peter.ujfalusi, yung-chuan.liao, ranjani.sridharan, kai.vehmanen,
pierre-louis.bossart, perex, tiwai, amadeuszx.slawinski, khalid,
shuah, david.hunter.linux, linux-sound, linux-kernel, stable
On Wed, Nov 12, 2025 at 07:33:51PM +0000, Mark Brown wrote:
> On Wed, Nov 12, 2025 at 02:20:19PM -0500, Greg KH wrote:
>
> > Also please do not wrap lines of fixes tags.
>
> Someone probably ought to teach checkpatch about that one, it moans
> about long lines without checking for Fixes: IIRC.
I can recall this issue, too... I checked how to reproduce and fix this but
it seems it's already done: I couldn't reproduce it. I'm getting this for
breaking a Fixes: line:
WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: ...
It basically now checks the subject matches with the quoted string.
So all is well!
--
Sakari Ailus
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
2025-11-12 19:20 ` Greg KH
2025-11-12 19:33 ` Mark Brown
@ 2025-11-13 8:46 ` Cezary Rojewski
2025-11-13 13:24 ` Greg KH
1 sibling, 1 reply; 6+ messages in thread
From: Cezary Rojewski @ 2025-11-13 8:46 UTC (permalink / raw)
To: Greg KH
Cc: liam.r.girdwood, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, broonie,
perex, tiwai, amadeuszx.slawinski, sakari.ailus, khalid, shuah,
david.hunter.linux, linux-sound, linux-kernel, stable,
hariconscious
On 2025-11-12 8:20 PM, Greg KH wrote:
> On Wed, Nov 12, 2025 at 11:48:51PM +0530, hariconscious@gmail.com wrote:
>> From: HariKrishna Sagala <hariconscious@gmail.com>
>>
>> snprintf() returns the would-be-filled size when the string overflows
>> the given buffer size, hence using this value may result in a buffer
>> overflow (although it's unrealistic).
>
> unrealistic == impossible
>
> So why make this change at all?
The problem will never occur in production-scenario given the AudioDSP
firmware limitation - max ~10 probe-point entries so, the built string
will be far away from 4K_SZ bytes.
If the verdict is: ignore the recommendation as the problem is
unrealistic, I'm OK with that. Typically though I'd prefer to stick to
the recommendations.
>
>> This patch replaces it with a safer version, scnprintf() for papering
>> over such a potential issue.
>
> Don't "paper over", actually fix real things.
>
>
>> Link: https://github.com/KSPP/linux/issues/105
>> 'Fixes: 5a565ba23abe ("ASoC: Intel: avs: Probing and firmware tracing
>> over debugfs")'
>
> No, this is not a "fix".
The patch isn't worded well, that's clear.
While the patch is an outcome of static-analysis, isn't it good to have
'Fixes:' to point out the offending commit regardless?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf()
2025-11-13 8:46 ` Cezary Rojewski
@ 2025-11-13 13:24 ` Greg KH
0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2025-11-13 13:24 UTC (permalink / raw)
To: Cezary Rojewski
Cc: liam.r.girdwood, peter.ujfalusi, yung-chuan.liao,
ranjani.sridharan, kai.vehmanen, pierre-louis.bossart, broonie,
perex, tiwai, amadeuszx.slawinski, sakari.ailus, khalid, shuah,
david.hunter.linux, linux-sound, linux-kernel, stable,
hariconscious
On Thu, Nov 13, 2025 at 09:46:12AM +0100, Cezary Rojewski wrote:
> On 2025-11-12 8:20 PM, Greg KH wrote:
> > On Wed, Nov 12, 2025 at 11:48:51PM +0530, hariconscious@gmail.com wrote:
> > > From: HariKrishna Sagala <hariconscious@gmail.com>
> > >
> > > snprintf() returns the would-be-filled size when the string overflows
> > > the given buffer size, hence using this value may result in a buffer
> > > overflow (although it's unrealistic).
> >
> > unrealistic == impossible
> >
> > So why make this change at all?
>
> The problem will never occur in production-scenario given the AudioDSP
> firmware limitation - max ~10 probe-point entries so, the built string will
> be far away from 4K_SZ bytes.
>
> If the verdict is: ignore the recommendation as the problem is unrealistic,
> I'm OK with that. Typically though I'd prefer to stick to the
> recommendations.
That's fine, but don't claim that it fixes a buffer overflow when that
is NOT what this is doing at all.
> > > This patch replaces it with a safer version, scnprintf() for papering
> > > over such a potential issue.
> >
> > Don't "paper over", actually fix real things.
> >
> >
> > > Link: https://github.com/KSPP/linux/issues/105
> > > 'Fixes: 5a565ba23abe ("ASoC: Intel: avs: Probing and firmware tracing
> > > over debugfs")'
> >
> > No, this is not a "fix".
>
> The patch isn't worded well, that's clear.
> While the patch is an outcome of static-analysis, isn't it good to have
> 'Fixes:' to point out the offending commit regardless?
No, it is not "fixing" anything. Please don't claim that it does. It
is "just" a code transformation to get rid of an api that some people do
not like.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-11-13 13:24 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-12 18:18 [PATCH v2] ASoC: Intel: avs: Fix potential buffer overflow by snprintf() hariconscious
2025-11-12 19:20 ` Greg KH
2025-11-12 19:33 ` Mark Brown
2025-11-13 6:31 ` Sakari Ailus
2025-11-13 8:46 ` Cezary Rojewski
2025-11-13 13:24 ` Greg KH
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox