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: <2024030803-bulk-grader-3ad1@gregkh>
Date: Fri, 8 Mar 2024 09:01:24 +0000
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Alexey Dobriyan <adobriyan@...il.com>
Cc: "Rafael J. Wysocki" <rafael@...nel.org>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sysfs: make sysfs_emit() return ssize_t

On Fri, Mar 08, 2024 at 09:26:01AM +0300, Alexey Dobriyan wrote:
> On Thu, Mar 07, 2024 at 10:04:41PM +0000, Greg Kroah-Hartman wrote:
> > On Mon, Feb 05, 2024 at 01:11:36PM +0300, Alexey Dobriyan wrote:
> > > sysfs_emit() is most often found in functions returning ssize_t
> > > not int:
> > > 
> > > 	static ssize_t oops_count_show(...)
> > > 	{
> > > 		return sysfs_emit(page, ...);
> > > 	}
> > > 
> > > This pattern results in sign-extension instruction between
> > > sysfs_emit() return value (int) and caller return value (which is
> > > ssize_t).
> > 
> > Is that a problem?
> 
> Small problem, but, yes.
> 
> If sysfs_emit() returns "int", then every user compiles to
> 
> 	call	sysfs_emit
> 	movsx	rax, eax
> 	ret
> 
> Given than sysfs_emit() is the official way to print in sysfs,
> there are lots of users and there will be more users in the future
> as it grows.
> 
> This trailing "movsx" instruction is duplicated every time.
> 
> If sysfs_emit() returns ssize_t then it is folded into sysfs_emit() and
> appears in the code _once_ saving bytes.
> 
> Ultimately, all this confusion and mismatches come from snprintf()
> accepting "size_t" but returning "int" (despite working on very large
> strings!) which sysfs_emit() copied.

True, then why not fix up the base function here, vscnprintf() and
vsnprintf() and then propagate the fixes outward?

thanks,

greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ