Re: [PATCH 03/11] fs: add new read_uptr and write_uptr file operations

From: Matthew Wilcox
Date: Wed Jun 24 2020 - 14:44:02 EST


On Wed, Jun 24, 2020 at 08:37:43PM +0200, Christoph Hellwig wrote:
> On Wed, Jun 24, 2020 at 07:59:05PM +0200, Christoph Hellwig wrote:
> > On Wed, Jun 24, 2020 at 06:56:44PM +0100, Matthew Wilcox wrote:
> > > /* don't even try if the size is too large */
> > > + error = -ENOMEM;
> > > if (count > KMALLOC_MAX_SIZE)
> > > - return -ENOMEM;
> > > + goto out;
> > > + kbuf = kzalloc(count, GFP_KERNEL);
> > > + if (!kbuf)
> > > + goto out;
> > >
> > > if (write) {
> > > + error = -EFAULT;
> > > + if (!copy_from_iter_full(kbuf, count, iter))
> > > goto out;
> > > }
> >
> > The nul-termination for the write cases seems to be lost here.
>
> Version with the count and termination fixed below. Can I get your
> signoff? If testing passes that means I can go back to my
> kernel_read/write version from the set_fs removal tree with it.

Sure!

Signed-off-by: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>

I went with some slightly different fixes, but I'm having trouble
sending email (the new infradead.org is not quite set up right yet).
I've attached the two fixes to this email in case you want to
incorporate them in some way.