Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp240492pxa; Wed, 12 Aug 2020 00:09:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+zfsz6A0w8yGENikxjODguxgMlwWXAFeegm1c2rjjAzvKo1aENlpD74trvEfGrTnS65NJ X-Received: by 2002:a17:906:ff05:: with SMTP id zn5mr28905848ejb.64.1597216177693; Wed, 12 Aug 2020 00:09:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597216177; cv=none; d=google.com; s=arc-20160816; b=X7RMRofmoGr826OlfmiVJTuMzHSlSoV8ZU/Uk2oTnH4iqHjMQEWGA3RNh7zJ6kW+fs PXsC/5d4c9lGyiep+HaOutszAPvQz94DPf9uGrezJxnemaG7MeizQZLcQa8IfVDsaVay RpOTCLj7xyl8lrBBSvRPc4GlxXVwDTpLZIsZO99xzSlvPb1KpqRI0nFeK41CVXaoSTzj oHMJyOMFgxcGHseS+MLTXxyUHvP3Of1PIrET2CMhgE0raaaJLRgGy62f4KKoQzMzFqfy yKf8dC9z3eeGkLjhPuOnHRNE2AAUJN6FVAuMHx8I8Ly1DGN8LZrTUah6Vtv1Xg2HGJrP xVHA== 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=r3/TeOBdWS3GG7uh3Vm2ptQ93GMvV/eXWGHdK1BOQmE=; b=XBUNIPoF/9KfojuIr+fm2zqDTC7A+R1t/+CSbxuiyskGmqoX3p/DobfURDVXY91Bft j434m7TCkbIbWA3mWz11ISOrFOj1G2vrtIz+rYXys+D2eItS/NfGlP3ZLX/h0r4CvVy0 o5x91PNoqt62rZ7zd+xPeuEqXaiM4qHBMtSHE9a+ub8QPlkxtVb00lahI6YsGMiYwlYD Ueu1KbnoMj+bjNt0Ta9fKjlKyiEdY3XYXYCFG7WQuKMSjjjen56cvjdyWxFXCFAZvoE2 WFyHk6F8c6XnvPBsdmNSOvHf/RnORhIIX3yFBYh0RWZVpdPihdu5EkToilSCuLdxJKu8 Sqeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=db1n1k9z; 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 ss14si615225ejb.651.2020.08.12.00.09.14; Wed, 12 Aug 2020 00:09:37 -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=db1n1k9z; 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 S1726718AbgHLHIa (ORCPT + 99 others); Wed, 12 Aug 2020 03:08:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:41468 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725845AbgHLHIa (ORCPT ); Wed, 12 Aug 2020 03:08:30 -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 A96662053B; Wed, 12 Aug 2020 07:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597216110; bh=iscE9GItSI35Y8APIrUEV6sr2YREeGnyX+/eG4Y/b0Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=db1n1k9zj+UKi6t4tEK382BilUYHjepA61MeoqswndA6OfBN/naZ+BOZb2r8QPtyU 9UgcRbwlbBz2jIqkBWs0nkwnOiKBKsH9vk0c5EIOdvq2EnBeVxB73PvN0vENvzwqLe M7exJjEqveOeP/cQTbPsMqdbuOyTpULHQI/Ikpzw= Date: Wed, 12 Aug 2020 09:08:27 +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: <20200812070827.GA1304640@kroah.com> References: <20200812065556.869508-1-yepeilin.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200812065556.869508-1-yepeilin.cs@gmail.com> 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 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? thanks, greg k-h