From: Goldwyn Rodrigues <rgoldwyn@suse.de>
To: Nikolay Borisov <nborisov@suse.com>, dvyukov@google.com
Cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, syzkaller@googlegroups.com
Subject: Re: [PATCH] fs: Handle register_shrinker failure
Date: Thu, 6 Apr 2017 14:21:29 -0500 [thread overview]
Message-ID: <8e6dad6a-1b0d-bec4-9104-1d572bed9bd8@suse.de> (raw)
In-Reply-To: <1490342140-19138-1-git-send-email-nborisov@suse.com>
On 03/24/2017 02:55 AM, Nikolay Borisov wrote:
> register_shrinker allocates dynamic memory and thus is susceptible to failures
> under low-memory situation. Currently,get_userns ignores the return value of
> register_shrinker, potentially exposing not fully initialised object. This
> can lead to a NULL-ptr deref everytime shrinker->nr_deferred is referenced.
>
> Fix this by failing to register the filesystem in case there is not enough
> memory to fully construct the shrinker object.
>
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Looks good, though the situation seems rare.
Reviewed-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
> ---
> fs/super.c | 14 +++++++++++++-
> 1 file changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/fs/super.c b/fs/super.c
> index b8b6a086c03b..964b18447c92 100644
> --- a/fs/super.c
> +++ b/fs/super.c
> @@ -518,7 +518,19 @@ struct super_block *sget_userns(struct file_system_type *type,
> hlist_add_head(&s->s_instances, &type->fs_supers);
> spin_unlock(&sb_lock);
> get_filesystem(type);
> - register_shrinker(&s->s_shrink);
> + err = register_shrinker(&s->s_shrink);
> + if (err) {
> + spin_lock(&sb_lock);
> + list_del(&s->s_list);
> + hlist_del(&s->s_instances);
> + spin_unlock(&sb_lock);
> +
> + up_write(&s->s_umount);
> + destroy_super(s);
> + put_filesystem(type);
> + return ERR_PTR(err);
> + }
> +
> return s;
> }
>
>
--
Goldwyn
next prev parent reply other threads:[~2017-04-06 19:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-24 7:55 Nikolay Borisov
2017-04-06 19:21 ` Goldwyn Rodrigues [this message]
2017-04-28 4:30 ` Al Viro
2017-04-28 5:34 ` Al Viro
-- strict thread matches above, loose matches on Subject: below --
2017-03-23 14:14 fs: GPF in deactivate_locked_super Dmitry Vyukov
2017-03-24 7:57 ` [PATCH] fs: Handle register_shrinker failure Nikolay Borisov
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=8e6dad6a-1b0d-bec4-9104-1d572bed9bd8@suse.de \
--to=rgoldwyn@suse.de \
--cc=dvyukov@google.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=syzkaller@googlegroups.com \
--cc=viro@zeniv.linux.org.uk \
/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®