mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Yuehong Wu <wuyuehong@cmss.chinamobile.com>,
	linux-nvme@lists.infradead.org
Cc: Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Chaitanya Kulkarni <kch@nvidia.com>,
	Keith Busch <kbusch@kernel.org>,
	Maurizio Lombardi <mlombard@redhat.com>,
	Mohamed Khalfella <mkhalfella@purestorage.com>,
	Nitesh Shetty <nj.shetty@samsung.com>,
	Hannes Reinecke <hare@suse.de>,
	Randy Dunlap <rdunlap@infradead.org>,
	Aurelien Aptel <aaptel@nvidia.com>,
	Jesse Taube <jtaubepe@redhat.com>,
	Rongzheng Wang <testwrzwrz@gmail.com>,
	Kees Cook <kees@kernel.org>, Rosen Penev <rosenp@gmail.com>,
	Guixin Liu <kanie@linux.alibaba.com>,
	Qing Zhang <diasyzhang@tencent.com>,
	Eric Biggers <ebiggers@kernel.org>,
	Julian Sun <sunjunchao@bytedance.com>,
	Yu Zhang <yuz08559@gmail.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nvmet: clamp the last ANA group index against the real array size
Date: Fri, 13 Nov 2026 15:49:41 +0530	[thread overview]
Message-ID: <469c4d3f-e181-4683-85e0-42046520c096@linux.ibm.com> (raw)
In-Reply-To: <20261106-nvmet-ana-grpid-1-yuehongwu@cmss.chinamobile.com>

On 11/6/26 12:10 PM, Yuehong Wu wrote:
> NVMET_MAX_ANAGRPS is the highest valid ANA group id, not the size of
> nvmet_ana_group_enabled[]: the array has NVMET_MAX_ANAGRPS + 1 entries
> and the controller advertises anagrpmax == NVMET_MAX_ANAGRPS.  Both
> array_index_nospec() calls however pass NVMET_MAX_ANAGRPS as the size,
> so for the last group the mask is 0 and the index quietly becomes 0:
> 
>   - nvmet_ana_groups_make_group() increments enabled[0] while the group
>     keeps grpid == 128, so the later nvmet_ana_group_release() decrements
>     enabled[128], which underflows to 0xffffffff.  The ANA log page then
>     reports group 128 as inaccessible forever even though the configfs
>     group no longer exists, and the increment on enabled[0] is never
>     undone.
> 
>   - nvmet_ns_ana_grpid_store() accepts 128, stores 0 in ns->anagrpid and
>     returns success, so the namespace silently stays in the default ANA
>     group instead of the one the user asked for.
> 
> Both failures are silent, and they change what the target reports in its
> ANA log page, which is what a host uses to select paths.
> 
> Pass the real array size in both calls, so the masking is kept but the
> last group is no longer folded onto index 0.
> 
> Fixes: 20dc66f2d76b ("nvme: prevent potential spectre v1 gadget")
> Cc:stable@vger.kernel.org
> Signed-off-by: Yuehong Wu<wuyuehong@cmss.chinamobile.com>

Looks good to me:

Reviewed-by: Nilay Shroff <nilay@linux.ibm.com>

  parent reply	other threads:[~2026-11-13 10:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06  6:40 Yuehong Wu
2026-11-06  7:03 ` Yuehong Wu
2026-11-06 13:47   ` Andrew Stellman
2026-11-12 21:21 ` Christoph Hellwig
2026-11-13 10:19 ` Nilay Shroff [this message]
2026-11-13 10:25 ` Hannes Reinecke

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=469c4d3f-e181-4683-85e0-42046520c096@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=aaptel@nvidia.com \
    --cc=diasyzhang@tencent.com \
    --cc=ebiggers@kernel.org \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=jtaubepe@redhat.com \
    --cc=kanie@linux.alibaba.com \
    --cc=kbusch@kernel.org \
    --cc=kch@nvidia.com \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=mkhalfella@purestorage.com \
    --cc=mlombard@redhat.com \
    --cc=nj.shetty@samsung.com \
    --cc=rdunlap@infradead.org \
    --cc=rosenp@gmail.com \
    --cc=sagi@grimberg.me \
    --cc=sunjunchao@bytedance.com \
    --cc=testwrzwrz@gmail.com \
    --cc=wuyuehong@cmss.chinamobile.com \
    --cc=yuz08559@gmail.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

all inboxes | Powered by JetHome®