From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796510043; b=zgMVlp1/tcbgZ66jDCSJm4wsZ4ZXlputawjxaqS7hvoEXZS2edWnyrxyfmo8YFNHc1/h UpxFPZtEXHWu0tpbVqm2N9/zHfVF+ycPS+53QhdUyhD3iPumEhiLY6cdxP4uWfY+RJ2yg jpqHa50ydPP+rxR1SteGYAwQsWNrA+bs+cCAw0ppwbaHlVyNYssUpj0UlOr1qI1qrIhR5 PPwg7ORb5uDn313LLmdJKL1tdVG3VpxPErq3pD5NyP1TffYDKu7/KyY+pPi57/59niLz1 fur5WQqBNmuze86b9EJZiPQfLbOB+0rUf90tWeWO7cT4EZFeSUFL9cy/sCw8fNgwDUA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796510043; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-Id: In-Reply-To:References:X-Mailer:Mime-Version:Content-Type: Content-Transfer-Encoding; bh=5EZOXkmw+nV7KvQqGZBYWku71h/JtH/iASIsIBXtSBg=; b=KOubHyBGAkbEiRGbrQOY5+xa/jf+GxJlldZVH8BKyK6hGSnnil4GfWEAJxVY3NrWKf53 yUGBwtHqjJjhvvuao4/a3wznAWcJTEMREfiwrW9hdk6YbltQMjV1GJhAEQjr72gyDIepG ArIBhpwqftQUVfxP1iBPzmMSE0SnckkyJdUudk3hgqAWlPVHdEeeE82/VEzZp7mIYqUHl GDbtl6FrJJIPL+2U0WHq9OcVrN1Tj9bj7/jaLMcRZTL5bRG1/mh6jsQ2E2SYmTWD39TVS b5s5xl0FCjI07+PTrW4mfuJ3bGEEPGqZRR/jrzrd5LYB/K99i5DBNJgXJdQ5AQEbl6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=X6LGdtUw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 43564606A31F; Sat, 5 Dec 2026 22:34:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=X6LGdtUw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 943291F0092B; Sat, 5 Dec 2026 22:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796510042; bh=5EZOXkmw+nV7KvQqGZBYWku71h/JtH/iASIsIBXtSBg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=X6LGdtUw6zQhEs8vNH439oU7dctvGVh1l0LLhGWSPv2mxK9R1CT+5ForOlR8SbHMv 1jM1FotnqsbBzXU23UVJy3+5MKAnHFPzZFo8ybagl+W6aZNZszW9DJJNx+E9BpAOh3 Em7NirQS5uiHUz2Of7tYBmM4PsjQsmfvn1Y0C5hw= Date: Sat, 5 Dec 2026 14:34:01 -0800 From: Andrew Morton To: Ziheng Wei Cc: Jason Gunthorpe , Leon Romanovsky , 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() Message-Id: <20261205143401.46fc7200cfde7914ca7e34a6@linux-foundation.org> In-Reply-To: <20261205074354.83986-1-zihengw03@163.com> References: <20261205074354.83986-1-zihengw03@163.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 5 Dec 2026 15:43:54 +0800 Ziheng Wei 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.