Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp754498imm; Thu, 13 Sep 2018 07:16:33 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda1S8YAGJziY6y2by2Ps1cS7FbcH4Ptd7a4Uqu7ib8pcrJee+AIFIAsZqOojKDIzJq7SYh/ X-Received: by 2002:a17:902:b282:: with SMTP id u2-v6mr7357673plr.123.1536848193234; Thu, 13 Sep 2018 07:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536848193; cv=none; d=google.com; s=arc-20160816; b=GWku9N5QbiQ5mNDRBS7VkNsObCsAXnkjsP8z6XciuqKMcawrM6+Folg5FEcwWhNfq+ 6xfhX6pLJRx0GNbVehiSUCNZjlYdxKPSWrZAhq4NhN9Qt1VwDSgZmqEShWIgTqqbb86F sG9mWXHi81Zm6AiOtl7xINe9Lghh4Nl0jgSwZZQ3PznI/nd/6fTDq7nOfPYEGQGZ5qq4 YjOcJPWV0Bz59qY1EfE0nzQzukUqotFXl76jeFtiioo3D3nxtYZNGihypTI2kmge+YbK gNAOkcKILwSFqYt8wp0u0U5S0diEKtW02eZG6au8j/bvM6UlIM2gJ00wFFw+BQRM95Ug /E+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=al7e/fYvkFxHIF2Xpm1G8jxTWXFgk+XOp/U5ucU1A2c=; b=amFB417iswoPuygkzPis/Ddv4Ho8Vnys9YQSlmmAeI6mP2UWHbZR7w7IALZx1mgx9I 4uIoFzDTCsou+PVoudiFff2Enxl+s4cq9+FThpQDFYEHwlnqbLRKToHwvoK33BbicNFl U5VGc4R1NL/7O5L2h+9YS81iJvitQD6pEEigsZKsGM5+PdHoJWqCOHDQFE3IwatTS1Cw 15vNBImBv8iBgwy96l1UBoKODTI5iewaL9FdrfQhTooRa9f7s+uZ7Vy0jz/7l8t5XPeL 2uHKij8a49coAB1S16j/2kqg5R1vimvr/jI6YHihcbWoBiHwBSCGuG3lVhuSIVUeZ0fv O1yg== 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 24-v6si4280941pgx.314.2018.09.13.07.16.10; Thu, 13 Sep 2018 07:16:33 -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 S1730068AbeIMSyV (ORCPT + 99 others); Thu, 13 Sep 2018 14:54:21 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60612 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729398AbeIMSyV (ORCPT ); Thu, 13 Sep 2018 14:54:21 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id C6713D10; Thu, 13 Sep 2018 13:44:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , syzbot , "=?UTF-8?q?Ernesto=20A . =20Fern=C3=A1ndez?=" , Andrew Morton , Al Viro , Linus Torvalds , Sasha Levin Subject: [PATCH 4.14 022/115] hfsplus: dont return 0 when fill_super() failed Date: Thu, 13 Sep 2018 15:30:42 +0200 Message-Id: <20180913131824.955710544@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131823.327472833@linuxfoundation.org> References: <20180913131823.327472833@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tetsuo Handa [ Upstream commit 7464726cb5998846306ed0a7d6714afb2e37b25d ] syzbot is reporting NULL pointer dereference at mount_fs() [1]. This is because hfsplus_fill_super() is by error returning 0 when hfsplus_fill_super() detected invalid filesystem image, and mount_bdev() is returning NULL because dget(s->s_root) == NULL if s->s_root == NULL, and mount_fs() is accessing root->d_sb because IS_ERR(root) == false if root == NULL. Fix this by returning -EINVAL when hfsplus_fill_super() detected invalid filesystem image. [1] https://syzkaller.appspot.com/bug?id=21acb6850cecbc960c927229e597158cf35f33d0 Link: http://lkml.kernel.org/r/d83ce31a-874c-dd5b-f790-41405983a5be@I-love.SAKURA.ne.jp Signed-off-by: Tetsuo Handa Reported-by: syzbot Reviewed-by: Ernesto A. Fernández Reviewed-by: Andrew Morton Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/hfsplus/super.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/fs/hfsplus/super.c +++ b/fs/hfsplus/super.c @@ -524,8 +524,10 @@ static int hfsplus_fill_super(struct sup goto out_put_root; if (!hfs_brec_read(&fd, &entry, sizeof(entry))) { hfs_find_exit(&fd); - if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) + if (entry.type != cpu_to_be16(HFSPLUS_FOLDER)) { + err = -EINVAL; goto out_put_root; + } inode = hfsplus_iget(sb, be32_to_cpu(entry.folder.id)); if (IS_ERR(inode)) { err = PTR_ERR(inode);