From: Nilay Shroff <nilay@linux.ibm.com>
To: linux-nvme@lists.infradead.org, linux-block@vger.kernel.org
Cc: kbusch@kernel.org, hch@lst.de, sagi@grimberg.me, axboe@fb.com,
chaitanyak@nvidia.com, yi.zhang@redhat.com,
shinichiro.kawasaki@wdc.com, mlombard@redhat.com,
gjoyce@linux.ibm.com
Subject: Re: [PATCH] nvmet: fix the use of ZERO_PAGE in nvme_execute_identify_ns_nvm()
Date: Fri, 22 Nov 2024 14:27:47 +0530 [thread overview]
Message-ID: <539b2e5e-6314-472f-9b61-439a304a07cd@linux.ibm.com> (raw)
In-Reply-To: <20241122085113.2487839-1-nilay@linux.ibm.com>
Sorry but I forgot to add the reported-by tag.
Reported-by: Yi Zhang <yi.zhang@redhat.com>
On 11/22/24 14:20, Nilay Shroff wrote:
> The nvme_execute_identify_ns_nvm function uses ZERO_PAGE
> for copying SG list with all zeros. As ZERO_PAGE would not
> necessarily return the virtual-address of the zero page, we
> need to first convert the page address to kernel virtual-
> address and then use it as source address for copying the
> data to SG list with all zeros.
>
> Using return address of ZERO_PAGE(0) as source address for
> copying data to SG list would fill the target buffer with
> random value and causes the undesired side effect. This patch
> implements the fix ensuring that we use virtual-address of the
> zero page for copying all zeros to the SG list buffers.
>
> Link: https://lore.kernel.org/all/CAHj4cs8OVyxmn4XTvA=y4uQ3qWpdw-x3M3FSUYr-KpE-nhaFEA@mail.gmail.com/
> Fixes: 64a51080eaba ("nvmet: implement id ns for nvm command set")
> [nilay: Use page_to_virt() for converting ZERO_PAGE address to
> virtual-address as suggested by Maurizio Lombardi]
> Signed-off-by: Nilay Shroff <nilay@linux.ibm.com>
> ---
> drivers/nvme/target/admin-cmd.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/nvme/target/admin-cmd.c b/drivers/nvme/target/admin-cmd.c
> index 934b401fbc2f..a2b0444f28ab 100644
> --- a/drivers/nvme/target/admin-cmd.c
> +++ b/drivers/nvme/target/admin-cmd.c
> @@ -901,12 +901,14 @@ static void nvmet_execute_identify_ctrl_nvm(struct nvmet_req *req)
> static void nvme_execute_identify_ns_nvm(struct nvmet_req *req)
> {
> u16 status;
> + void *zero_buf;
>
> status = nvmet_req_find_ns(req);
> if (status)
> goto out;
>
> - status = nvmet_copy_to_sgl(req, 0, ZERO_PAGE(0),
> + zero_buf = page_to_virt(ZERO_PAGE(0));
> + status = nvmet_copy_to_sgl(req, 0, zero_buf,
> NVME_IDENTIFY_DATA_SIZE);
> out:
> nvmet_req_complete(req, status);
next prev parent reply other threads:[~2024-11-22 8:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 8:50 [PATCH] nvmet: fix the use of ZERO_PAGE in nvme_execute_identify_ns_nvm() Nilay Shroff
2024-11-22 8:57 ` Nilay Shroff [this message]
2024-11-22 9:29 ` Maurizio Lombardi
2024-11-22 12:08 ` Christoph Hellwig
2024-11-22 16:00 ` Keith Busch
2024-11-24 12:43 ` Nilay Shroff
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=539b2e5e-6314-472f-9b61-439a304a07cd@linux.ibm.com \
--to=nilay@linux.ibm.com \
--cc=axboe@fb.com \
--cc=chaitanyak@nvidia.com \
--cc=gjoyce@linux.ibm.com \
--cc=hch@lst.de \
--cc=kbusch@kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-nvme@lists.infradead.org \
--cc=mlombard@redhat.com \
--cc=sagi@grimberg.me \
--cc=shinichiro.kawasaki@wdc.com \
--cc=yi.zhang@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.