From: Andreas Gruenbacher <agruenba@redhat.com>
To: Trond Myklebust <trondmy@hammerspace.com>,
"akpm@osdl.org" <akpm@osdl.org>,
"xiyuyang19@fudan.edu.cn" <xiyuyang19@fudan.edu.cn>,
"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: Andreas Gruenbacher <agruenba@redhat.com>,
"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 14:51:41 +0200 [thread overview]
Message-ID: <20200420125141.18002-1-agruenba@redhat.com> (raw)
In-Reply-To: <7b95f2ac1e65635dcb160ca20e798d95b7503e49.camel@hammerspace.com>
Am Mo., 20. Apr. 2020 um 14:15 Uhr schrieb Trond Myklebust <trondmy@hammerspace.com>:
> I don't really see any alternative to adding a 'dfalloc' to track the
> allocated dfacl separately.
Something like the attached patch should work as well.
Thanks,
Andreas
---
fs/nfs/nfs3acl.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index c5c3fc6e6c60..f1581f11c220 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -253,37 +253,41 @@ int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
int nfs3_set_acl(struct inode *inode, struct posix_acl *acl, int type)
{
- struct posix_acl *alloc = NULL, *dfacl = NULL;
+ struct posix_acl *orig = acl, *dfacl = NULL;
int status;
if (S_ISDIR(inode->i_mode)) {
switch(type) {
case ACL_TYPE_ACCESS:
- alloc = dfacl = get_acl(inode, ACL_TYPE_DEFAULT);
- if (IS_ERR(alloc))
- goto fail;
+ dfacl = get_acl(inode, ACL_TYPE_DEFAULT);
+ status = PTR_ERR(dfacl);
+ if (IS_ERR(dfacl))
+ goto out;
break;
case ACL_TYPE_DEFAULT:
dfacl = acl;
- alloc = acl = get_acl(inode, ACL_TYPE_ACCESS);
- if (IS_ERR(alloc))
- goto fail;
+ acl = get_acl(inode, ACL_TYPE_ACCESS);
+ status = PTR_ERR(acl);
+ if (IS_ERR(acl))
+ goto out;
break;
}
}
if (acl == NULL) {
- alloc = acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
- if (IS_ERR(alloc))
- goto fail;
+ acl = posix_acl_from_mode(inode->i_mode, GFP_KERNEL);
+ status = PTR_ERR(acl);
+ if (IS_ERR(acl))
+ goto out;
}
status = __nfs3_proc_setacls(inode, acl, dfacl);
- posix_acl_release(alloc);
+out:
+ if (acl != orig)
+ posix_acl_release(acl);
+ if (dfacl != orig)
+ posix_acl_release(dfacl);
return status;
-
-fail:
- return PTR_ERR(alloc);
}
const struct xattr_handler *nfs3_xattr_handlers[] = {
base-commit: ae83d0b416db002fe95601e7f97f64b59514d936
--
2.25.3
next prev parent reply other threads:[~2020-04-20 12:51 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
2020-04-20 12:51 ` Andreas Gruenbacher [this message]
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=20200420125141.18002-1-agruenba@redhat.com \
--to=agruenba@redhat.com \
--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=trondmy@hammerspace.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®