From nobody Tue Apr 7 03:13:15 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 D091C2F547F for ; Mon, 16 Mar 2026 15:20:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773674411; cv=none; b=sJS89qD9Q5Szq/aVbd4T/vvZDnMSQ7Z+uYeIQG6HgCEbEp3ICQjcfYTO1c73kW7H8QX3F2SnyDCmHImNUofofMGQdN2tahqXp+12E+uD505ZJDZOtwXs0bPwB2SuO9nQXyGuGNyCW9Nda5XEb4DhPslsTuYZrKBA2zFuz5lz+wo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773674411; c=relaxed/simple; bh=nnHfC0I+Yayv+ytVyHEPG85R7CUHATohWO9RKrXk1Zk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=IWThoA3JcvH6cCvJIwItrEh49bpFfJHWXBZtg7eCZt4chZTqyEmDrHDs7Z2zd3QMFtCtwgrCNLuf7BGqMmrqQEv5RGocz+T1hXntEDdpyQjsBtfCe1yXUk1CAYS6/FknZo4BDmH8QTcOrTlSQePEIvgzKezbtuBog4lDK3XUeeU= 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=HAWRvQlJ; arc=none smtp.client-ip=209.85.216.41 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="HAWRvQlJ" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-35a1230c60eso2429601a91.3 for ; Mon, 16 Mar 2026 08:20:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773674409; x=1774279209; 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=W09BwawQXBw7qZlw0AhGoZ1ZZiQnOnbL7dJOy6IZMDo=; b=HAWRvQlJa9MpUhe12woW8fMzzviZXpLGhJnOFh2RlarEDIM0sPeRkFxeOeCtRHBsnL zwqpvtu4Gkt2zHV+ADH+/4++fYAAeO/YvCask23dk2CmeLsyFPbhJkEeLolNeW9h1qVm 9PRZt4ADvKzIFaFcU2TCSxmVgLO6xCXEUAG3lIN5Ba+4ak/DQyOI5KpxBkM518Vy1bLy ZLBigK3qOUa5TnnR+iC76SM9tfHVEAZiZorU9fDUWBiPXhkkgV+CnGlD2Bd3rn2cUQ1M zO4X2zLt05I//DWyK7JQ8YCqoKRn9hL9wP5Q/fIQ6YHRRDQltjVWh8JfdFaqNvEj5vz3 BUNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773674409; x=1774279209; 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=W09BwawQXBw7qZlw0AhGoZ1ZZiQnOnbL7dJOy6IZMDo=; b=Z4+OKFomgL6u1Ws46w4xOYyv6teasEdBKk3w3img8Bc5+L9NP46ahd9NuQt18CtIOC LGy6sTxS0ekK/TbGnLn60/Y3VYN7q8O/clpssKs+4YX9QTYk29PvQiJxTGdLDvn8CQqN E9t133IcEo0sOU2datBi8bPWnD0q7BR2yIyGNUcNHB4E3JM5AMxF+m7pYcQUJEHfSLuI tVgm/JVqvVTXtlS476AZIUZ5kRCf0SoQBkig1ZwC78tKoTKhJaOD6Jk1PrghqsEs9HmA w2dj0X6E+8VFAUojftpcSy611YokRMrX/whuAe7Uyyu+P0JQD8nwwD3OzTLFyisVpHvO m5ug== X-Gm-Message-State: AOJu0YxBZgS/07tWtJenRyj1vdhkm0dJ31QIbwfTcOTB3KhkWWt5k5n1 xjNH92j8/Vq9Edje1J3FUISCxtWTAA5+uRgaGiK9FVghG/Z+kB+EVMCl X-Gm-Gg: ATEYQzyvWVcAkacDVSOSpdHH7Lw7K1DFHHqxB6MQ2sho9+5q3hW77KU6uJSp6iPnJ+Q ZS9nUtqcoLIPhIaC9ka/VECIoq7b+UofrF61Te94W8SqPMM6clWiCQLCYxYrSsJugw8UlLvytZS cbRtzok8mk5XyIpOUiVp2UhKDROs2N0yGZyXkyibNB9bl9GzPFFID7NLpzA/g9qLgZhck/Sv0kx lhuYo0zhQqsiD8REjjjJ15/sfmgQlAzSJ4qeSysWImTT0kDQs64WPbPvSNexah9NYDIRxBM0VmW 18/LBXxF7zDQczawN6q5MboNWU84xYXCnS5VZb8FcK+zU8BJZwmuV0nDTq+t609eoYGHD6O1mY/ g/dhHBTaSJnBvBJH1Cwl/76YCHFr5HZuGP25tR93UOGolK+LVYxDHqcRHHOKSZAjq0IMFTS4odF fKp2BXaqFcANve+IlWDOYd483WDFu2IVaeeY0AyDZYFAESFdkTPAqIrGZcOzElViZ+A7N+yypGY iU4aLQ= X-Received: by 2002:a17:90a:d408:b0:35b:a9f3:62ee with SMTP id 98e67ed59e1d1-35ba9f36aa5mr978278a91.27.1773674409030; Mon, 16 Mar 2026 08:20:09 -0700 (PDT) Received: from deepanshu-kernel-hacker.. ([2405:201:682f:389d:52ce:671a:31ef:56a1]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7400000532sm4626033a12.27.2026.03.16.08.20.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 08:20:08 -0700 (PDT) From: Deepanshu Kartikey To: mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, 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 Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Deepanshu Kartikey , syzbot+bbe6b99feefc3a0842de@syzkaller.appspotmail.com, Deepanshu Kartikey Subject: [PATCH v3] kernel/fork: validate exit_signal in kernel_clone() Date: Mon, 16 Mar 2026 20:49:56 +0530 Message-ID: <20260316151956.563558-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). A non-zero non-valid exit_signal acts the same as exit_signal =3D=3D 0: the parent process is not signaled when the child terminates. 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. Since the valid_signal() check is now in kernel_clone() and covers all callers including clone3(), the same check in copy_clone_args_from_user() becomes redundant and is removed. The higher 32bits check for clone3() is kept as it is clone3() specific. 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] Link: https://lore.kernel.org/all/20260316104536.558108-1-kartikey406@gmail= .com/T/ [v2] Fixes: 3f2c788a1314 ("fork: prevent accidental access to clone3 features") Signed-off-by: Deepanshu Kartikey Acked-by: Oleg Nesterov --- v3: - Remove now redundant valid_signal() check from copy_clone_args_from_user() since kernel_clone() now covers all callers including clone3() - Update changelog to remove WARN_ON mention and describe actual bug behavior instead v2: - Move valid_signal() check from clone() syscall handler to kernel_clone() to cover all callers including sys_ia32_clone() - Update changelog to document user-visible behavior change --- kernel/fork.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/fork.c b/kernel/fork.c index 947a8dbce06a..73f7fe958a30 100644 --- a/kernel/fork.c +++ b/kernel/fork.c @@ -2687,6 +2687,9 @@ 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 @@ -2885,11 +2888,9 @@ static noinline int copy_clone_args_from_user(struct= kernel_clone_args *kargs, return -EINVAL; =20 /* - * Verify that higher 32bits of exit_signal are unset and that - * it is a valid signal + * Verify that higher 32bits of exit_signal are unset */ - if (unlikely((args.exit_signal & ~((u64)CSIGNAL)) || - !valid_signal(args.exit_signal))) + if (unlikely(args.exit_signal & ~((u64)CSIGNAL))) return -EINVAL; =20 if ((args.flags & CLONE_INTO_CGROUP) && --=20 2.43.0