From: Trond Myklebust <trondmy@hammerspace.com>
To: "akpm@osdl.org" <akpm@osdl.org>,
"xiyuyang19@fudan.edu.cn" <xiyuyang19@fudan.edu.cn>,
"agruen@suse.de" <agruen@suse.de>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"anna.schumaker@netapp.com" <anna.schumaker@netapp.com>,
"okir@suse.de" <okir@suse.de>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Cc: "tanxin.ctf@gmail.com" <tanxin.ctf@gmail.com>,
"yuanxzhang@fudan.edu.cn" <yuanxzhang@fudan.edu.cn>,
"kjlu@umn.edu" <kjlu@umn.edu>
Subject: Re: [PATCH] nfs: Fix potential posix_acl refcnt leak in nfs3_set_acl
Date: Mon, 20 Apr 2020 12:14:07 +0000 [thread overview]
Message-ID: <7b95f2ac1e65635dcb160ca20e798d95b7503e49.camel@hammerspace.com> (raw)
In-Reply-To: <1587361410-83560-1-git-send-email-xiyuyang19@fudan.edu.cn>
On Mon, 2020-04-20 at 13:43 +0800, Xiyu Yang wrote:
> nfs3_set_acl() invokes get_acl(), which returns a local reference of
> the
> posix_acl object to "alloc" with increased refcount.
>
> When nfs3_set_acl() returns or a new object is assigned to
> "alloc", the
> original local reference of "alloc" becomes invalid, so the refcount
> should be decreased to keep refcount balanced.
>
> The reference counting issue happens in one path of nfs3_set_acl().
> When
> "acl" equals to NULL but "alloc" is not NULL, the function forgets to
> decrease the refcnt increased by get_acl() and causes a refcnt leak.
>
> Fix this issue by calling posix_acl_release() on this path when
> "alloc"
> is not NULL.
>
> Fixes: b7fa0554cf1b ("[PATCH] NFS: Add support for NFSv3 ACLs")
> Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
> Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
> ---
> fs/nfs/nfs3acl.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
> index c5c3fc6e6c60..b5c41bcca8cf 100644
> --- a/fs/nfs/nfs3acl.c
> +++ b/fs/nfs/nfs3acl.c
> @@ -274,6 +274,8 @@ int nfs3_set_acl(struct inode *inode, struct
> posix_acl *acl, int type)
> }
>
> if (acl == NULL) {
> + if (alloc)
> + posix_acl_release(alloc);
This will result in 'dfacl' being freed while it is still in use, so
can't be correct either.
> alloc = acl = posix_acl_from_mode(inode->i_mode,
> GFP_KERNEL);
> if (IS_ERR(alloc))
> goto fail;
I don't really see any alternative to adding a 'dfalloc' to track the
allocated dfacl separately.
--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
trond.myklebust@hammerspace.com
next prev parent reply other threads:[~2020-04-20 12:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-20 5:43 Xiyu Yang
2020-04-20 12:14 ` Trond Myklebust [this message]
2020-04-20 12:51 ` Andreas Gruenbacher
2020-04-20 12:59 ` Trond Myklebust
2020-04-20 13:04 ` Andreas Gruenbacher
2020-04-20 13:13 ` Trond Myklebust
2020-04-20 13:51 Andreas Gruenbacher
2020-04-20 14:13 ` Trond Myklebust
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7b95f2ac1e65635dcb160ca20e798d95b7503e49.camel@hammerspace.com \
--to=trondmy@hammerspace.com \
--cc=agruen@suse.de \
--cc=akpm@osdl.org \
--cc=anna.schumaker@netapp.com \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=okir@suse.de \
--cc=tanxin.ctf@gmail.com \
--cc=xiyuyang19@fudan.edu.cn \
--cc=yuanxzhang@fudan.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®