Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp593347iog; Mon, 13 Jun 2022 08:47:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxpoSQIasz4w9m3FUJ7cZ2s0Jdae07XNTcVyAigYHhmV2JV7Z/xkk6/HFDRRUyoLVVC0f/D X-Received: by 2002:a05:6a00:1907:b0:4f7:945:14cf with SMTP id y7-20020a056a00190700b004f7094514cfmr191877pfi.47.1655135223590; Mon, 13 Jun 2022 08:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655135223; cv=none; d=google.com; s=arc-20160816; b=ukIhKimEoDTQaE8hmCFkdWPaV0Wkw2HZZiacPnQNwN+AWtkzTgLWYDZKWwXLydqvtI 4hCGLa5SGoYfNkFqHLaORGq+flh94kZs/zSgskqZMHSgNdqi98M6HGc1KOJOJf2ZQuUX RTC33IEmCkO+APkddwg7tIstcAHygY8FbKnTX4B6sJX7C75zsW14SHuqfHjDN3o6uZQf ePq4+FfGCQsaJgpD/RpMnLR/UF2QUEe+RoRI1EKnHEMKtCqCZEkazChttlY1hLjfZJjL tt2sxvCQCVKixTIMF1eUqTY5oQ3jLA7LrDI/KcISktnDv3Vyqr19M/k1Fy8KNZYFZITY i5mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UK0xYopk4oKKQf6STDlVLLKfTVv/K4hq6euF2+GsDUk=; b=uFzfV4SGM5LZT+cvLQGY+oVAaV576H27FvN/5tcLiQ1oEGG/hq9rC36xpW28nKLHa2 XwZDBiQEciwQOlTUhbL3giiuBibGaCj2IYmc4ajV1o7l7EObAOmWq80pV7RLuqCqmjaO 7xaxKVBhh5vugUh4rJTtDOT0/+39MTJdNc8blmFuqP0oisK7Zt5RXQkxl09ZTL0978TE IsG6iwzp55wi8GDc5iSzhqAGiXw8pHAUzsElIGTtYKh8UVLeEevkDI2OeuS3nGN/a5E2 QcUtFZzdk4QmD8HZ9k8rdH7sopJZblUneMAjbbqrPO25wQX/QWsyZLwws2qjVeGGwDPG jYpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WD3lZFi3; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x3-20020a170902ec8300b00168a4ef6a67si11980266plg.17.2022.06.13.08.46.49; Mon, 13 Jun 2022 08:47: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=@linuxfoundation.org header.s=korg header.b=WD3lZFi3; 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=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358821AbiFMNH6 (ORCPT + 99 others); Mon, 13 Jun 2022 09:07:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234906AbiFMMzV (ORCPT ); Mon, 13 Jun 2022 08:55:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18ED6D12E; Mon, 13 Jun 2022 04:16:00 -0700 (PDT) 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 A8CE960EAE; Mon, 13 Jun 2022 11:15:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7834C3411E; Mon, 13 Jun 2022 11:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655118959; bh=cokuF+EmG7THmip/f1ZMHWS/tW/vYaqu9L+68+z/nek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WD3lZFi39bOtJpnYnf9Eyf8+1L1R8gqSvnJw19EU5sDWjaySyMh7zpWCVKneOvYPl g2PhYTVnuDTqhJ20CWwjp0wvE/lGKYGr10HGJuK5qPLjxsDMDuTVAtawnY1bt3yfy6 VOTo3t9ddoHfOoRU0S6ZC8L1ShtWWeFWAkE7YuyM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthew Wilcox , Jens Axboe , Sasha Levin Subject: [PATCH 5.15 090/247] block: make bioset_exit() fully resilient against being called twice Date: Mon, 13 Jun 2022 12:09:52 +0200 Message-Id: <20220613094925.686356643@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094922.843438024@linuxfoundation.org> References: <20220613094922.843438024@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Jens Axboe [ Upstream commit 605f7415ecfb426610195dd6c7577b30592b3369 ] Most of bioset_exit() is fine being called twice, as it clears the various allocations etc when they are freed. The exception is bio_alloc_cache_destroy(), which does not clear ->cache when it has freed it. This isn't necessarily a bug, but can be if buggy users does call the exit path more then once, or with just a memset() bioset which has never been initialized. dm appears to be one such user. Fixes: be4d234d7aeb ("bio: add allocation cache abstraction") Link: https://lore.kernel.org/linux-block/YpK7m+14A+pZKs5k@casper.infradead.org/ Reported-by: Matthew Wilcox Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/bio.c b/block/bio.c index 9b28381412d2..8381c6690dd6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -665,6 +665,7 @@ static void bio_alloc_cache_destroy(struct bio_set *bs) bio_alloc_cache_prune(cache, -1U); } free_percpu(bs->cache); + bs->cache = NULL; } /** -- 2.35.1