Re: [PATCH 01/19] nfs/localio: fix nfsd_file ref leak on nfs_local_doio() init failure
From: Jeff Layton
Date: Wed Jun 10 2026 - 12:30:42 EST
On Wed, 2026-06-10 at 10:08 -0400, Chuck Lever wrote:
> On Tue, Jun 9, 2026, at 1:47 PM, Jeff Layton wrote:
> > Two early return paths in nfs_local_doio() fail to release the localio
> > (nfsd_file) reference passed in by the caller:
> >
> > - When hdr->args.count is zero, the function returns 0 without calling
> > nfs_local_file_put().
> >
> > - When nfs_local_iocb_init() fails (e.g. -ENOMEM from allocation or
> > -EOPNOTSUPP if the file lacks read_iter/write_iter), the function
> > returns the error without releasing localio or completing the hdr
> > lifecycle.
> >
> > A leaked nfsd_file pins the associated net namespace reference,
> > blocking network namespace teardown, and holds a reference on the
> > exported filesystem, preventing unmount.
> >
> > Fix the zero-count path by adding the missing nfs_local_file_put()
> > call. Fix the iocb init failure path by jumping to a new cleanup label
> > that releases localio, sets hdr->task.tk_status, and calls
> > nfs_local_hdr_release() -- matching the existing error handling pattern
> > for the post-iocb error path.
> >
> > Fixes: e77c464c31b3 ("nfs/nfsd: add "local io" support")
>
> I don't seem to have commit e77c464c31b3 in my tree. Should this be
>
> Fixes: 70ba381e1a43 ("nfs: add LOCALIO support")
>
> ?
>
Yeah, that introduced the first of the leaks, I think. I need to write
a "vet these Fixes: tags" skill for an LLM.
> > Assisted-by: Claude:claude-opus-4-8
> > Signed-off-by: Jeff Layton <jlayton@xxxxxxxxxx>
> > ---
> > fs/nfs/localio.c | 16 +++++++++++++---
> > 1 file changed, 13 insertions(+), 3 deletions(-)
>
> This updates only a client-side source file. Should it go through
> Anna/Trond's trees? Or were you thinking that, since the leak
> impacts only NFS server behavior, I should take it?
>
Oh, good point. I asked Claude to give me a list of nfsd bugs and it
included this one. I'm fine if Anna or Trond want to take this one.
--
Jeff Layton <jlayton@xxxxxxxxxx>