Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp728132imm; Thu, 13 Sep 2018 06:55:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZpO2nDEv4v4s6RwllZWD+uw3kQtseJ9/9PQmq+3pSywE1aBFufPL3ACVcc6WkEhZzzyekd X-Received: by 2002:a63:9841:: with SMTP id l1-v6mr7127547pgo.228.1536846949137; Thu, 13 Sep 2018 06:55:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846949; cv=none; d=google.com; s=arc-20160816; b=ufvseHGKKw9SIL0aiUt4FOVMImqKvKWBRPeECVoSrhheX/QCd39jVKzFJ0hV6bwjV4 HsrR1Qjtm4LGMKFkhwTXQkRGX+hxgApfLgAv2aWRYHXtx4A+f7fsuDpD9rCCjSQlLHnd /nLwQjdOctsiQx1h5DJ2R1qogbbIs6jSQ//rYhqQrbF1oa3WB86lYjdZ20kQeVuqTsK5 SZDOogVVOjJFSJRTgPpjUHzRdGynecjdVLWuhetzIYmL01QudYX1PK87iFMRTGhUUu8R Dfm7PM7VTdDJSTsSn88sHMRo8F9GWqZyLAfOYhNO1urug4qXTHoStr+Rk5Jw9y1tbeUj SXUg== 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=gQVswNJ8x0Gr5O8wKS+BR9b3rW11s6xyjl0JT4KIgCo=; b=ZEl1ujj23SQrVseT1L9ODYiq2AQX/cYg2IAaM0Ss5CrP2S+8BIRE0ndIXg3K+rAllp eqyR1YHBOedNPw+IuTf4T5nKapArjAtqt+8Sh861DhzJewX8ysgP5Uf6mWw6y2jpUqLX rldSdAFao40YkogpYIkEWUor9iGOH7y2A3LcbCSnE8mzp8EW0/T6DqHk3dpUAarqpm/6 CqyVXk0DZLG97ofMgwr802tZ243HOWY/qxPeebTJ2f2IN9DcECUpwj4iFU6vHYK9US+n TCK8NdtSzUVDLS6FLYS5pfzDe1oaephWtjMqSz8SheUBjUOIrQafQnH3K1ytG/B+teoZ PJ+Q== 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 y193-v6si4003827pgd.512.2018.09.13.06.55.33; Thu, 13 Sep 2018 06:55:49 -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 S1731163AbeIMTFC (ORCPT + 99 others); Thu, 13 Sep 2018 15:05:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33978 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727783AbeIMTFB (ORCPT ); Thu, 13 Sep 2018 15:05:01 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 65D65D10; Thu, 13 Sep 2018 13:55:25 +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.18 038/197] hfsplus: dont return 0 when fill_super() failed Date: Thu, 13 Sep 2018 15:29:47 +0200 Message-Id: <20180913131843.077619787@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@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.18-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);