From: Gao Xiang <gaoxiang25@huawei.com>
To: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Cc: <viro@zeniv.linux.org.uk>, <linux-fsdevel@vger.kernel.org>
Subject: Re: [PATCH v2] posix_acl: fix memleak when set posix acl.
Date: Tue, 26 Nov 2019 22:01:38 +0800 [thread overview]
Message-ID: <20191126140138.GA228491@architecture4> (raw)
In-Reply-To: <20191126133809.2082-1-zhangxiaoxu5@huawei.com>
Hi Xiaoxu,
On Tue, Nov 26, 2019 at 09:38:09PM +0800, Zhang Xiaoxu wrote:
> When set posix acl, it maybe call posix_acl_update_mode in some
> filesystem, eg. ext4. It may set acl to NULL, so, we can't free
> the acl which allocated in posix_acl_xattr_set.
>
> Use an temp value to store the acl address for posix_acl_release.
>
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
> ---
> fs/posix_acl.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index 84ad1c90d535..0a359d06274c 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -882,7 +882,7 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
> const char *name, const void *value,
> size_t size, int flags)
> {
> - struct posix_acl *acl = NULL;
> + struct posix_acl *acl = NULL, *p = NULL;
> int ret;
>
> if (value) {
> @@ -890,8 +890,15 @@ posix_acl_xattr_set(const struct xattr_handler *handler,
> if (IS_ERR(acl))
> return PTR_ERR(acl);
> }
> +
> + /*
> + * when call set_posix_acl, posix_acl_update_mode may set acl
> + * to NULL,use temporary variables p for posix_acl_release.
> + */
> + p = acl;
> ret = set_posix_acl(inode, handler->flags, acl);
IMO, variable acl in this function won't be affected, yes?
Am I missing something?
Thanks,
Gao Xiang
> - posix_acl_release(acl);
> +
> + posix_acl_release(p);
> return ret;
> }
>
> --
> 2.17.2
>
next prev parent reply other threads:[~2019-11-26 13:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 13:38 [PATCH v2] posix_acl: fix memleak when set posix acl Zhang Xiaoxu
2019-11-26 14:01 ` Gao Xiang [this message]
2019-11-26 14:20 ` zhangxiaoxu (A)
2019-12-08 19:44 ` Al Viro
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=20191126140138.GA228491@architecture4 \
--to=gaoxiang25@huawei.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zhangxiaoxu5@huawei.com \
/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;
as well as URLs for NNTP newsgroup(s).