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 6B50130FF20; Tue, 31 Mar 2026 17:10:12 +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=1774977012; cv=none; b=TYqbe53SZWGRxBnN3OCMgzNtRvhkhAmWbADXtBtRFE3MPnU481rgN4Bcah9CuHaNNxXG7iKDjdTnBbLxNAVptsS9bADU5bNrzfKwhYCMrYJdoOpyGsEQZa9tml+upiiDF7I9jNCa1LoMFcse2LsGAJ298WSd9IgRRLiVMo6QDWI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774977012; c=relaxed/simple; bh=ahWl1Y0GG/FGBTfvGxQ5qHBa1S2dyz6U+tcVTigvj+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GqTZBhUYS46Tz13/2A8aR7utu408q5TxN8lSLV1b0Jk10I/YZDk+vGtp+5N0vTchW0jGO+opBtlfs3kQ6tHxF2flDN4HvSdbMpIDCeBjAXcDaudjDCr5nmQOj7aWCOHh/g/wKb+wdT3aLT3q/KqxwOhSEcAd5cw0o/reBj9wxTk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dDX5nyH1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="dDX5nyH1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BE950C2BCB1; Tue, 31 Mar 2026 17:10:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774977012; bh=ahWl1Y0GG/FGBTfvGxQ5qHBa1S2dyz6U+tcVTigvj+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dDX5nyH1aTo7/wI0X6ckhgwx55fqKeCE4vmtlsHncmvuPmCLUMyL1oVAJeIV5PZ69 cvvTWtOWKT7nzidleVU8T1/exKXjXZTZnoMWE6I0xqsoFq6+t3nvZFL3V2vbLcZVoI 1QRFAManzYOaqy0YMwqyk5SEK9X3pPMsqGU4cczk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Nicholas Carlini , "Peter Zijlstra (Intel)" , Sasha Levin Subject: [PATCH 6.18 307/309] futex: Require sys_futex_requeue() to have identical flags Date: Tue, 31 Mar 2026 18:23:30 +0200 Message-ID: <20260331161804.863013966@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260331161753.468533260@linuxfoundation.org> References: <20260331161753.468533260@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Zijlstra [ Upstream commit 19f94b39058681dec64a10ebeb6f23fe7fc3f77a ] Nicholas reported that his LLM found it was possible to create a UaF when sys_futex_requeue() is used with different flags. The initial motivation for allowing different flags was the variable sized futex, but since that hasn't been merged (yet), simply mandate the flags are identical, as is the case for the old style sys_futex() requeue operations. Fixes: 0f4b5f972216 ("futex: Add sys_futex_requeue()") Reported-by: Nicholas Carlini Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Sasha Levin --- kernel/futex/syscalls.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/futex/syscalls.c b/kernel/futex/syscalls.c index 880c9bf2f3150..99723189c8cf7 100644 --- a/kernel/futex/syscalls.c +++ b/kernel/futex/syscalls.c @@ -459,6 +459,14 @@ SYSCALL_DEFINE4(futex_requeue, if (ret) return ret; + /* + * For now mandate both flags are identical, like the sys_futex() + * interface has. If/when we merge the variable sized futex support, + * that patch can modify this test to allow a difference in size. + */ + if (futexes[0].w.flags != futexes[1].w.flags) + return -EINVAL; + cmpval = futexes[0].w.val; return futex_requeue(u64_to_user_ptr(futexes[0].w.uaddr), futexes[0].w.flags, -- 2.53.0