lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20171121140500.bgkpwcdk2dxesao4@dhcp22.suse.cz>
Date:   Tue, 21 Nov 2017 15:05:00 +0100
From:   Michal Hocko <mhocko@...nel.org>
To:     Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
Cc:     syzbot 
        <bot+065a25551da6c9ab4283b7ae889c707a37ab2de3@...kaller.appspotmail.com>,
        akpm@...ux-foundation.org, hannes@...xchg.org,
        hillf.zj@...baba-inc.com, linux-kernel@...r.kernel.org,
        linux-mm@...ck.org, mgorman@...hsingularity.net,
        minchan@...nel.org, shli@...com, syzkaller-bugs@...glegroups.com,
        ying.huang@...el.com, Al Viro <viro@...iv.linux.org.uk>,
        Dave Chinner <david@...morbit.com>
Subject: Re: general protection fault in __list_del_entry_valid (2)

[Cc Al and Dave - email thread starts http://lkml.kernel.org/r/001a113f996099503a055e793dd3@google.com]

On Tue 21-11-17 20:11:26, Tetsuo Handa wrote:
> On 2017/11/21 16:35, syzbot wrote:
> > Hello,
> > 
> > syzkaller hit the following crash on ca91659962303d4fd5211a5e4e13df5cbb11e744
> > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master
> > compiler: gcc (GCC) 7.1.1 20170620
> > .config is attached
> > Raw console output is attached.
> > 
> > Unfortunately, I don't have any reproducer for this bug yet.
> 
> Fault injection found an unchecked register_shrinker() return code.
> Wow, register_shrinker()/unregister_shinker() is possibly frequently called path?
> 
> 
> struct super_block *sget_userns(struct file_system_type *type,
> 				int (*test)(struct super_block *,void *),
> 				int (*set)(struct super_block *,void *),
> 				int flags, struct user_namespace *user_ns,
> 				void *data)
> {
> (...snipped...)
> 	spin_unlock(&sb_lock);
> 	get_filesystem(type);
> 	register_shrinker(&s->s_shrink); // Error check required.
> 	return s;

Yes, this is the case since numa aware shrinkers were introduced. I have
a bit hard time to follow the code flow but why cannot we simply
register the shrinker when we allocate the new super block? We
still have the s_umount held so the shrinker cannot race with the
registration code.

Something like the totally untested and possibly wrong
---
diff --git a/fs/super.c b/fs/super.c
index 994db21f59bf..1eb850413fdf 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -506,6 +506,11 @@ struct super_block *sget_userns(struct file_system_type *type,
 		s = alloc_super(type, (flags & ~SB_SUBMOUNT), user_ns);
 		if (!s)
 			return ERR_PTR(-ENOMEM);
+		if (register_shrinker(&s->s_shrink)) {
+			up_write(&s->s_umount);
+			destroy_super(s);
+			return ERR_PTR(-ENOMEM);
+		}
 		goto retry;
 	}
 
@@ -522,7 +527,6 @@ 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);
 	return s;
 }
 
-- 
Michal Hocko
SUSE Labs

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ