Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp273099pxa; Wed, 12 Aug 2020 01:19:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgpEc1Hm7MYE2BLcIEZrRH4gUrcJm4NWjlBRf/76HmfLY/uYa2H6skUVPYTNOP7CTOvEOy X-Received: by 2002:a17:906:386:: with SMTP id b6mr29763843eja.538.1597220384417; Wed, 12 Aug 2020 01:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597220384; cv=none; d=google.com; s=arc-20160816; b=xlyqv4+MJEP6WTp8gZQZuzyLEkzUotwyK3/G2V3KzHPMO8fl7W/SCnc1UXLyEovmou SfF+tuhSU7/U3KPaLfU5C81WNxjHakzf1ae8Ggu7Ame72rANEcIu154NYHdW0AgXPd3d mK97IlJZCUOWPaAsuRz9JzzjnuDtgeczz32nA6tjMIsMtb8E0uixgjoR90W91M+TvOk2 O0Jmrli7HOj5hNH1QPgb6lH7/1PHLTOvHLcQIr6xzYRnETh44XLK/WncHE9PT2pcQ3Q4 qGZo/LdzvMxYThUYlxl74tkDaK47MwMtq75liFqr9PCKqKn+Kl7i4aMIgczrE64JuZIj 9fPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=bmYIMwgkrwppww0gL43UZNNDNdFldZmHQv0HfDHJPs0=; b=LbLI+527Br7275yrN44I26P4yeuN9eyYGO7WrqVbtb3w87RXO/qi6Bw2NpEqicQLmQ UxrJqX8H5dFKZykmTM94/BhxOpD4fwYiqhEl3R/q02mCFUlSN8TokBZQETkXthezxlvb Fvsy16v0hgbD1LsW9TGLu+ztr0Q/TI2x5xH+0O6ArgjDrVcmPtTka6TOe/+XByI82Gi9 8JWkN/8wnLN0fBqIm8EgDvVzI6Cc6wU2sLqxYkkVAqsDbBnNr5RP7rbfGG181EV9o6eF YQChESQ2huB7bhVoW5VqAbq34Sm2vvUbpX1KfTdEKBXYkXJ4O8/54u7GHe9d/QA+Las0 phjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aoTbN6qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ov32si815911ejb.218.2020.08.12.01.19.21; Wed, 12 Aug 2020 01:19:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aoTbN6qb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726826AbgHLISn (ORCPT + 99 others); Wed, 12 Aug 2020 04:18:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46100 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726712AbgHLISn (ORCPT ); Wed, 12 Aug 2020 04:18:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5255620774; Wed, 12 Aug 2020 08:18:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597220322; bh=DZe4rDhjzxljBRgO7VQ+ytJ53LFjK1MMm84lYaTTDBg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aoTbN6qbRHC8oLTWGWsg1IOq4qT55TJQzev+Ml+0+6WYL2d5Rr5res40LMxOW9Stk h6SlHs3E9bKMCM42TIdi3JvHICDxpR9+DIqlAw1cQrvA7JDwU6hA1GtOEVR1FymycK dmyF1wg1RL7LMKxfQKwABHqtuEwdM/q+lI94p+ww= Date: Wed, 12 Aug 2020 10:18:52 +0200 From: Greg Kroah-Hartman To: Peilin Ye Cc: linux-fsdevel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: [Linux-kernel-mentees] [PATCH] hfs, hfsplus: Fix NULL pointer dereference in hfs_find_init() Message-ID: <20200812081852.GA851575@kroah.com> References: <20200812065556.869508-1-yepeilin.cs@gmail.com> <20200812070827.GA1304640@kroah.com> <20200812071306.GA869606@PWN> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812071306.GA869606@PWN> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 12, 2020 at 03:13:06AM -0400, Peilin Ye wrote: > On Wed, Aug 12, 2020 at 09:08:27AM +0200, Greg Kroah-Hartman wrote: > > On Wed, Aug 12, 2020 at 02:55:56AM -0400, Peilin Ye wrote: > > > Prevent hfs_find_init() from dereferencing `tree` as NULL. > > > > > > Reported-and-tested-by: syzbot+7ca256d0da4af073b2e2@syzkaller.appspotmail.com > > > Signed-off-by: Peilin Ye > > > --- > > > fs/hfs/bfind.c | 3 +++ > > > fs/hfsplus/bfind.c | 3 +++ > > > 2 files changed, 6 insertions(+) > > > > > > diff --git a/fs/hfs/bfind.c b/fs/hfs/bfind.c > > > index 4af318fbda77..880b7ea2c0fc 100644 > > > --- a/fs/hfs/bfind.c > > > +++ b/fs/hfs/bfind.c > > > @@ -16,6 +16,9 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd) > > > { > > > void *ptr; > > > > > > + if (!tree) > > > + return -EINVAL; > > > + > > > fd->tree = tree; > > > fd->bnode = NULL; > > > ptr = kmalloc(tree->max_key_len * 2 + 4, GFP_KERNEL); > > > diff --git a/fs/hfsplus/bfind.c b/fs/hfsplus/bfind.c > > > index ca2ba8c9f82e..85bef3e44d7a 100644 > > > --- a/fs/hfsplus/bfind.c > > > +++ b/fs/hfsplus/bfind.c > > > @@ -16,6 +16,9 @@ int hfs_find_init(struct hfs_btree *tree, struct hfs_find_data *fd) > > > { > > > void *ptr; > > > > > > + if (!tree) > > > + return -EINVAL; > > > + > > > > How can tree ever be NULL in these calls? Shouldn't that be fixed as > > the root problem here? > > I see, I will try to figure out what is going on with the reproducer. That's good to figure out. Note, your patch might be the correct thing to do, as that might be an allowed way to call the function. But in looking at all the callers, they seem to think they have a valid pointer at the moment, so perhaps if this check is added, some other root problem is papered over to be only found later on? thanks, greg k-h