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 9412136999B; Fri, 17 Oct 2025 15:19:41 +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=1760714381; cv=none; b=CWsR2LmdvlgZ/XHFJvfr+FRJaSH50GrRCEsRqsWITiBiqAj9089rZEYUHeSB6LU93gYy4pznhP/W63+VyRPXP2p5NfkjR2LjCY8QPMEfqylN88AU48FG+/Vn/HdHzvU4wgHQkzSUFuK1SOGw1LlXodz9mHjqPrwCUpbrPkuhEJ8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760714381; c=relaxed/simple; bh=459XRJ9mMy02BKe/1n7MR4p1B0CSo9Ze00MlnLCUxN0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G1jWG54l4n8gMZJs+wlGE6YXAFkIXpyxfW+FwnlhYSeAR8uDqgXSQQnNFe9IpPsnqdacOyAxTh4dAa+hR336hyK52910jl9KnUnVbLCa6/nYmHXv8yecgaLYqyipsB/AnHjPZdAanrSwQMPAkSiv72yMBU3b+96knKhZHz3aZRg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=dF5Dq8Bm; 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="dF5Dq8Bm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F619C4CEE7; Fri, 17 Oct 2025 15:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760714381; bh=459XRJ9mMy02BKe/1n7MR4p1B0CSo9Ze00MlnLCUxN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dF5Dq8Bmagw+ifNeJLg5WHIOmFk3nR5ALcFje+ejiUEjGs+nCZ7Uca5rmyIVk0bjx HftMsH57xJ4VKMwR1AuNFvLLkCG7ThzSMH/eet73PcsvozWgBlji7a84qYKsyxOWrp tX50w3gwImFOmO4BkT++pGF28VhF70WmeqOeUy5g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Simon Schuster , David Hildenbrand , Lorenzo Stoakes , Arnd Bergmann , Christian Brauner Subject: [PATCH 6.12 125/277] copy_sighand: Handle architectures where sizeof(unsigned long) < sizeof(u64) Date: Fri, 17 Oct 2025 16:52:12 +0200 Message-ID: <20251017145151.690032768@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251017145147.138822285@linuxfoundation.org> References: <20251017145147.138822285@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Simon Schuster commit 04ff48239f46e8b493571e260bd0e6c3a6400371 upstream. With the introduction of clone3 in commit 7f192e3cd316 ("fork: add clone3") the effective bit width of clone_flags on all architectures was increased from 32-bit to 64-bit. However, the signature of the copy_* helper functions (e.g., copy_sighand) used by copy_process was not adapted. As such, they truncate the flags on any 32-bit architectures that supports clone3 (arc, arm, csky, m68k, microblaze, mips32, openrisc, parisc32, powerpc32, riscv32, x86-32 and xtensa). For copy_sighand with CLONE_CLEAR_SIGHAND being an actual u64 constant, this triggers an observable bug in kernel selftest clone3_clear_sighand: if (clone_flags & CLONE_CLEAR_SIGHAND) in function copy_sighand within fork.c will always fail given: unsigned long /* == uint32_t */ clone_flags #define CLONE_CLEAR_SIGHAND 0x100000000ULL This commit fixes the bug by always passing clone_flags to copy_sighand via their declared u64 type, invariant of architecture-dependent integer sizes. Fixes: b612e5df4587 ("clone3: add CLONE_CLEAR_SIGHAND") Cc: stable@vger.kernel.org # linux-5.5+ Signed-off-by: Simon Schuster Link: https://lore.kernel.org/20250901-nios2-implement-clone3-v2-1-53fcf5577d57@siemens-energy.com Acked-by: David Hildenbrand Reviewed-by: Lorenzo Stoakes Reviewed-by: Arnd Bergmann Signed-off-by: Christian Brauner Signed-off-by: Greg Kroah-Hartman --- kernel/fork.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/fork.c +++ b/kernel/fork.c @@ -1807,7 +1807,7 @@ static int copy_files(unsigned long clon return 0; } -static int copy_sighand(unsigned long clone_flags, struct task_struct *tsk) +static int copy_sighand(u64 clone_flags, struct task_struct *tsk) { struct sighand_struct *sig;