From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E6EF1AC44D for ; Sat, 21 Mar 2026 23:57:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774137445; cv=none; b=Em4CyXzBR5TOXCSosylXB+B27492o2X5V8B6kUlSfA9nEBM9+qaFp6A4VaFrb2XZXxuUEZNe+ITOPXcLHK5YOJW3OChrh8imIaqBHj0HZDo5V7bHVkbL2FiNp2SdlEu9UQjsdmw4pXMccNfoyb3ZBElWu8UqT1F2CW8MnoqXLcY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774137445; c=relaxed/simple; bh=lkV68X9LxcNUAchAI3reSRnd3whbyecpsJN6/wyT/Rg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=nzwpfAIfmh5tYZTye5vLU88s/cL8SV/V53ypR2mOSfA2QPS82OpQPLUBl6Rb1HXIMT+XVlUPuHP01CyMaLqXlBd+gPl4lo4LDjHoxQV2j0oi+MDm1ukxysXmEAiYqtg4PcpJ7IPPWyuX6etzsnZLafcPo0HqmJua9oTOFi25kEE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=B+4dhaM2; arc=none smtp.client-ip=209.85.215.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="B+4dhaM2" Received: by mail-pg1-f179.google.com with SMTP id 41be03b00d2f7-c6e2355739dso1286073a12.2 for ; Sat, 21 Mar 2026 16:57:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1774137443; x=1774742243; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=fien3WBzKEP70100CMVx+hvZzy3ZitaPZv79bCUSu/w=; b=B+4dhaM2cxBaVTcbc7bjwkETFyQBeTo2ro6YY8RWpp4eo8JULgr3TShOZbGrG15zA9 g4WN6RtU3+E52CQiDFk/X3EkMCbs+GzfJko1d4N+x4W0naLCjdoViPh0hUcHdN4xfU/Y ACyp8FjIJ9v2kwoP6+XD68z2l3c2cUSOXJZy/2rmCZKwG1eUmvEifHI5nDyyrmFqFsEO 5JsJA8D/eGIZgt7HmAvZh94JHG8IU+NliAqbT+MscLqmOrAU9Lxm4JLE6DQL5rO8tdlg qbbI6hYAZlLD0qOVBz7kBkVR+nTAi+qnO9cjbZj449HGpfPIY7gua7Oa+3Wx69ZCI2T8 aqKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774137443; x=1774742243; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fien3WBzKEP70100CMVx+hvZzy3ZitaPZv79bCUSu/w=; b=hnCAmW57sQp9I6NTc1EZlqRfAQ0UqhuYtLISxNU5BUDISWn73nldwLqwLe5MRcBvH0 qdQIFyZjuraJ7J0G0BN+e8EsrdRn7vwnw1XUisqY93cui0R9vr1EcW4yro+o5OXGj8fv QvltmWoa6TqVGXasq0NUgxSpSwDf6JmgVJMG2sPJmWrXtAz+eNYtPLtpYI1WsryQc6o+ VxMDUIANPnNbalO2qVyXGZ3iIz3TXwmfq/q9qe71eCCwdDPN49q6vfL9oqbPmF34sAGa p1P15IRJ4VsP8LEPRi0dZBQtGywKiY1PxjxgFs1mwEFo0injuNU+VsUq3PJKdS9g9151 /cxA== X-Forwarded-Encrypted: i=1; AJvYcCXbQoTUhOtedOinoK/ROpq0+JKI56hYgruJKoZLMpiP1k7XCz7ImuS/bBpbAtkTZj01Om2XRcuPTR3Fu3s=@vger.kernel.org X-Gm-Message-State: AOJu0YxT4JHWHPb8+qbgC0PQCPMMOT7TYob/a+7Wme14mRdcaW0/+xBK RKYe3IcztxhS+0TTGsC3IDyJy36Him+CHVKMZhk1bHSpmvY4N+g2vuAU X-Gm-Gg: ATEYQzzcCgYNo36veeYxA0a8I8h6vHGOjJ9KrLkpcJSCs89ly7ADfivTXNdHmqNiRSB mJkC1mJTCsBrqzOTsTvKn1BsbiAzD6l2aCBfPfaRkO4g6/6XXdr3cv/zUzX61B3MLUcxypPigUp CbmWvX8d4noduJo33bWLYNP7mfx8wAZR8hbYaMRgWs4YLVDljFutok4/nrF9D3U6/ReK2EY2sQl PEBmOg9wq9ccrSiVG/ss50x2bEmVvjOfqrNmRfsNACvnNbSyUyGlGQ4LoNvJlUD0U8KRhfSp3Iw cC4UE5H8LUiAlaXRrelPV9BeH5IS9cq+VrestkmI/DC6hdl++QPAAUa/lewihn/UVGXQgEl8KEQ 0FGU4adfX5VLHzHrDAXUoFrgzQrmfrw37e3WcrC4tK2tlj4HH2K1ClBiCELR/Nohx1vAfl1+FHI 103xV4HooEvyaFyAXp3xIBKXRTRAWLuE5h0bXI3sK6epXMXqDfLVPdrB38717y0PG5lgIqaYzeM EnHdzaxYRCF X-Received: by 2002:a17:902:f685:b0:2b0:4a1c:b847 with SMTP id d9443c01a7336-2b0827d55dcmr71320455ad.52.1774137443412; Sat, 21 Mar 2026 16:57:23 -0700 (PDT) Received: from naup-virtual-machine (114-36-250-67.dynamic-ip.hinet.net. [114.36.250.67]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b083656b67sm80649985ad.38.2026.03.21.16.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Mar 2026 16:57:22 -0700 (PDT) Date: Sun, 22 Mar 2026 07:57:19 +0800 From: Hao-Yu Yang To: security@kernel.org Cc: tglx@kernel.org, mingo@redhat.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] futex: Use-after-free between futex_key_to_node_opt and vma_replace_policy Message-ID: References: <20260313124756.52461-1-naup96721@gmail.com> 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=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260313124756.52461-1-naup96721@gmail.com> On Fri, Mar 13, 2026 at 08:47:56PM +0800, Hao-Yu Yang wrote: > During futex_key_to_node_opt() execution, vma->vm_policy is read under > speculative mmap lock and RCU. Concurrently, mbind() may call > vma_replace_policy() which frees the old mempolicy immediately via > kmem_cache_free(). > > This creates a race where __futex_key_to_node() dereferences a freed > mempolicy pointer, causing a use-after-free read of mpol->mode. > > [ 151.412631] BUG: KASAN: slab-use-after-free in __futex_key_to_node (kernel/futex/core.c:349) > [ 151.414046] Read of size 2 at addr ffff888001c49634 by task e/87 > [ 151.414476] > [ 151.415431] CPU: 1 UID: 1000 PID: 87 Comm: e Not tainted 7.0.0-rc3-g0257f64bdac7 #1 PREEMPT(lazy) > [ 151.415758] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014 > [ 151.415969] Call Trace: > [ 151.416059] > [ 151.416161] dump_stack_lvl (lib/dump_stack.c:123) > [ 151.416299] print_report (mm/kasan/report.c:379 mm/kasan/report.c:482) > [ 151.416359] ? __virt_addr_valid (./include/linux/mmzone.h:2046 ./include/linux/mmzone.h:2198 arch/x86/mm/physaddr.c:54) > [ 151.416412] ? __futex_key_to_node (kernel/futex/core.c:349) > [ 151.416517] ? kasan_complete_mode_report_info (mm/kasan/report_generic.c:182) > [ 151.416583] ? __futex_key_to_node (kernel/futex/core.c:349) > [ 151.416631] kasan_report (mm/kasan/report.c:597) > [ 151.416677] ? __futex_key_to_node (kernel/futex/core.c:349) > [ 151.416732] __asan_load2 (mm/kasan/generic.c:271) > [ 151.416777] __futex_key_to_node (kernel/futex/core.c:349) > [ 151.416822] get_futex_key (kernel/futex/core.c:374 kernel/futex/core.c:386 kernel/futex/core.c:593) > [ 151.416871] ? __pfx_get_futex_key (kernel/futex/core.c:550) > [ 151.416927] futex_wake (kernel/futex/waitwake.c:165) > [ 151.416976] ? __pfx_futex_wake (kernel/futex/waitwake.c:156) > [ 151.417022] ? __pfx___x64_sys_futex_wait (kernel/futex/syscalls.c:398) > [ 151.417081] __x64_sys_futex_wake (kernel/futex/syscalls.c:382 kernel/futex/syscalls.c:366 kernel/futex/syscalls.c:366) > [ 151.417129] x64_sys_call (arch/x86/entry/syscall_64.c:41) > [ 151.417236] do_syscall_64 (arch/x86/entry/syscall_64.c:63 arch/x86/entry/syscall_64.c:94) > [ 151.417342] entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) > [ 151.418312] > > Fix by adding rcu to __mpol_put(). > > change-log: > v2-v1: add rcu to __mpol_put > > Fixes: c042c505210d ("futex: Implement FUTEX2_MPOL") > Reported-by: Hao-Yu Yang > Signed-off-by: Hao-Yu Yang > --- > include/linux/mempolicy.h | 1 + > mm/mempolicy.c | 2 +- > 2 files changed, 2 insertions(+), 1 deletion(-) > > diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h > index 0fe96f3ab3ef..65c732d440d2 100644 > --- a/include/linux/mempolicy.h > +++ b/include/linux/mempolicy.h > @@ -55,6 +55,7 @@ struct mempolicy { > nodemask_t cpuset_mems_allowed; /* relative to these nodes */ > nodemask_t user_nodemask; /* nodemask passed by user */ > } w; > + struct rcu_head rcu; > }; > > /* > diff --git a/mm/mempolicy.c b/mm/mempolicy.c > index 0e5175f1c767..6dc61a3d4a32 100644 > --- a/mm/mempolicy.c > +++ b/mm/mempolicy.c > @@ -487,7 +487,7 @@ void __mpol_put(struct mempolicy *pol) > { > if (!atomic_dec_and_test(&pol->refcnt)) > return; > - kmem_cache_free(policy_cache, pol); > + kfree_rcu(pol, rcu); > } > EXPORT_SYMBOL_FOR_MODULES(__mpol_put, "kvm"); > > -- > 2.34.1 > Hi, I’d like to kindly ask if there’s an update on when this patch might be merged.