Commit 7efbccca authored by Miklos Szeredi's avatar Miklos Szeredi Committed by Kleber Sacilotto de Souza

fuse: Fix oops at process_init_reply()

BugLink: https://bugs.launchpad.net/bugs/1792392

commit e8f3bd77 upstream.

syzbot is hitting NULL pointer dereference at process_init_reply().
This is because deactivate_locked_super() is called before response for
initial request is processed.

Fix this by aborting and waiting for all requests (including FUSE_INIT)
before resetting fc->sb.

Original patch by Tetsuo Handa <penguin-kernel@I-love.SKAURA.ne.jp>.
Reported-by: default avatarsyzbot <syzbot+b62f08f4d5857755e3bc@syzkaller.appspotmail.com>
Fixes: e27c9d38 ("fuse: fuse: add time_gran to INIT_OUT")
Cc: <stable@vger.kernel.org> # v3.19
Signed-off-by: default avatarMiklos Szeredi <mszeredi@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c4d67ef8
...@@ -384,11 +384,6 @@ static void fuse_put_super(struct super_block *sb) ...@@ -384,11 +384,6 @@ static void fuse_put_super(struct super_block *sb)
{ {
struct fuse_conn *fc = get_fuse_conn_super(sb); struct fuse_conn *fc = get_fuse_conn_super(sb);
fuse_send_destroy(fc);
fuse_abort_conn(fc);
fuse_wait_aborted(fc);
mutex_lock(&fuse_mutex); mutex_lock(&fuse_mutex);
list_del(&fc->entry); list_del(&fc->entry);
fuse_ctl_remove_conn(fc); fuse_ctl_remove_conn(fc);
...@@ -1193,16 +1188,25 @@ static struct dentry *fuse_mount(struct file_system_type *fs_type, ...@@ -1193,16 +1188,25 @@ static struct dentry *fuse_mount(struct file_system_type *fs_type,
return mount_nodev(fs_type, flags, raw_data, fuse_fill_super); return mount_nodev(fs_type, flags, raw_data, fuse_fill_super);
} }
static void fuse_kill_sb_anon(struct super_block *sb) static void fuse_sb_destroy(struct super_block *sb)
{ {
struct fuse_conn *fc = get_fuse_conn_super(sb); struct fuse_conn *fc = get_fuse_conn_super(sb);
if (fc) { if (fc) {
fuse_send_destroy(fc);
fuse_abort_conn(fc);
fuse_wait_aborted(fc);
down_write(&fc->killsb); down_write(&fc->killsb);
fc->sb = NULL; fc->sb = NULL;
up_write(&fc->killsb); up_write(&fc->killsb);
} }
}
static void fuse_kill_sb_anon(struct super_block *sb)
{
fuse_sb_destroy(sb);
kill_anon_super(sb); kill_anon_super(sb);
} }
...@@ -1225,14 +1229,7 @@ static struct dentry *fuse_mount_blk(struct file_system_type *fs_type, ...@@ -1225,14 +1229,7 @@ static struct dentry *fuse_mount_blk(struct file_system_type *fs_type,
static void fuse_kill_sb_blk(struct super_block *sb) static void fuse_kill_sb_blk(struct super_block *sb)
{ {
struct fuse_conn *fc = get_fuse_conn_super(sb); fuse_sb_destroy(sb);
if (fc) {
down_write(&fc->killsb);
fc->sb = NULL;
up_write(&fc->killsb);
}
kill_block_super(sb); kill_block_super(sb);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment