From nobody Tue Apr 7 04:19:58 2026 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 EEF7C23909F for ; Mon, 16 Mar 2026 10:45:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773657950; cv=none; b=b7lXR9py4EWKpYMKVmT9u2RG0yDEKwSfBuRsE6te6aQ2IrnNQBR6O5P5yOUtNQrPa7sS+Gh4xsMEnq53Oy8hf+wsQvbIfXvhHgTQrReT9eCTQ0hEge7Djo/NliDc09coldid4X6Dd0upHI6ijAOzIk6gnOtDkqnv03OKo6Rn1g4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773657950; c=relaxed/simple; bh=Yx+lv/MD45WanGEQqcRGTXf8qbxS8bUlvpFYF6cE2WY=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Co4Hqh3xm6DdCFYTM4sroWpb0Puqpgc7vkZadNqPCI8XBWaQoOaeMhPLZGZu1N7yXkEY6XQRvktOslOho1EdZDMLltmjFm5Gb2xcgcJe+RzY2rz9EGVsDT0M+kbkgh/YFZ0Mw5xwEcqnTvy8wxJ5chE2101u7azlwaHjGJudaCo= 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=M14ykTmP; arc=none smtp.client-ip=209.85.215.175 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="M14ykTmP" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-c70e27e2b74so1509950a12.0 for ; Mon, 16 Mar 2026 03:45:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773657948; x=1774262748; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ubW1SAZoUmH0bsB9ImpSqRcmDeexO/GRoosaLSx4hpI=; b=M14ykTmPfL6iO2Qeqzah/fMt8tC0weBJTabPGuQ/2Vuk3YNLd9Wu9gJnwMt948k7IB G0ARZBjIavQmWb1Zz/pCkvpRaB1pbzLVJDdpmBTKIimL0ERLplmqBptXVfcDnt0XNBsf GW1g7QwlhhMHhDMPE07eAzdeFItC+gAykG3aB0lGJaXm7igNk1UeQapWTkFIFzNkYjfV oF0L6z6aIRPqudskFlXCJpbCfXIukBe5FdhA0xAUkD38AjZXFB8w/FNFFU/q3PariONI SUWk+H7gYJ41hPsATByoZrj4iQOdXlW1qk+Or5mTMNYsxoQFSuVFvMVTHF9OBDmQTrLz UUFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773657948; x=1774262748; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ubW1SAZoUmH0bsB9ImpSqRcmDeexO/GRoosaLSx4hpI=; b=MUx8MG94cDTwxUOcedphGbLEIel40CmmuOR6N8KE8/fEey4QAdaMDZCns1eFYp1Hra 8G6M4dW6t8SKHnup13EtsQU48PoiO2Y69SUhlNRFTi/A53hS7+cdouWw647Fklos0Z+b /DEADdHQ5e2SxVhPao01Mz+Kqq7PD0LkY1Z2bMwjX2L6w/HxYcPCYAC1nW/oW5PhA0Xh oRhmgIf9Aky/EbNWDO/dxv7xeOcEP6YRiTRFL46/zpK79FANDLCz0NYf1UmpFlwvLyZR rR1LoSGiBecEriIh3/earNSDS6QMp6O8cMkmTTdMoEQxKAGt/pAHHhjmLpusdssch1ke hjrg== X-Gm-Message-State: AOJu0Ywsf6vf7eaMfpezzfK2iZ48RKe6DCaNOj00cJ2vu9El1xc4WAbg 88cLxAiLgGyg7Sjl+kqxAuSNpHyQjHw/IcqVRNDsPrUiil807KwR5m2Z X-Gm-Gg: ATEYQzz2eSa92AyXb2Q3Kwz10ibbFYxzD1zDlyidGOKj9s+GMGARLEloePSW/bgEStb YVt98ugBMNQONEGTYu8atq0uRfDy86jDIjsxCCPnpHZ8pdjHaV5ZRBtf64Efueuqd3RZ6JXNH2c awVFMDyWDpcQRiGE+5biYlKAQh/cy3XWY0gS60PEyg5LZajzG5di1xXeBU8Twk4iIu0ZjCs9d+a gmE+1bzV3C7RMoe/xQx6fZdAQdsmjfi2UbkF0P3Nc76VdeS0AUVOf223k0AtADYAUW0/vij6n7A 4Z1L1cY0IIHsb3GPoPV1ArqytzjdC8x+tMsvFi160FlZEUxXoLAiZmFHwnTyXS/sLv/y0lWS4WD B1jJt9D4Q4zJFo0R25VpattFLXONDyq4PCpYN6ygdP5Be1Jnzi/CU6bQRNh77d3S7jlqjuI/65C 3TvYMOv1zAAORKdB5r9vrsotoP53U1rxpFlHAESAQRE2fZwPTQa0slnOXUlvFJ5WvRuHIYk7F8k HsGD8M= X-Received: by 2002:a17:902:e543:b0:2ae:606b:bd98 with SMTP id d9443c01a7336-2aecaad0c39mr127425815ad.26.1773657948057; Mon, 16 Mar 2026 03:45:48 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:e19b:34e3:1bbe:df72]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2aece56c23esm133669075ad.1.2026.03.16.03.45.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 03:45:47 -0700 (PDT) From: Deepanshu Kartikey To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, kees@kernel.org, akpm@linux-foundation.org, david@kernel.org, ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org, rppt@kernel.org, surenb@google.com, mhocko@suse.com, brauner@kernel.org, oleg@redhat.com, dietmar.eggemann@arm.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Deepanshu Kartikey , syzbot+bbe6b99feefc3a0842de@syzkaller.appspotmail.com, Deepanshu Kartikey Subject: [PATCH v2] kernel/fork: validate exit_signal in kernel_clone() Date: Mon, 16 Mar 2026 16:15:36 +0530 Message-ID: <20260316104536.558108-1-kartikey406@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a child process exits, it sends exit_signal to its parent via do_notify_parent(). The clone() syscall constructs exit_signal as: (lower_32_bits(clone_flags) & CSIGNAL) CSIGNAL is 0xff, so values in the range 65-255 are possible. However, valid_signal() only accepts signals up to _NSIG (64 on x86_64), causing a WARN_ON in do_notify_parent() when the process exits: WARNING: kernel/signal.c:2174 do_notify_parent+0xc7e/0xd70 The syzkaller reproducer triggers this by calling clone() with flags=3D0x80, resulting in exit_signal =3D (0x80 & CSIGNAL) =3D 128, which exceeds _NSIG and is not a valid signal. The v1 of this patch added the check only in the clone() syscall handler, which is incomplete. kernel_clone() has other callers such as sys_ia32_clone() which would remain unprotected. Move the check to kernel_clone() to cover all callers. clone3() already validates exit_signal in copy_clone_args_from_user(). The comment above kernel_clone() states that callers are expected to validate exit_signal, but several callers never did. Adding the check to kernel_clone() enforces this for all callers centrally. Note that this is a user-visible change: previously, passing an invalid exit_signal to clone() was silently accepted. The man page for clone() does not document any defined behavior for invalid exit_signal values, so rejecting them with -EINVAL is the correct behavior. It is unlikely that any sane application relies on passing an invalid exit_signal. Reported-by: syzbot+bbe6b99feefc3a0842de@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=3Dbbe6b99feefc3a0842de Tested-by: syzbot+bbe6b99feefc3a0842de@syzkaller.appspotmail.com Link: https://lore.kernel.org/all/20260307064202.353405-1-kartikey406@gmail= .com/T/ [v1] Fixes: 3f2c788a1314 ("fork: prevent accidental access to clone3 features") Signed-off-by: Deepanshu Kartikey --- kernel/fork.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/fork.c b/kernel/fork.c index 947a8dbce06a..89d7eb67baf5 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2687,6 +2687,8 @@ pid_t kernel_clone(struct kernel_clone_args *args) (args->pidfd =3D=3D args->parent_tid)) return -EINVAL; =20 + if (!valid_signal(args->exit_signal)) + return -EINVAL; /* * Determine whether and which event to report to ptracer. When * called from kernel_thread or CLONE_UNTRACED is explicitly --=20 2.43.0