From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793210361; b=M1KDVskDT/7coGHpkqJhb9YpPMzj8CP/hOf92n00H5cfBOHQ/6eXMGTh/3txwciQBb0d EYpCz3lt3k+/eZmrx48suCaVV5B6tcAUNAfJQA2+sxuIk2eTgN4TPR9PRYceQizi4gdOO M71u2fmfCJNNLnG/lKddGGWSfXstv2HRwPkgORJJlKjVGJXKIa8JkzR0QNmAA7prm9xpO IEqwGtAmQzgKWECA1aZnJgpnHxyK96HuX1RXRrfnfU4mID7LKkVcWoSBg/UQ5Mfl8IHaZ kdZrW7L95OU8xA/EzB02nTMScn2jGjBLba3DRPpbvT8KpWyDAJecMDOLXmtPt0VgXrg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793210361; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=fHmk9IhjDzNGFRQONKeygSRypZO1N4L0Qan3VyXPt+o=; b=eTV+b73YfkP7ZL2aOfX+C+2pWU8rAoGKoAKYMrPvaa803Ntl9jySpJ6VHPuz/SlU6mfC i9lCyPJ1MpYlT7Y1zC2FDLQ41kRyCYmc+cfSpvId1+nA5dVjvWK6tcuNJwC7Dqj0H2fZn zXbdYhhL1oBcLXI39lojY5PTgppz7n+PcxUi6FOADxNZo9mk/rIIKvd21aDG+FbYH2O4e DmpfagdvdUUA4HdLErC3k/z5npkVCWYZfn7vN4isegSHLjAAqNYmA5tU5/1v6jL9uRWba D/JPSlrhEhCwQjrpp5OTJ7YLaPGXzGQuEvB2wCbpxOhgyU5CoxnU937uOhR83fnZH7g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=F+Wz5a6d; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF4FC606A31C; Wed, 28 Oct 2026 17:59:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=F+Wz5a6d Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BF151F01825; Wed, 28 Oct 2026 17:59:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793210360; bh=fHmk9IhjDzNGFRQONKeygSRypZO1N4L0Qan3VyXPt+o=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F+Wz5a6dVUNA74UWVA+4XvUADNjuVuv9kSnwZFO679gpSopT5yKQA1zV+omYoN06l vKjglrXuAlGQfweaC4SLKNrjhSiwfIXe1h+0jeM4PjFkcbLawm3BFcpbVTm1IuHI8c i1wXLTXvDe2jDCzQldFTxaBr6tyoKo4kNuh1nzlE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oleg Nesterov , "Christian Brauner (Amutable)" Subject: [PATCH 6.6 168/168] signal: allow taks to temporarily block TIF_NOTIFY_SIGNAL Date: Wed, 28 Oct 2026 18:01:44 +0100 Message-ID: <20261028165947.064021119@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028165943.089486480@linuxfoundation.org> References: <20261028165943.089486480@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Christian Brauner commit 22b7f491be8f93ff72de0a3fe02b8ee9e64d3f21 upstream. TIF_NOTIFY_SIGNAL is used to kick a task in uninterruptible sleep to return to userspace and run task work and then go back to sleep. This mechanism works well but breaks e.g., coredumps. dump_interrupted() only allows fatal signals to interrupt a coredump and the whole regular write path going to actual filesystems is impervious to TIF_NOTIFY_SIGNAL as well. Add PF_NO_NOTIFY_SIGNAL and helpers to raise and restore it. This is the same approach as memalloc_nofs_save(). signal_pending() will not report a fake pending signal via TIF_NOTIFY_SIGNAL if inside a PF_NO_NOTIFY_SIGNAL section. No functional changes. Link: https://patch.msgid.link/20260824-work-tif_notify_signal-v2-1-6609e42b3157@kernel.org Reviewed-by: Oleg Nesterov Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) Signed-off-by: Greg Kroah-Hartman --- include/linux/sched.h | 2 +- include/linux/sched/signal.h | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -1768,7 +1768,7 @@ extern struct pid __rcu *cad_pid; * I am cleaning dirty pages from some other bdi. */ #define PF_KTHREAD 0x00200000 /* I am a kernel thread */ #define PF_RANDOMIZE 0x00400000 /* Randomize virtual address space */ -#define PF__HOLE__00800000 0x00800000 +#define PF_NO_NOTIFY_SIGNAL 0x00800000 /* see no_notify_signal_save() */ #define PF__HOLE__01000000 0x01000000 #define PF__HOLE__02000000 0x02000000 #define PF_NO_SETAFFINITY 0x04000000 /* Userland is not allowed to meddle with cpus_mask */ --- a/include/linux/sched/signal.h +++ b/include/linux/sched/signal.h @@ -2,6 +2,7 @@ #ifndef _LINUX_SCHED_SIGNAL_H #define _LINUX_SCHED_SIGNAL_H +#include #include #include #include @@ -389,14 +390,36 @@ static inline int task_sigpending(struct return unlikely(test_tsk_thread_flag(p,TIF_SIGPENDING)); } +/* Prevent TIF_NOTIFY_SIGNAL from interrupting this task. */ +static inline unsigned int no_notify_signal_save(void) +{ + unsigned int flags = current->flags; + + current->flags |= PF_NO_NOTIFY_SIGNAL; + return flags; +} + +/* Restore the previous PF_NO_NOTIFY_SIGNAL state. */ +static inline void no_notify_signal_restore(unsigned int flags) +{ + current_restore_flags(flags, PF_NO_NOTIFY_SIGNAL); +} + +DEFINE_LOCK_GUARD_0(no_notify_signal, + _T->flags = no_notify_signal_save(), + no_notify_signal_restore(_T->flags), + unsigned int flags) + static inline int signal_pending(struct task_struct *p) { /* * TIF_NOTIFY_SIGNAL isn't really a signal, but it requires the same * behavior in terms of ensuring that we break out of wait loops - * so that notify signal callbacks can be processed. + * so that notify signal callbacks can be processed. Not for a task + * that asked not to be interrupted by it, see no_notify_signal_save(). */ - if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL))) + if (unlikely(test_tsk_thread_flag(p, TIF_NOTIFY_SIGNAL)) && + likely(!(READ_ONCE(p->flags) & PF_NO_NOTIFY_SIGNAL))) return 1; return task_sigpending(p); }