Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1833817imm; Mon, 3 Sep 2018 10:37:13 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY3+yK0x8RGmA46kmnx4d/HfvKPdvQyefa6GURKU8TBRQ5xhW54rdxiuNUpp6fqHLCHN0lK X-Received: by 2002:a62:198e:: with SMTP id 136-v6mr30665102pfz.103.1535996233796; Mon, 03 Sep 2018 10:37:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535996233; cv=none; d=google.com; s=arc-20160816; b=h3RJ10F0svEukqvclN8vjG1WG3v289J58/NMRJKXNePiIsESO7Wtr8DL+JxcEsd5Sk T0Tkx/dOCdSdULNrPIFzzpulGkRu9nPL82YQhTCjnpQxXsKx0+WIrOPOx+XzWz1cYi/W v8G8Sn2ZUItpK6oVA4doZxpBSEeSaeUXYPpxEePRcpSBLs3+OQ1G2yisThu1mI143cO7 VplfoBTv56hDcHNNOobjjll0Iu/K7ygY9TEXwrHBhrPjuyDErsbDPRil4OAvFvVtlDPH EzcVH3V8dfsf2mQ3VrtnGNqp7u5WL4SatM+L59alv/Id5odSgbGkyt2xkgvU8dB6FFZj rRzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=4yX4BHYGvihlIWeVPVcmUpImyQ3EDSeIvqHculygBi4=; b=Oy3BEh/jtOpbs5E13LKCx7ao7NM1HwWGX9E8TKA3f4s39C3TzOcV0IgzrMklbv7GEQ 4YscAqnTGsBqELtK8v45FkdCLNOeMhV/gTrGF23mGFHtuM6IgnCoyHQtKgh80IoSc5dj BPt38ZwzQALYterMvAqMI1lHlZzZWVOkF2aWzhCKa3PVF4/lCEJ3oeS8y9K1/aUiGzRR ortY622S0PpxsRmoaHgpimKjiz9j6x5RsmIlL0IQ7nzeXscg167a13N955Bc0RDOTEmT zUGTtwGKZa1XyhQV+aOv3dq88H1Pkf+9ZRExrOpi4E+f1dn00p2b7aj8qRjpajCKJJYz JQnQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3-v6si18350024pll.395.2018.09.03.10.36.58; Mon, 03 Sep 2018 10:37:13 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731533AbeICV4n (ORCPT + 99 others); Mon, 3 Sep 2018 17:56:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48010 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727972AbeICV4m (ORCPT ); Mon, 3 Sep 2018 17:56:42 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 67E99D1B; Mon, 3 Sep 2018 17:35:32 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Miklos Szeredi Subject: [PATCH 4.18 063/123] fuse: Fix oops at process_init_reply() Date: Mon, 3 Sep 2018 18:56:47 +0200 Message-Id: <20180903165722.106235307@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180903165719.499675257@linuxfoundation.org> References: <20180903165719.499675257@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Miklos Szeredi commit e8f3bd773d22f488724dffb886a1618da85c2966 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 . Reported-by: syzbot Fixes: e27c9d3877a0 ("fuse: fuse: add time_gran to INIT_OUT") Cc: # v3.19 Signed-off-by: Miklos Szeredi Signed-off-by: Greg Kroah-Hartman --- fs/fuse/inode.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -397,11 +397,6 @@ static void fuse_put_super(struct super_ { struct fuse_conn *fc = get_fuse_conn_super(sb); - fuse_send_destroy(fc); - - fuse_abort_conn(fc, false); - fuse_wait_aborted(fc); - mutex_lock(&fuse_mutex); list_del(&fc->entry); fuse_ctl_remove_conn(fc); @@ -1218,16 +1213,25 @@ static struct dentry *fuse_mount(struct 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); if (fc) { + fuse_send_destroy(fc); + + fuse_abort_conn(fc, false); + fuse_wait_aborted(fc); + down_write(&fc->killsb); fc->sb = NULL; up_write(&fc->killsb); } +} +static void fuse_kill_sb_anon(struct super_block *sb) +{ + fuse_sb_destroy(sb); kill_anon_super(sb); } @@ -1250,14 +1254,7 @@ static struct dentry *fuse_mount_blk(str static void fuse_kill_sb_blk(struct super_block *sb) { - struct fuse_conn *fc = get_fuse_conn_super(sb); - - if (fc) { - down_write(&fc->killsb); - fc->sb = NULL; - up_write(&fc->killsb); - } - + fuse_sb_destroy(sb); kill_block_super(sb); }