[PATCH] uacce: use sysfs_emit instead of sprintf

Greg KH gregkh at linuxfoundation.org
Mon May 17 21:56:35 AEST 2021


On Mon, May 17, 2021 at 07:49:37PM +0800, yekai(A) wrote:
> 
> 
> On 2021/5/17 18:36, Greg KH wrote:
> > On Mon, May 17, 2021 at 06:25:37PM +0800, Kai Ye wrote:
> > > Use the sysfs_emit to replace sprintf.
> > 
> > That says _what_ you did, not _why_ you are doing this.  What problem
> > are you solving with this change?
> > 
> > thanks,
> > 
> > greg k-h
> > .
> > 
> sprintf is not safe, and it not recommended to use.

Why not?  What is "unsafe" with it in this function?

> sprintf does not know the PAGE_SIZE maximum of the temporary buffer
> used for outputting sysfs content and it's possible to overrun the
> PAGE_SIZE buffer length. so used sysfs_emit that  knows that the size
> of the call situations that also ensures that no overrun is done. so use
> sysfs_emit to replace sprintf maybe better.

But that's not a problem at all for these calls, right?  If so, please
show me how that could ever happen.

thanks,

greg k-h


More information about the Linux-accelerators mailing list