Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2251095rwi; Tue, 1 Nov 2022 05:46:44 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Cl2VjDSjDZEY+hcueZHTMOK6Bt7jSWArynj83bNCSbzQFmI4SB44Q7h5sLZV18/PAlTr8 X-Received: by 2002:a17:90b:1918:b0:213:d97c:c6c9 with SMTP id mp24-20020a17090b191800b00213d97cc6c9mr11872152pjb.198.1667306804506; Tue, 01 Nov 2022 05:46:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667306804; cv=none; d=google.com; s=arc-20160816; b=VrnutY+D4tFzcHbnzn8EHseBsuf/DsKnvrjhHfR1CVQVTDoeuoFV3J4ZTcdg1iYJVj oCzplhSOpz94Cckq4nyK+PwK6PM+DD1TwJFm34QLRkWfCoZOrTYTGfHOaemRisFI5VRz xiFvPBpuMqgtWoGdtjjAVHsFOcu8RICHXDr+VhbvLJs/VMdn1t2o7R7NfkebVdOO8HnA decmtX+o5CEIQfIPBscNWAsGkUkL1lLUqK21ZuD/JKYdO1hNNxMOesFuec/t7xupWWZG CgYiqlh9xZorABRjZuReCN0Pq+HLMcSTaq45hrAuXDpmbsry0HyZXRe/PyJEUE/8naiN DWjw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1HSWFPfOt1riIb0IjJMCk5APkuULOujn78qsjSkzbHc=; b=jSDeWDabTQxhai8DUOsMCggG1NxQHdWr6+tOi99NWtxN2yb6g0qoLH/Y+Eo2F57sKb D1ytv1LrFMD28QuSvHo9LcPempvNl0vfHTgx2OhPmUro4Ca9rQxwbPWZEQfE4Cyn/2pa iGx6zUq9+tMhGeazs6GmTfU1CY5aO9OK15gFOgfo1iq9LnbU+4zaxGOGx9xHBNnsSl7w y+z1qPx8AWig9WwrpsZvN0STbfnsqZ2jF3FmSw9i9fUwPG430OllunEXGdFgJHwKkqLD zwPqVH+/X/UQF34fsIegQA5ZspqXFkgvBPWzbTPIz12nmIgnyTJW1pSWOGj57L/52+yt OyRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="To6Gz/mz"; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a056a00189800b0056bce3dfaacsi11699482pfh.25.2022.11.01.05.46.31; Tue, 01 Nov 2022 05:46:44 -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=@kernel.org header.s=k20201202 header.b="To6Gz/mz"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230322AbiKALbT (ORCPT + 97 others); Tue, 1 Nov 2022 07:31:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiKALal (ORCPT ); Tue, 1 Nov 2022 07:30:41 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BA2E63F9; Tue, 1 Nov 2022 04:29:21 -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 ams.source.kernel.org (Postfix) with ESMTPS id D293AB81CC6; Tue, 1 Nov 2022 11:29:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A186DC433C1; Tue, 1 Nov 2022 11:29:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667302158; bh=e8tBsfk9EYh1neUMVjssmIJU9k1CMFsjsde1Uilgo88=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=To6Gz/mzR5sl1yK8wueU1ymrCjZF7kYU4axgjQLGkNe8Q1aegLdeOXzyFD1FFezud 89YYtpiZebaWuFnABLgTcs/y9fQlpvkMuI5ohMECsGNOf7VXhhzXps7NUTYMI826g4 QRCanvt0YD7m0zWQrxBUtxYEntMqjyzO2JtBWXZkMeASkDXGlXuji+2871VeSiiN01 ZdoT9wp2jJIBsDU2EfV6iidrf/00o86ignd8To7i5XAjkC2v3/exAmex5ilXdwxjWW //VUUoxxft29CrK+aPFQM8DJaY6MBUWwzJe/qljM5yVnbCvcwT0D7J/d88VBstwyc4 Xj+CN+jbesLoQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pavel Begunkov , Christoph Hellwig , Jens Axboe , Sasha Levin , linux-block@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 34/34] bio: safeguard REQ_ALLOC_CACHE bio put Date: Tue, 1 Nov 2022 07:27:26 -0400 Message-Id: <20221101112726.799368-34-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221101112726.799368-1-sashal@kernel.org> References: <20221101112726.799368-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.2 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 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: Pavel Begunkov [ Upstream commit d4347d50407daea6237872281ece64c4bdf1ec99 ] bio_put() with REQ_ALLOC_CACHE assumes that it's executed not from an irq context. Let's add a warning if the invariant is not respected, especially since there is a couple of places removing REQ_POLLED by hand without also clearing REQ_ALLOC_CACHE. Signed-off-by: Pavel Begunkov Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/558d78313476c4e9c233902efa0092644c3d420a.1666122465.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index 77e3b764a078..fc2364cf1775 100644 --- a/block/bio.c +++ b/block/bio.c @@ -741,7 +741,7 @@ void bio_put(struct bio *bio) return; } - if (bio->bi_opf & REQ_ALLOC_CACHE) { + if ((bio->bi_opf & REQ_ALLOC_CACHE) && !WARN_ON_ONCE(in_interrupt())) { struct bio_alloc_cache *cache; bio_uninit(bio); -- 2.35.1