public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Biggers <ebiggers@kernel.org>
To: linmiaohe <linmiaohe@huawei.com>
Cc: "axboe@kernel.dk" <axboe@kernel.dk>,
	"satyat@google.com" <satyat@google.com>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] block: Fix potential NULL pointer dereference in __bio_crypt_clone()
Date: Tue, 1 Sep 2020 22:22:44 -0700	[thread overview]
Message-ID: <20200902052244.GA54052@sol.localdomain> (raw)
In-Reply-To: <1a8ac4099d274d2b994a417c034fa3c6@huawei.com>

On Wed, Sep 02, 2020 at 01:56:53AM +0000, linmiaohe wrote:
> Eric Biggers <ebiggers@kernel.org> wrote:
> >On Tue, Sep 01, 2020 at 07:59:21AM -0400, Miaohe Lin wrote:
> >> mempool_alloc() may return NULL if __GFP_DIRECT_RECLAIM is not set in 
> >> gfp_mask under memory pressure. So we should check the return value of
> >> mempool_alloc() against NULL before dereference.
> >> 
> >> Fixes: a892c8d52c02 ("block: Inline encryption support for blk-mq")
> >> Signed-off-by: Miaohe Lin <linmiaohe@huawei.com>
> >
> >It's intended that __GFP_DIRECT_RECLAIM always be set here.
> >Do you have an example where it isn't set here?
> 
> map_request() only pass GFP_ATOMIC to gfp_mask, though bio crypt is not used yet.
> 
> >Also, if this can indeed happen, then we need to make __bio_crypt_clone() (and bio_crypt_clone()) return a bool (or an error code) to indicate whether it succeeded or failed.  We can't just ignore the allocation failure.
> >
> >- Eric
> 
> IMO, just the allocation failure is ok or we would break KABI.
> Many thanks.
> 

Ignoring the allocation failure isn't okay, since it would cause encrypted I/O
to fall back to unencrypted I/O, which would cause data corruption.

Also, upstream doesn't have a stable KABI.

I sent out a patch with what I have in mind; can you take a look?
https://lkml.kernel.org/r/20200902051511.79821-1-ebiggers@kernel.org

- Eric

  reply	other threads:[~2020-09-02  5:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-02  1:56 [PATCH] block: Fix potential NULL pointer dereference in __bio_crypt_clone() linmiaohe
2020-09-02  5:22 ` Eric Biggers [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-09-01 11:59 Miaohe Lin
2020-09-01 16:07 ` Eric Biggers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200902052244.GA54052@sol.localdomain \
    --to=ebiggers@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=linmiaohe@huawei.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=satyat@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox