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: <2413481.ElGaqSPkdT@mbox>
Date: Thu, 03 Jul 2025 22:28:13 +0530
From: akshay bansod <akbansd@...il.com>
To: Andy Shevchenko <andriy.shevchenko@...el.com>
Cc: Lorenzo Bianconi <lorenzo@...nel.org>,
 Jonathan Cameron <jic23@...nel.org>, David Lechner <dlechner@...libre.com>,
 Nuno Sá <nuno.sa@...log.com>,
 Andy Shevchenko <andy@...nel.org>,
 linux-kernel-mentees@...ts.linuxfoundation.org, skhan@...uxfoundation.org,
 linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] iio: st_lsm6dsx: Replace scnprintf with sysfs_emit

On Thursday, 3 July 2025 10:12 pm +0530 Andy Shevchenko wrote:
> On Thu, Jul 03, 2025 at 11:08:59AM +0530, Akshay Bansod wrote:
> > Update the sysfs interface for sampling frequency and scale attributes.
> > Replace `scnprintf()` with `sysfs_emit_at()` which is PAGE_SIZE-aware
> > and recommended for use in sysfs.
> 
> 'must' is stronger than 'recommendation'.
> Of has the documentation been changed lately?
> 
> ...
> 
> > st_lsm6dsx_sysfs_sampling_frequency_avail(struct device *dev,
> 
> >  	odr_table = &sensor->hw->settings->odr_table[sensor->id];
> >  	for (i = 0; i < odr_table->odr_len; i++)
> > -		len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%03d ",
> > -				 odr_table->odr_avl[i].milli_hz / 1000,
> > -				 odr_table->odr_avl[i].milli_hz % 1000);
> > +		len += sysfs_emit_at(buf, len, "%d.%03d ",
> > +				     odr_table->odr_avl[i].milli_hz / 1000,
> > +				     odr_table->odr_avl[i].milli_hz % 1000);
> >  	buf[len - 1] = '\n';
> 
> My gosh, this is error prone. I'm wondering when some CIs will start to
> complain on this line. But this was already before your change...
> 
I'm planning to drop It entirely or should I replace it with another `sysfs_emit_at()` ?
I've seen other device driver returning space terminated buffers. Maybe I'm overlooking
something.

> >  	return len;
> 
> ...
> 
> >  	fs_table = &hw->settings->fs_table[sensor->id];
> >  	for (i = 0; i < fs_table->fs_len; i++)
> > -		len += scnprintf(buf + len, PAGE_SIZE - len, "0.%09u ",
> > -				 fs_table->fs_avl[i].gain);
> > +		len += sysfs_emit_at(buf, len, "0.%09u ",
> > +				     fs_table->fs_avl[i].gain);
> >  	buf[len - 1] = '\n';
> 
> Ditto.
> 
> 

regards,
Akshay Bansod




Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ