Re: [PATCH -next] mm: Use sysfs_emit functions not sprintf

From: Jason Gunthorpe
Date: Wed Oct 07 2020 - 14:57:11 EST


On Wed, Oct 07, 2020 at 11:04:42AM -0700, Joe Perches wrote:
> On Wed, 2020-10-07 at 09:53 -0300, Jason Gunthorpe wrote:
> > On Wed, Oct 07, 2020 at 12:16:01AM -0700, Kees Cook wrote:
> > > On Tue, Oct 06, 2020 at 09:28:17AM -0700, Joe Perches wrote:
> > > > Convert the various uses of sprintf/snprintf/scnprintf to
> > > > format sysfs output to sysfs_emit and sysfs_emit_at to make
> > > > clear the output is sysfs related and to avoid any possible
> > > > buffer overrun of the PAGE_SIZE buffer.
> > > >
> > > > Done with cocci scripts and some typing.
> > >
> > > Can you include the cocci script in the commit log? It might be nicer to
> > > split the "manual" changes from the cocci changes, as that makes review
> > > much easier too.
> > >
> > > Regardless, yes, I'm a fan of switching these all around to
> > > sysfs_emit*(). :)
> >
> > Yah, +1, I'd welcome patches for drivers/infiniband as well next cycle
>
> The script to change <foo>_show(struct device *, ...)
> function uses of
> sprintf to sysfs_emit is attached.

> $ git diff --shortstat drivers/infiniband
> 25 files changed, 322 insertions(+), 303 deletions(-)
>
> Because it touches a lot of drivers, the 'cc' list is
> pretty large for the diff.
>
> Given the size of the cc list, unless there's a single
> acceptable patch, I will not submit individual patches as
> I really dislike the back and forth of this sub-maintainer
> will but this sub-maintainer will not apply a patch.

This size looks not too bad, we regularly do all driver updates. Up to
you if you want split per driver. In rdma land something like this
will go ahead unless someone points to technical errors in the
conversion.

Thanks,
Jason