lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aRSNrXnmPTElmx5H@kekkonen.localdomain>
Date: Wed, 12 Nov 2025 15:37:49 +0200
From: Sakari Ailus <sakari.ailus@...ux.intel.com>
To: hariconscious@...il.com
Cc: cezary.rojewski@...el.com, liam.r.girdwood@...ux.intel.com,
	peter.ujfalusi@...ux.intel.com, yung-chuan.liao@...ux.intel.com,
	ranjani.sridharan@...ux.intel.com, kai.vehmanen@...ux.intel.com,
	pierre-louis.bossart@...ux.dev, broonie@...nel.org, perex@...ex.cz,
	tiwai@...e.com, amadeuszx.slawinski@...ux.intel.com,
	khalid@...nel.org, shuah@...nel.org, david.hunter.linux@...il.com,
	linux-sound@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ASoC: Intel: avs: Replace snprintf() with scnprintf()

Hi HariKrishna,

On Wed, Nov 12, 2025 at 05:32:35PM +0530, hariconscious@...il.com wrote:
> From: HariKrishna Sagala <hariconscious@...il.com>
> 
> As per the C99 standard snprintf() returns the length of the data
> that *would have been* written if there were enough space for it.
> It's generally considered safer to use the scnprintf() variant.

Not only that, but the code assumes scnprintf() behaviour to function
correctly. This should be reflected in the commit message. I.e. this is a
bugfix and should probably be cc'd to stable. Could you provide a Fixes:
tag as well?

The change itself seems fine to me, apart from indentation.

> 
> Link: https://github.com/KSPP/linux/issues/105
> Signed-off-by: HariKrishna Sagala <hariconscious@...il.com>
> ---
> This patch replaces snprintf() varaint with scnprintf() in
> scenario to know the actual length of the data rather than *would
> have been* written data of snprintf().
> No functional changes intended.
> Reference Links:
> https://lwn.net/Articles/69419/
> https://www.kernel.org/doc/html/latest/core-api/kernel-api.html#c.snprintf
> 
> Note:
> Compile & boot tested with necessary config parameters.
> Other areas of AVS uses scnprintf() variant.
> 
>  sound/soc/intel/avs/debugfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/soc/intel/avs/debugfs.c b/sound/soc/intel/avs/debugfs.c
> index 3534de46f9e4..100b95bfcd78 100644
> --- a/sound/soc/intel/avs/debugfs.c
> +++ b/sound/soc/intel/avs/debugfs.c
> @@ -119,7 +119,7 @@ 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,
> +		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)
> 
> base-commit: 24172e0d79900908cf5ebf366600616d29c9b417

-- 
Kind regards,

Sakari Ailus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ