Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2411383pxb; Sun, 30 Jan 2022 15:39:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhopgDVCnQxAHivN+6vw+Nqfso4aKq6PaXsHcyXPrxj7735s1bM8EKsVBF3ATFU3X9QEYq X-Received: by 2002:a05:6402:40d2:: with SMTP id z18mr18383461edb.152.1643585997749; Sun, 30 Jan 2022 15:39:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643585997; cv=none; d=google.com; s=arc-20160816; b=wR0eRXj3rSNJVPBq6exTixKXlrA0p+HOqaSzdYolXnVrHMEO543S542svv5LJmLW4z agEDbxrTQjZIZQvJKcdep4EY3UFjKsp1YqJRaKu2FKoempfb83kFQ7uUo+kSHu+OOSiR rinjUeccWBG1nN3Bn1Vv1EFWrQVKjkw/mbHPj1doGxzCB/GIxJUVrSiA4ex93FYqEBoc wa1KUTiRYEX62bZBfjgff2fq3Gd6pWiWG/k7Mm7uJKzUSE49r3NLmbkF7zHa6p/D+rXj Cqrbe6Kc/PoJLlJ0/NCLHSLGEI+bbGO38LTrRRNTY8bo+HYzPVQ3j91eBCl4VoQbGk9t 6UmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7PTddfK1mABGy+/W2QOfoUYdNbK3UIQry+khlEpnnYs=; b=ld7OvtBHlmi6zOE+FtGXQ87Ycgv8jbVef+YKhS8oh+O0jqhoJuucr0dR0ciOq8RtsF f6gMXQ/BRXL5mRutKuOniQ8eSSHXqkxpZIUMUN1xoWHITrBqfY9cd9OS4DJicoXnbIhR zpZKbVl0P6M14YzrX6FBKkNGbarPVTjP6jAAIDzNl1HoY0/UOcMqJK08rK6mLioEdfbn 0jH2PE6i8osmBQDGnQKaKCl/DFdw8NM1emx0iSO5NNN4ooduOanBqgi4e9oWwdNzxteI DY0oy6cnv8U59N6z2i5eFhLAXSqu+pVgA+0yTeo7oIGfbDFfeAKVQLi7ygUsY5a1Rl6x G8Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=N0VQjGfq; 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=pass (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 i6si8386642edc.398.2022.01.30.15.39.23; Sun, 30 Jan 2022 15:39:57 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=N0VQjGfq; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347798AbiA1KSM (ORCPT + 99 others); Fri, 28 Jan 2022 05:18:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346937AbiA1KSA (ORCPT ); Fri, 28 Jan 2022 05:18:00 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93B5DC06175D; Fri, 28 Jan 2022 02:17:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3461761E51; Fri, 28 Jan 2022 10:17:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0EBEDC340EB; Fri, 28 Jan 2022 10:17:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643365078; bh=lshUfTJFHFj4Xt/uIgskMDM4p57r2Pvvnd2wk+sBnUE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=N0VQjGfqz13Px2iWGGgo7Ula5GRv/NJ8ebQkdOmZlqG3R1SUtUXo0j6SUqFfkjJiA MLiIIV0BH8a33jSxiS2+hq7cR8dOzM2H2ue8Aop29LXvnQztWwWQnWMYIoQfaTXIov iimOVXEQ0mnz4JhR+6vXhI1lOVn59CmvXUS3uGxo= Date: Fri, 28 Jan 2022 11:17:52 +0100 From: Greg KH To: Zhou Qingyang Cc: kjlu@umn.edu, Coly Li , Kent Overstreet , linux-bcache@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] bcache: Fix a NULL or wild pointer dereference in btree_gc_rewrite_node() Message-ID: References: <20220124164701.53525-1-zhou1615@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220124164701.53525-1-zhou1615@umn.edu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 25, 2022 at 12:47:01AM +0800, Zhou Qingyang wrote: > In btree_gc_rewrite_node(), btree_node_alloc_replacement() is assigned to > n and return error code or NULL on failure. n is passed to > bch_btree_node_write_sync() and there is a dereference of it in > bch_btree_node_write_sync() without checks, which may lead to wild > pointer dereference or NULL pointer dereference depending on n. > > Fix this bug by adding IS_ERR_OR_NULL check of n. > > This bug was found by a static analyzer. > > Builds with 'make allyesconfig' show no new warnings, > and our static analyzer no longer warns about this code. > > Fixes: ("bcache: Rework btree cache reserve handling") > Signed-off-by: Zhou Qingyang > --- > The analysis employs differential checking to identify inconsistent > security operations (e.g., checks or kfrees) between two code paths > and confirms that the inconsistent operations are not recovered in the > current function or the callers, so they constitute bugs. > > Note that, as a bug found by static analysis, it can be a false > positive or hard to trigger. Multiple researchers have cross-reviewed > the bug. > > drivers/md/bcache/btree.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c > index 88c573eeb598..06d42292e86c 100644 > --- a/drivers/md/bcache/btree.c > +++ b/drivers/md/bcache/btree.c > @@ -1504,6 +1504,8 @@ static int btree_gc_rewrite_node(struct btree *b, struct btree_op *op, > return 0; > > n = btree_node_alloc_replacement(replace, NULL); > + if (IS_ERR_OR_NULL(n)) > + return 0; > > /* recheck reserve after allocating replacement node */ > if (btree_check_reserve(b, NULL)) { > -- > 2.25.1 > As stated before, umn.edu is still not allowed to contribute to the Linux kernel. Please work with your administration to resolve this issue.