Please pull the proc-linus branch from the git tree:

   git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace.git 
proc-linus

   HEAD: 058f2e4da79b23afb56ce3d03d907d6cdd36f2b8 proc: s_fs_info may be NULL 
when proc_kill_sb is called

Syzbot found a NULL pointer dereference if kzalloc of proc's s_fs_info fails.
The fix is the patch below.

---

From: Alexey Gladkov <[email protected]>
Date: Wed, 10 Jun 2020 20:35:49 +0200
Subject: [PATCH] proc: s_fs_info may be NULL when proc_kill_sb is called

syzbot found that proc_fill_super() fails before filling up sb->s_fs_info,
deactivate_locked_super() will be called and sb->s_fs_info will be NULL.
The proc_kill_sb() does not expect fs_info to be NULL which is wrong.

Link: https://lore.kernel.org/lkml/[email protected]
Reported-by: [email protected]
Fixes: fa10fed30f25 ("proc: allow to mount many instances of proc in one pid 
namespace")
Signed-off-by: Alexey Gladkov <[email protected]>
Signed-off-by: Eric W. Biederman <[email protected]>
---
 fs/proc/root.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/proc/root.c b/fs/proc/root.c
index ffebed1999e5..5e444d4f9717 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -264,11 +264,13 @@ static void proc_kill_sb(struct super_block *sb)
 {
        struct proc_fs_info *fs_info = proc_sb_info(sb);
 
-       if (fs_info->proc_self)
-               dput(fs_info->proc_self);
+       if (!fs_info) {
+               kill_anon_super(sb);
+               return;
+       }
 
-       if (fs_info->proc_thread_self)
-               dput(fs_info->proc_thread_self);
+       dput(fs_info->proc_self);
+       dput(fs_info->proc_thread_self);
 
        kill_anon_super(sb);
        put_pid_ns(fs_info->pid_ns);
-- 
2.20.1

Reply via email to