Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Guixin Liu" <kanie@linux.alibaba.com>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH] nvmet: zero the reservation report tail beyond NUMD
Date: Wed, 25 Nov 2026 06:27:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-232691@kernel.org> (raw)
In-Reply-To: <20261125061453.230238-1-kanie@linux.alibaba.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] nvmet: torn read of rkey in nvmet_pr_update_reg_rkey() [1]
--

commit 58bea4d71647eb54c1d0685be4714b3cb40c9a6f
Author: Guixin Liu <kanie@linux.alibaba.com>

nvmet: zero the reservation report tail beyond NUMD

This commit zeroes any remaining bytes in the command SGL beyond the
requested reservation report size in nvmet_execute_pr_report() so that
uninitialized kernel memory is not returned to the host.

> diff --git a/drivers/nvme/target/pr.c b/drivers/nvme/target/pr.c
> index 8c818f24815bd..63ea607d48646 100644
> --- a/drivers/nvme/target/pr.c
> +++ b/drivers/nvme/target/pr.c
> @@ -900,6 +900,9 @@ static void nvmet_execute_pr_report(struct nvmet_req *req)
>  
>  	put_unaligned_le16(num_ctrls, data->regctl);
>  	status = nvmet_copy_to_sgl(req, 0, data, num_bytes);
> +	if (!status && req->transfer_len > num_bytes)
> +		status = nvmet_zero_sgl(req, num_bytes,
> +					req->transfer_len - num_bytes);
>  	kfree(data);
>  out:
>  	nvmet_req_complete(req, status);

[Severity: Critical]
This problem wasn't introduced by this patch, but can RCU readers such as
nvmet_execute_pr_report() observe a torn 64-bit reg->rkey [1] on
32-bit architectures?

When the target registrant is not the current reservation holder,
nvmet_pr_update_reg_attr() updates the live entry in pr->registrant_list
in place via nvmet_pr_update_reg_rkey():

drivers/nvme/target/pr.c:nvmet_pr_update_reg_rkey() {
	reg->rkey = *(u64 *)attr;
}

drivers/nvme/target/pr.c:nvmet_pr_update_reg_attr() {
	...
	if (reg != holder) {
		change_attr(reg, attr);
		return NVME_SC_SUCCESS;
	}
	...
}

On 32-bit systems, the 64-bit store to reg->rkey splits into two 32-bit
stores, so a concurrent RCU reader can observe half of the old key and
half of the new key, corrupting the reported key or causing reservation
validation failures.

[1] https://sashiko.dev/#/bug/linux-b537252d-fab1-48b2-bcc6-de089d7cd907

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261125061453.230238-1-kanie@linux.alibaba.com?part=1


  reply	other threads:[~2026-11-25  6:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25  6:14 [PATCH] nvmet: zero the reservation report tail beyond NUMD Guixin Liu
2026-11-25  6:27 ` sashiko-bot [this message]
2026-11-25  7:14   ` Guixin Liu
2026-11-25  7:04 ` Christoph Hellwig

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=sashiko-outbox-232691@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=kanie@linux.alibaba.com \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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