From patchwork Wed Jul 18 10:00:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10531975 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9273F600F4 for ; Wed, 18 Jul 2018 10:00:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 76D342900D for ; Wed, 18 Jul 2018 10:00:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B332290C2; Wed, 18 Jul 2018 10:00:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 01F832900D for ; Wed, 18 Jul 2018 10:00:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726954AbeGRKhc (ORCPT ); Wed, 18 Jul 2018 06:37:32 -0400 Received: from www262.sakura.ne.jp ([202.181.97.72]:21389 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726064AbeGRKhc (ORCPT ); Wed, 18 Jul 2018 06:37:32 -0400 Received: from fsav105.sakura.ne.jp (fsav105.sakura.ne.jp [27.133.134.232]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id w6IA0IrN030482; Wed, 18 Jul 2018 19:00:18 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav105.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp); Wed, 18 Jul 2018 19:00:18 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank126074194044.bbtec.net [126.74.194.44]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id w6IA0EOM030450 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 18 Jul 2018 19:00:18 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: Miklos Szeredi Cc: linux-fsdevel@vger.kernel.org, Tetsuo Handa , syzbot Subject: [PATCH] fuse: Fix oops at process_init_reply(). Date: Wed, 18 Jul 2018 19:00:12 +0900 Message-Id: <1531908012-3594-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Tetsuo Handa syzbot is hitting NULL pointer dereference at process_init_reply() [1]. This is because deactivate_locked_super() is called before response for initial request is processed. Fix this by protecting process_init_reply() using fc->killsb. [1] https://syzkaller.appspot.com/bug?id=d363046088dc26030e146e92102f965bf4623a50 Signed-off-by: Tetsuo Handa Reported-by: syzbot --- fs/fuse/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index a24df88..2c9495e 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c @@ -868,7 +868,8 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) { struct fuse_init_out *arg = &req->misc.init_out; - if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION) + down_read(&fc->killsb); + if (req->out.h.error || arg->major != FUSE_KERNEL_VERSION || !fc->sb) fc->conn_error = 1; else { unsigned long ra_pages; @@ -938,6 +939,7 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) } fuse_set_initialized(fc); wake_up_all(&fc->blocked_waitq); + up_read(&fc->killsb); } static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req)