Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Keith Busch <kbusch@meta.com>,
	hch@lst.de, linux-nvme@lists.infradead.org
Cc: sagi@grimberg.me, Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCHv2] nvme: sanitize metadata bounce buffer for reads
Date: Mon, 16 Oct 2023 19:14:56 -0600	[thread overview]
Message-ID: <bee7f34a-cfe0-4e4e-baf9-846c211fc398@kernel.dk> (raw)
In-Reply-To: <20231016230625.3792823-1-kbusch@meta.com>

On 10/16/23 5:06 PM, Keith Busch wrote:
> From: Keith Busch <kbusch@kernel.org>
> 
> User can request more metadata bytes than the device will write. Ensure
> kernel buffer is initialized so we are not leaking unsanitized memory on
> the completion's copy-out.
> 
> Fixes: 0b7f1f26f95a51a ("nvme: use the block layer for userspace passthrough metadata")
> Signed-off-by: Keith Busch <kbusch@kernel.org>
> ---
> v1->v2:
> 
>   correctly split data direction handling (axboe)
> 
>  drivers/nvme/host/ioctl.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/nvme/host/ioctl.c b/drivers/nvme/host/ioctl.c
> index 788b36e7915ab..eb2ef3e149614 100644
> --- a/drivers/nvme/host/ioctl.c
> +++ b/drivers/nvme/host/ioctl.c
> @@ -36,9 +36,13 @@ static void *nvme_add_user_metadata(struct request *req, void __user *ubuf,
>  	if (!buf)
>  		goto out;
>  
> -	ret = -EFAULT;
> -	if ((req_op(req) == REQ_OP_DRV_OUT) && copy_from_user(buf, ubuf, len))
> -		goto out_free_meta;
> +	if (req_op(req) == REQ_OP_DRV_OUT) {
> +		ret = -EFAULT;
> +		if (copy_from_user(buf, ubuf, len))
> +			goto out_free_meta;
> +	} else {
> +		memset(buf, 0, len);
> +	}
>  
>  	bip = bio_integrity_alloc(bio, GFP_KERNEL, 1);
>  	if (IS_ERR(bip)) {

Reviewed-by: Jens Axboe <axboe@kernel.dk>

-- 
Jens Axboe




  reply	other threads:[~2023-10-17  1:15 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20231016230939epcas5p47d9b62301959586c168c9baca580c874@epcas5p4.samsung.com>
2023-10-16 23:06 ` [PATCHv2] nvme: sanitize metadata bounce buffer for reads Keith Busch
2023-10-17  1:14   ` Jens Axboe [this message]
2023-10-17  4:17   ` Christoph Hellwig
2023-10-17  6:06   ` Kanchan Joshi
2023-10-17  8:22   ` Chaitanya Kulkarni

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=bee7f34a-cfe0-4e4e-baf9-846c211fc398@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kbusch@kernel.org \
    --cc=kbusch@meta.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    /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