From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50C973ACF07 for ; Thu, 9 Apr 2026 10:09:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775729385; cv=none; b=fMI3anuTuQE1u7um1fRX+nlEjzI5mE4E34Qn61UCuXwlbTMHDuDuU64CqhtQOukqd1t9Xiovb690BEndg6Xqy2WpQOc8e+98GYqJE+4pVw84z9U/F6kJwFwySYFf2SKVE+BNHxR2Imw/EDZ2UAMtrkgCafb+WFiZ9cNwyp8zJIk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775729385; c=relaxed/simple; bh=gDPlLIZMDSKGp8rM/tAzo6PGs3I0TWrP9B+TqnbQOAo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Kjxbp0LWDzwtkZrX6o7XIi2TyWXxeSSYta46ivCC540vUuuaQrLFdQB//nC7NrT1WbSea69rFO9fkomtZeiA3XEdefByd5BAR905XQpiSD6GWW1mE0+/oVPKSZCvO6swUIrCn0xY6bi3krXKea6ch+ud2MAqujBw/MZLFybEmiE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W9oXowWs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W9oXowWs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7423CC4CEF7; Thu, 9 Apr 2026 10:09:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1775729384; bh=gDPlLIZMDSKGp8rM/tAzo6PGs3I0TWrP9B+TqnbQOAo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W9oXowWsDcNR6qKBv6OzSuu7PUJ8lgPSzNRZ9EvXDexW503z3R+mYmQpn4WjK6bod PSPSdApYULVQnCBbuBf1j/FQ2aMvh56o30+geHtCUKWbWJUa+yHDKmJ8pw4OYkLjdL E4s75JkdufM+HYS4kt0q5CO+CRIx0g0TWwUjSDNiLa1NbiT+qaRbC1TBSzdxlBkY+1 Kq3xbdynzYavJjKIIPiM7nL2wEIiNNsSOSw64QeqTlVwviGgXiEbhJlhFiFW+iI4Hr 9/cnezW8w+8HZ54NYlI/NUb7uxvrmb5/tEkjX3Ac3l5nd9aEhwyehAziCvUZPafc5v bGn6Gud98keow== Date: Thu, 9 Apr 2026 11:09:40 +0100 From: Lorenzo Stoakes To: xu.xin16@zte.com.cn Cc: david@kernel.org, hughd@google.com, akpm@linux-foundation.org, chengming.zhou@linux.dev, wang.yaxin@zte.com.cn, yang.yang29@zte.com.cn, michel@lespinasse.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] ksm: Optimize rmap_walk_ksm by passing a suitable address range Message-ID: References: <202604091806051535BJWZ_FTtdIm3Snk24ei_@zte.com.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202604091806051535BJWZ_FTtdIm3Snk24ei_@zte.com.cn> On Thu, Apr 09, 2026 at 06:06:05PM +0800, xu.xin16@zte.com.cn wrote: > Can we just replace the stored anon_vma of "ksm_rmap_item" with the orig_vma > when KSM merging? Then, from rmap_item->orig_vma, we can directly obtain both > the anon_vma and the vm_pgoff, thereby enabling the location of all PTEs mapping > this page without any ambiguity. Please no :) that's a UAF waiting to happen, VMAs are highly dynamic objects that can change at any given time if appropriate locks aren't held, nor are they refcounted. David suggested a way of storing the vm_pgoff without increasing rmap item struct size, hopefully that's viable and then we can get the benefits here without breaking anything! Cheers, Lorenzo