Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2166864pxb; Mon, 22 Feb 2021 23:25:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJzw1L2dveLqqAmRp9W34fbuNVESkP4lV7hjhqQLjuTmhulmv8XqLlakXbeQ3FPEjOUaVfeE X-Received: by 2002:a05:6402:3514:: with SMTP id b20mr25863475edd.100.1614065153648; Mon, 22 Feb 2021 23:25:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614065153; cv=none; d=google.com; s=arc-20160816; b=lxy5NWq4VNfpA1i/CzTsfkBWLUiND3tr6EtnuSCuK2L9UbKlD2Ir/8HHafn/ySMT31 YC4q73KVZTohTNn60DK87x19rCFKZ9BKfe0aDgBQlqoVcla9AYuCTJHPaj+PpKFrbJXF E17+brCL/ACK4zhD5zilhbEze1MwSsMeX9pFIssSnW73e8aNhpkQc5loLGS8GFgm5/p5 ++cup3Y5DiB8jUm7prVDl63ueoSdK/tZYbvjl023LXXJj1OX467DNakAbKE9j7NfetPj 7TSfMAXRw+oZRktw8ky0OKvdDpLkIYIkqbZhFDX/6/gjTM7GeW4C2TVI1vaxUPybxtTD pgeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=jZnl6xCmkXxMOgB+yWJvLLO6H17tbXaA/y5S0p4mnH4=; b=B14eaEzLHcT6qAvN2X654oXfRMAnvtQoWkHxZKtlXTeI9b2hpyCkvAW8WRowfLosXw UjuEhcwDMM3gBSOTZ9QL7JXccUj8rja+etWBy3copuYdNk7cySA72QGdqjlQNnfq17mw FNs8b1EI+q2dI6v8Bss7Snb1e26Lf4EoutYg9W331m0xMi37j6JLNqjtTXl6omYVf6h4 d2ilfz1erEBTiutV+rqNLPwWuxEzTw7QZHvfFvR/1n1/Mrg61+RrxxMWePivRedWGBsA tCn20erG/z4+QmvR0wBQtKCw3YOizDuBU0BbDGIAuTYJqiexyPq0MJvcNh5Vde+Kys92 Lj+g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s24si4820254ejd.591.2021.02.22.23.25.29; Mon, 22 Feb 2021 23:25:53 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231863AbhBWHXr (ORCPT + 99 others); Tue, 23 Feb 2021 02:23:47 -0500 Received: from verein.lst.de ([213.95.11.211]:32997 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231822AbhBWHXg (ORCPT ); Tue, 23 Feb 2021 02:23:36 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id B7D5268D0D; Tue, 23 Feb 2021 08:22:52 +0100 (CET) Date: Tue, 23 Feb 2021 08:22:52 +0100 From: Christoph Hellwig To: John Stultz Cc: Christoph Hellwig , Johannes Thumshirn , Chaitanya Kulkarni , Damien Le Moal , Jens Axboe , David Anderson , Alistair Delva , Todd Kjos , Amit Pundir , YongQin Liu , lkml , linux-block@vger.kernel.org, Satya Tangirala Subject: Re: [REGRESSION] "split bio_kmalloc from bio_alloc_bioset" causing crash shortly after bootup Message-ID: <20210223072252.GA18035@lst.de> References: <20210223070408.GA16980@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210223070408.GA16980@lst.de> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2021 at 08:04:08AM +0100, Christoph Hellwig wrote: > The problem is that the blk-crypto fallback code calls bio_split > with a NULL bioset. That was aready broken before, as the mempool > needed to guarantee forward progress was missing, but is not fatal. > > Satya, can you look into adding a mempool that can guarantees forward > progress here? Something like this would be the minimum viable fix: diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c index e8327c50d7c9f4..c176b7af56a7a5 100644 --- a/block/blk-crypto-fallback.c +++ b/block/blk-crypto-fallback.c @@ -80,6 +80,7 @@ static struct blk_crypto_keyslot { static struct blk_keyslot_manager blk_crypto_ksm; static struct workqueue_struct *blk_crypto_wq; static mempool_t *blk_crypto_bounce_page_pool; +static struct bio_set crypto_bio_split; /* * This is the key we set when evicting a keyslot. This *should* be the all 0's @@ -224,7 +225,8 @@ static bool blk_crypto_split_bio_if_needed(struct bio **bio_ptr) if (num_sectors < bio_sectors(bio)) { struct bio *split_bio; - split_bio = bio_split(bio, num_sectors, GFP_NOIO, NULL); + split_bio = bio_split(bio, num_sectors, GFP_NOIO, + &crypto_bio_split); if (!split_bio) { bio->bi_status = BLK_STS_RESOURCE; return false; @@ -538,9 +540,13 @@ static int blk_crypto_fallback_init(void) prandom_bytes(blank_key, BLK_CRYPTO_MAX_KEY_SIZE); - err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots); + err = bioset_init(&crypto_bio_split, 64, 0, 0); if (err) goto out; + + err = blk_ksm_init(&blk_crypto_ksm, blk_crypto_num_keyslots); + if (err) + goto fail_free_bioset; err = -ENOMEM; blk_crypto_ksm.ksm_ll_ops = blk_crypto_ksm_ll_ops; @@ -591,6 +597,8 @@ static int blk_crypto_fallback_init(void) destroy_workqueue(blk_crypto_wq); fail_free_ksm: blk_ksm_destroy(&blk_crypto_ksm); +fail_free_bioset: + bioset_exit(&crypto_bio_split); out: return err; }