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=1796384735; b=EvGl/p/EjeynfoiQzsAKo8AGN1srRDu1sb8pZb7zoNN8xBQs05NghM8oM2nCgiwF0RhE kIszPPBIDG23C3yhB3FX3D8+87fNu+xTIXRhkraehcGTelDdq2msJ/wHZ33VMM+DHNPiM D2/gWA946j7+UpcTSQOFHLdi2UG6BYj8BWugonUgM+Q7tKXleHltyFormxMs8dRjctxCP rqr7r6g3x76CXyh0RrBGlQiqX/PRC+zWUqgwfw8Rul7a55vkpHBU4AcAo6OCCgT8A5qnC /BJrdhAGwH/U5VWkwIRubw8lXy4fNJmaTatEPGTZ9AOIY0n2lNm0vJ6js6659jMPCww== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796384735; 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=97h7jsvsTJfK36DLY3nbvccbuUXtmoLgqQfpqLhlT9s=; b=pdoeAA486GT7GhOOKWUNKYm7MT5SWDhLfwuD6nxoL6DXvIgpSDOE/qbphsL4wJrKxsX1 /k3DtJwWOpJcRORsms9cym9m+3clnER0sdkDrgoCnNsbINK/u3TY7M2S7reUS8qnqFIni kej/bhAba0/u9xnJcPNiUEPi8i+Uz9VoOShzk5fe+fEERSx7VhTUwhkdoxhJRi+8AemBD IoOw6VEfW+4zQcOS1v22XWleyiEG+vm5FKtEGZjhV65aXqUrLnct7nRVMK65zjze1H6KS OIAH8y62a5zkMRbwpfH7jSZQdWN+41Qd2PZUOJEezDq5a/4YmKzaAA1sFz0/o/Nmw2Q== 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=USAi+4Cb; 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 CF603606A322; Fri, 4 Dec 2026 11:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=USAi+4Cb Received: by smtp.kernel.org (Postfix) with ESMTPSA id E05301F000CE; Fri, 4 Dec 2026 11:45:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796384735; bh=97h7jsvsTJfK36DLY3nbvccbuUXtmoLgqQfpqLhlT9s=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=USAi+4CbPAWCngHa3U8KQF/TDasJRwHYBhq2Dq0n0kM7EqzB5C8LvbBm9/XPE0+z0 ylLlHJumdU1MBbWuOLNdAMZPUiaJyfXYBS34Bv46wDv7ADSAB1VVI2N/K7peYfHL3E YZwP7CogK0pmuZrnXzKSIvPw5wWRDvfZEnyksmos= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Oleg Nesterov , "Christian Brauner (Amutable)" , Sasha Levin Subject: [PATCH 6.6 0270/1167] coredump: prevent TIF_NOTIFY_SIGNAL from interrupting coredumps Date: Fri, 4 Dec 2026 18:54:57 +0900 Message-ID: <20261204100709.091355591@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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 [ Upstream commit a58d647acfdc62561f3570d114025b3bf38ae41b ] 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 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. However, both the usermodehelper pipe and the coredump socket will bail early on TIF_NOTIFY_SIGNAL. This affects the following codepaths: - coredump_sock_recv() -> unix_stream_read_generic() The request/ack handshake is abandoned before any coredump data is sent. - anon_pipe_write() returning -ERESTARTSYS Once the pipe is full this truncates the coredump. - unix_stream_sendmsg() returning -ERESTARTSYS Once the send buffer is full this truncates the coredump. - coredump_sock_wait() -> __kernel_read() This reports a failure that didn't happen. - wait_for_dump_helpers() -> wait_event_interruptible() This stops waiting for the coredump helpers. Such truncation is entirely invisible to userspace and all uapi bits still indicate that a successful coredump happened. A crashing process with a bunch of file backed mappings and io_uring thrown in loses most of the coredump data. If the NT_FILE note goes past PAGE_SIZE mappings it's gonzo. TIF_NOTIFY_SIGNAL is sent by io_uring for the common case. And it uses poll without sleeping so a completion callback runs task_work_add() from interrupt context against the task that submitted the request. This is the task that is running the coredump. Since that task hasn't set work_exited (it hasn't exited yet after all) TIF_NOTIFY_SIGNAL keeps reappearing. A coredumping task doesn't return to userspace. The task work is run at exit. So interrupting it doesn't buy anything and just loses the coredump which is quite valuable. Note that this isn't specific to io_uring. There's also klp_send_signals(), bpf_task_work_schedule_signal(), landlock's tsync and then technically, kthread_stop() and the printk kunit test set the bit raw. Link: https://patch.msgid.link/20260824-work-tif_notify_signal-v2-2-6609e42b3157@kernel.org Fixes: 12db8b690010 ("entry: Add support for TIF_NOTIFY_SIGNAL") Reviewed-by: Oleg Nesterov Cc: stable@vger.kernel.org Signed-off-by: Christian Brauner (Amutable) [ sashal: Moved the guard to the top of do_coredump() (before any goto) instead of after coredump_wait(), since the monolithic function has gotos that would otherwise bypass it under clang. ] Signed-off-by: Sasha Levin --- fs/coredump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/coredump.c b/fs/coredump.c index 326b30421eec3..b6e9e7913bb31 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -615,6 +615,9 @@ void do_coredump(const kernel_siginfo_t *siginfo) .cpu = raw_smp_processor_id(), }; + /* Task work must not cut the dump short, see signal_pending(). */ + guard(no_notify_signal)(); + audit_core_dumps(siginfo->si_signo); binfmt = mm->binfmt; -- 2.53.0