All of lore.kernel.org
 help / color / mirror / Atom feed
From: Nilay Shroff <nilay@linux.ibm.com>
To: Guixin Liu <kanie@linux.alibaba.com>,
	Keith Busch <kbusch@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Christoph Hellwig <hch@lst.de>, Sagi Grimberg <sagi@grimberg.me>,
	Daniel Wagner <dwagner@suse.de>, Hannes Reinecke <hare@suse.de>
Cc: linux-nvme@lists.infradead.org
Subject: Re: [PATCH v5] nvme-multipath: serialize ana_log_buf lifecycle with ana_lock
Date: Fri, 4 Dec 2026 15:59:29 +0530	[thread overview]
Message-ID: <689213be-3c6a-4a90-b2fc-996629494987@linux.ibm.com> (raw)
In-Reply-To: <20261204070041.3602839-1-kanie@linux.alibaba.com>

On 12/4/26 12:30 PM, Guixin Liu wrote:
> nvme_parse_ana_log() reads ana_log_buf and ana_log_size under ana_lock,
> but the buffer is freed in nvme_mpath_uninit() and reallocated in
> nvme_mpath_init_identify() outside the lock. A concurrent parser in
> nvme_mpath_add_disk() can then use freed memory, dereference a NULL
> buffer, read a freshly allocated buffer before nvme_read_ana_log()
> populates it, or validate stale descriptors against shrunk limits
> (WARN_ON_ONCE). Once the buffer is NULL, nvme_read_ana_log() calls
> nvme_get_log() with size 0, where nvme_bytes_to_numd(0) underflows to
> 0xffffffff, and the NULL-buffer bail in nvme_parse_ana_log() leaves
> desc.state == 0 so the namespace is stuck NVME_NS_ANA_PENDING and never
> goes live.
> 
> Take ana_lock around the buffer release and reallocation, updating
> ana_log_buf, ana_log_size and anagrpmax together. Allocate the new
> buffer outside the lock and zero it, and clear ngrps on the shrink path,
> so an early parser sees ngrps == 0. nvme_read_ana_log() bails on a NULL
> buffer and nvme_parse_ana_log() returns -ENOENT in that case.
> nvme_mpath_add_disk() keeps the lockless nvme_ctrl_use_ana() feature test
> and, on -ENOENT, clears any pending bit and falls back to the non-ANA
> path so the namespace goes live even if ANA was disabled while it
> parsed. The ana_work drain stays outside the lock since ana_work itself
> takes ana_lock.
> 
> Fixes: 0d0b660f214d ("nvme: add ANA support")
> Cc:stable@vger.kernel.org
> Signed-off-by: Guixin Liu<kanie@linux.alibaba.com>

Looks good to me:

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


  parent reply	other threads:[~2026-12-04 10:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  7:00 [PATCH v5] nvme-multipath: serialize ana_log_buf lifecycle with ana_lock Guixin Liu
2026-12-04  8:23 ` Christoph Hellwig
2026-12-04 10:29 ` Nilay Shroff [this message]
2026-12-04 11:22 ` 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=689213be-3c6a-4a90-b2fc-996629494987@linux.ibm.com \
    --to=nilay@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=dwagner@suse.de \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=kanie@linux.alibaba.com \
    --cc=kbusch@kernel.org \
    --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 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.