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 13D3428CF6F for ; Fri, 19 Jun 2026 14:03:22 +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=1781877804; cv=none; b=FsehK84+0C7lm3LRsuTMjFpS7FEfoxnBGpwFAf0BBwnw9HYC94uOk9WFldYTV4g8I9ppPN9/nMaH2UkHBNUaErP6wYm3URD0/g3XfFZKJvaPm5VETkRf41PyC1BdW5k2cQTLVxm0MLTnHlbYJTxJWrvIFIgdV4hE/X7xDKt6PoA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781877804; c=relaxed/simple; bh=hi720SOjNMqZAfbk6PAQ+05T5pKF39tbt9W4zea7Cxw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Rc1xELXBlXsoRUU9RtCoNfV0VbbeCq+jJCsACYGdeL5uns+4/yPnSKMG7efoJWp5o20H2gYXAxuYEn4yKV58u0urxsdAMYxw21wUWKVwMZHX8ownIykPZQDluIxjy57UvgJGPdDZv4w+eJ8hU/Edr0CoQwO3dcy8/K/yW3fuhhg= 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=PjD6qjkf; 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="PjD6qjkf" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781877802; 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: in-reply-to:in-reply-to:references:references; bh=gTWlObZIKVVnnVTmmWbmsMewcq7XfNONPw+/ZJWcgRM=; b=PjD6qjkfjFt/BZpN/I7yyaHBga7O8hKNLYEfvEgjPkaoMCvlcHXixwUWPqsEp+z34/Grpy k5ptNd2PTutKW/CzLg4S6ewxYC/y879YN1cm4XC8cpbvaKx37VWG2g2f0hpQmCWn03smkP tA5YacbiZcXrqGpXUaLm1oN9fRfioyo= Received: from mx-prod-mc-01.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-459-YXvW-4zRO52wkKADgvpE3w-1; Fri, 19 Jun 2026 10:03:18 -0400 X-MC-Unique: YXvW-4zRO52wkKADgvpE3w-1 X-Mimecast-MFC-AGG-ID: YXvW-4zRO52wkKADgvpE3w_1781877797 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-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 37832195DBAC; Fri, 19 Jun 2026 14:03:17 +0000 (UTC) Received: from fedora (unknown [10.44.34.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 7799A195608C; Fri, 19 Jun 2026 14:03:14 +0000 (UTC) Received: by fedora (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Fri, 19 Jun 2026 16:03:16 +0200 (CEST) Date: Fri, 19 Jun 2026 16:03:12 +0200 From: Oleg Nesterov To: Andrew Morton , Kees Cook , Christian Brauner Cc: Kusaram Devineni , Jens Axboe , linux-kernel@vger.kernel.org, io-uring@vger.kernel.org Subject: Re: [PATCH v2] signalfd: don't dequeue the forced fatal signals Message-ID: References: <202604052136.440E9CFA44@keescook> Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 It seems that this fix is going to be lost ;) Can anyone pick it up? Oleg. On 04/06, Oleg Nesterov wrote: > > These signals should act like SIGKILL, in that userspace must never dequeue > them. But as Kusaram explains, io_uring-driven signalfd_read_iter() called > from get_signal() -> task_work_run() paths can do this before get_signal() > has a chance to dequeue such a signal and notice SA_IMMUTABLE. > > Change signalfd_poll() and signalfd_dequeue() to add pending SA_IMMUTABLE > signals to ctx->sigmask. > > TODO: we should probably change force_sig_info_to_task(HANDLER_EXIT) to > make fatal_signal_pending() true, or add a fatal_or_forced_signal_pending() > helper. Then signalfd_dequeue() could just return -EINTR in this case. > This also makes sense for get_signal(), which could prioritize a fatal > signal sent by (say) force_sig_seccomp(force_coredump => true), just like > it already prioritizes SIGKILL. > > Cc: stable@kernel.org > Reported-by: syzbot+0a4c46806941297fecb9@syzkaller.appspotmail.com > Closes: https://syzkaller.appspot.com/bug?extid=0a4c46806941297fecb9 > Tested-by: syzbot+0a4c46806941297fecb9@syzkaller.appspotmail.com > Link: https://lore.kernel.org/all/69d122fd.050a0220.2dbe29.001c.GAE@google.com/ > Suggested-by: Kusaram Devineni > Signed-off-by: Oleg Nesterov > Reviewed-by: Kees Cook > --- > fs/signalfd.c | 28 ++++++++++++++++++++++------ > 1 file changed, 22 insertions(+), 6 deletions(-) > > diff --git a/fs/signalfd.c b/fs/signalfd.c > index dff53745e352..22bc0870a824 100644 > --- a/fs/signalfd.c > +++ b/fs/signalfd.c > @@ -48,17 +48,30 @@ static int signalfd_release(struct inode *inode, struct file *file) > return 0; > } > > +static void refine_sigmask(struct signalfd_ctx *ctx, sigset_t *sigmask) > +{ > + struct k_sigaction *k = current->sighand->action; > + int n; > + > + *sigmask = ctx->sigmask; > + for (n = 1; n <= _NSIG; ++n, ++k) { > + if (k->sa.sa_flags & SA_IMMUTABLE) > + sigaddset(sigmask, n); > + } > +} > + > static __poll_t signalfd_poll(struct file *file, poll_table *wait) > { > struct signalfd_ctx *ctx = file->private_data; > __poll_t events = 0; > + sigset_t sigmask; > > poll_wait(file, ¤t->sighand->signalfd_wqh, wait); > > spin_lock_irq(¤t->sighand->siglock); > - if (next_signal(¤t->pending, &ctx->sigmask) || > - next_signal(¤t->signal->shared_pending, > - &ctx->sigmask)) > + refine_sigmask(ctx, &sigmask); > + if (next_signal(¤t->pending, &sigmask) || > + next_signal(¤t->signal->shared_pending, &sigmask)) > events |= EPOLLIN; > spin_unlock_irq(¤t->sighand->siglock); > > @@ -155,11 +168,13 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info > int nonblock) > { > enum pid_type type; > - ssize_t ret; > DECLARE_WAITQUEUE(wait, current); > + sigset_t sigmask; > + ssize_t ret; > > spin_lock_irq(¤t->sighand->siglock); > - ret = dequeue_signal(&ctx->sigmask, info, &type); > + refine_sigmask(ctx, &sigmask); > + ret = dequeue_signal(&sigmask, info, &type); > switch (ret) { > case 0: > if (!nonblock) > @@ -174,7 +189,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info > add_wait_queue(¤t->sighand->signalfd_wqh, &wait); > for (;;) { > set_current_state(TASK_INTERRUPTIBLE); > - ret = dequeue_signal(&ctx->sigmask, info, &type); > + ret = dequeue_signal(&sigmask, info, &type); > if (ret != 0) > break; > if (signal_pending(current)) { > @@ -184,6 +199,7 @@ static ssize_t signalfd_dequeue(struct signalfd_ctx *ctx, kernel_siginfo_t *info > spin_unlock_irq(¤t->sighand->siglock); > schedule(); > spin_lock_irq(¤t->sighand->siglock); > + refine_sigmask(ctx, &sigmask); > } > spin_unlock_irq(¤t->sighand->siglock); > > -- > 2.52.0 >