All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ziheng Wei <zihengw03@163.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Leon Romanovsky <leon@kernel.org>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] lib/test_hmm: hold devmem_lock in dmirror_fops_release()
Date: Sat, 5 Dec 2026 14:34:01 -0800	[thread overview]
Message-ID: <20261205143401.46fc7200cfde7914ca7e34a6@linux-foundation.org> (raw)
In-Reply-To: <20261205074354.83986-1-zihengw03@163.com>

On Sat,  5 Dec 2026 15:43:54 +0800 Ziheng Wei <zihengw03@163.com> wrote:

> dmirror_fops_release() iterates mdevice->devmem_chunks[0..devmem_count-1]
> and calls dmirror_device_evict_chunk() without holding
> mdevice->devmem_lock. A concurrent HMM_DMIRROR_RELEASE ioctl calling
> dmirror_device_remove_chunks() under devmem_lock can free each chunk and
> the devmem_chunks array while dmirror_fops_release() is walking them,
> causing a use-after-free.
> 
> Protect the devmem_chunks walk in dmirror_fops_release() with
> mdevice->devmem_lock, matching dmirror_device_remove_chunks().
> 
> Found by LLM-assisted static analysis.

lgtm, thanks.

> Compile-tested on x86_64.

That's a bit concerning.  Please find a way to runtime test things. 
Your LLM might already be able to do this in its own sandbox.


  reply	other threads:[~2026-12-05 22:34 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-05  7:43 [PATCH] lib/test_hmm: hold devmem_lock in dmirror_fops_release() Ziheng Wei
2026-12-05 22:34 ` Andrew Morton [this message]
2026-12-05 23:50   ` Andrew Morton
2026-12-06  2:47     ` Ziheng Wei
2026-12-05 22:34 ` + lib-test_hmm-hold-devmem_lock-in-dmirror_fops_release.patch added to mm-unstable branch Andrew Morton
2026-12-05 23:51 ` + lib-test_hmm-serialize-chunk-removal-with-migration.patch " Andrew Morton

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=20261205143401.46fc7200cfde7914ca7e34a6@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stable@vger.kernel.org \
    --cc=zihengw03@163.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.