Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8111017rwi; Tue, 25 Oct 2022 02:37:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7i6TTf5W73ijMiK9y0JRySA5trw7poLYNT4RBD5tZEoKy5hf9GPkyPYcY6AF+qiq5Fo2VW X-Received: by 2002:a05:6402:1d4e:b0:461:c7bd:7d9c with SMTP id dz14-20020a0564021d4e00b00461c7bd7d9cmr8418438edb.284.1666690623224; Tue, 25 Oct 2022 02:37:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666690623; cv=none; d=google.com; s=arc-20160816; b=KVcmmPSgS4kYibrldRT7jX6BkyhdMLcQH99qHI4+zXyjGVfE+bMbDiXruY5IjWI0n1 K6SdxjJO585f7m9UI2m6b1YWbq0BmPBAyiYb1vi7dFzBS8hEvh6IeqLUlrKbM8V/zjwD aN20NdGJ38aaFqHl8KAHJqF9GaLeFKxbUqFzx6JcZZJht+X7p12N9IQmCytry5XRZpSS 8pcEfvgSbhO0uKUBznw8Wj0U//r2yIeijPennnPzWf47VtaoZ8kIQFIk/bQad6eeDpmf REl4zMJ1NBs3hSFPeMjMjc7JujdP1w36w6FqXGwSRvDX0/JFMSfFAMeiH8ADrvZ3v2nK KHeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=X3hqIV0wZfEGGNbJBT4Kj1SM5tbGwTop51vS5maKUNI=; b=Y6SxIX9PIKzBDjT2goKxVtXcS5h9Un6RvUGKJVZkLgalqNfi0jQs2YCCKL0ASFXIT6 pYzVv0azgwNZxMTz1HW+RPWGW7rhwo1le3S2RoyKS3mIannNlwIU1PWjq8DY/TECsQ5H g8MtseBKQWEEZFXoC2rCvzGOH2RAnPms5e5WRFBSCisez+4O4xgiF1Uf1iEjzcUO35OD AFl06NxoUxUhG/NabnBXhFgrnuW991yCmMshcqhNRiq0UASD3m0xAumlAMxlto7H2Vpv XfTR07BfQEwlHH9lqbTl2S5ktpHTthN0ByPnJIJN3etmVxwViRmCnKfwBVI90epJmcph XLWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iklZYoBs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v23-20020a170906565700b0078210c21ecesi1864509ejr.304.2022.10.25.02.36.38; Tue, 25 Oct 2022 02:37:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=iklZYoBs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231207AbiJYJal (ORCPT + 99 others); Tue, 25 Oct 2022 05:30:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230307AbiJYJaU (ORCPT ); Tue, 25 Oct 2022 05:30:20 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39B3CBAF; Tue, 25 Oct 2022 02:29:03 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EBC5D1FDB3; Tue, 25 Oct 2022 09:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1666690141; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=X3hqIV0wZfEGGNbJBT4Kj1SM5tbGwTop51vS5maKUNI=; b=iklZYoBsKNhjMJ4wTorCWN5TtI7lP6OEUK/v0hqVKvfqWo7u6oBG82yYh0ynNx17tCj8y9 SaedHE8rtfBX2dY7EB7oOrS2Sv5tmbVdbgfSlzj5qd2hoiq+fKUQpJ+y2YxxDG0w+rBFo1 ykTU/b6lYYAqPmZdEg5GF6uREsmTvRk= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 955FF134CA; Tue, 25 Oct 2022 09:29:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id YombIV2sV2PiQAAAMHmgww (envelope-from ); Tue, 25 Oct 2022 09:29:01 +0000 Message-ID: <1d9d4d78-073d-fc49-1918-f7c8ab6fe15e@suse.com> Date: Tue, 25 Oct 2022 12:29:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH] btrfs: volumes: Increase bioc pointer check Content-Language: en-US To: Li zeming , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20221025082835.3751-1-zeming@nfschina.com> From: Nikolay Borisov In-Reply-To: <20221025082835.3751-1-zeming@nfschina.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25.10.22 г. 11:28 ч., Li zeming wrote: > If kzalloc fails to allocate the bioc pointer, NULL is returned > directly. > > Signed-off-by: Li zeming This patch clearly shows you haven't really understood the code. As is evident there is __GFP_NOFAIL flag so as per the guarantees for this flag we either loop infinitely trying to allocate a bioc or simply allocated it. So this check can never be triggered. NAK > --- > fs/btrfs/volumes.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c > index 064ab2a79c80..f9cb815fe23d 100644 > --- a/fs/btrfs/volumes.c > +++ b/fs/btrfs/volumes.c > @@ -5892,6 +5892,8 @@ static struct btrfs_io_context *alloc_btrfs_io_context(struct btrfs_fs_info *fs_ > */ > sizeof(u64) * (total_stripes), > GFP_NOFS|__GFP_NOFAIL); > + if (!bioc) > + return NULL; > > atomic_set(&bioc->error, 0); > refcount_set(&bioc->refs, 1);