From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A9AB11E8332 for ; Sun, 22 Feb 2026 15:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771773837; cv=none; b=mhRNkRLxUExP4rY0WqTbSBpPjBUbvDKLDBhEyGTsVUmt9Y83ujx2+HvX6TPIA3stNg97tYNIVwqjYWvtNAwULsGP0VCmSwg0AzZqSPS07dnLFTFMUcOeeTCOL+aLhckxBtr/fR26yp2FJiuCV27yNUKSpNNKJtLV5nth4FwKKAw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771773837; c=relaxed/simple; bh=DyN/q06n4Yc+2+RLkc51OvEuYKHE1gLnin1jidJQJX0=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=Nlc8DjSfE0Dzn7FPXgWz/UvDYNSYBVncPxjG8PIR+YBJhnC7U4EHDNFrIeH8hSGqsA1of3XErc3qpskuDnDEobsmOp+WoHZ1q80emjR+CKsiyIbzxpi26yRCIB4a4W8ayZopYMgNy7QuyI4oGbpU9uf7qs4ES7ORcJbT7yeA+F0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=TlRSPfxB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="TlRSPfxB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1771773835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=M9L0kIQamF7TzMCess9eBUfjpSSokSnnIsU2A3olgvE=; b=TlRSPfxBvrSpjmPlNEZ0VAAPnMLJRA7YQRmFXEl01qd3iuBTmrS+4oMnda9o+wjPwhHAAT QEiDso0bE9KkGXVOn6O74NIJKl2BUWhcJeMsmTtcYEHhFRq6Is6gqx1O4FX2uKWMB0DBBO 41vqbhm+E0QyrctL3Ij04xGToUOwnKE= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-693-j6BbPGVBN7K_mqKwn-Esqg-1; Sun, 22 Feb 2026 10:23:52 -0500 X-MC-Unique: j6BbPGVBN7K_mqKwn-Esqg-1 X-Mimecast-MFC-AGG-ID: j6BbPGVBN7K_mqKwn-Esqg_1771773831 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 046E81956088; Sun, 22 Feb 2026 15:23:51 +0000 (UTC) Received: from fedora (unknown [10.44.32.38]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 37FC419560A7; Sun, 22 Feb 2026 15:23:48 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Sun, 22 Feb 2026 16:23:50 +0100 (CET) Date: Sun, 22 Feb 2026 16:23:47 +0100 From: Oleg Nesterov To: Andrew Morton Cc: Christian Brauner , Mateusz Guzik , linux-kernel@vger.kernel.org Subject: [PATCH] do_notify_parent: sanitize the valid_signal() checks Message-ID: 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=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 The "sig" argument of do_notify_parent() must always be valid and it does WARN_ON_ONCE(sig == -1) at the start. The 2nd valid_signal() check before __send_signal_locked() must always be true or we have a bug. This is confusing. Change do_notify_parent() to WARN and return early if valid_signal(sig) is false. Signed-off-by: Oleg Nesterov --- kernel/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/signal.c b/kernel/signal.c index ca23059a947d..a56a4413699b 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -2173,7 +2173,8 @@ bool do_notify_parent(struct task_struct *tsk, int sig) bool autoreap = false; u64 utime, stime; - WARN_ON_ONCE(sig == -1); + if (WARN_ON_ONCE(!valid_signal(sig))) + return false; /* do_notify_parent_cldstop should have been called instead. */ WARN_ON_ONCE(task_is_stopped_or_traced(tsk)); @@ -2254,7 +2255,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig) * Send with __send_signal as si_pid and si_uid are in the * parent's namespaces. */ - if (valid_signal(sig) && sig) + if (sig) __send_signal_locked(sig, &info, tsk->parent, PIDTYPE_TGID, false); __wake_up_parent(tsk, tsk->parent); spin_unlock_irqrestore(&psig->siglock, flags); -- 2.52.0