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=1796379524; b=1+wUiTCRR0juiO/eqwvgjvSWcDq5RIAgq+OfqApeH2aXAMJGZbgtwZcqN2kBtlah4GKV kOMkdcW8wDkDg1szkRT1vppTPoRIwtdIWe8exxPhGLcDRLe6J1zSJzQRGZOIQcSRiI6BY hmDUfIsT/In0yY9iIliVlaDMq09hGT2zYisxQdnK9wTRUkd7+cjg1ZCbXfgncxTgEhRcN n4rj53UrUMJ/Uk51FFouEeFIwCpst81hHkxmbhVIfHqJ5TXn5zBUJzsCSCECZdb+g/8d9 4lEg6d62iN8WR/Cfs7k390eE9zQ/texQL8SK+5wiB5yKRSN9+efpu+1p94hdsZ8xlBQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379524; 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=r3bFR5CptBWwpb38WIcTorZ/GSs7J1Zg3KFooum23NU=; b=EYpL2oO/0/pV1vwKot4gU16MtT9hPm2dnP1rBwRq33YqqYsxcvIAHCkSIXb0RKxfh2lw 6Dv6IBjNIgL9VB9BWVOOranBDOPT/c4fivH/CveIcaE77pS1F35hMS+fCNwD8H13+eyu3 +61TINKhbpzr2hWehE+/TEeaesUuFduOQM2gsYJXsa8lB6JrWU4IjTUYn5rCF+C/zYOX1 3oj44LyaTmVfhvCR0UzKwMHtx8XvFxltg9+4yrlyhmjaQWagwm4BFR01qrSGSw9Q9ijtT ob8DnVmdj47S2GZX77yN4NBeYELSgVUrXKBRe4Gz8kEVQmkEA6A1lxYblFk1iRrodgA== 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=a2VM+tZB; 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 B43FC606A322; Fri, 4 Dec 2026 10:18:44 +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=a2VM+tZB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CB131F000CE; Fri, 4 Dec 2026 10:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379524; bh=r3bFR5CptBWwpb38WIcTorZ/GSs7J1Zg3KFooum23NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a2VM+tZBw3tJaOvwFjiFDtvourE/LPFOMqeMg/Io5IHS6fAIPAhfDgzXR9wphWKkB s7xD4r74fCWuSnEMAht3wmEcAg7j6vx5u4xlUN8weWIzOmT5eXtTcaa7o+EG9ROSZM TXBIAhpZTYgBXl1l8CNYJ7siFH/MryqWvjqkiJDU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0029/1167] io_uring/sqpoll: ensure task state is TASK_RUNNING when running task_work Date: Fri, 4 Dec 2026 18:50:56 +0900 Message-ID: <20261204100702.802744239@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: stable@vger.kernel.org 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: Jens Axboe Commit 8f7033aa4089fbaf7a33995f0f2ee6c9d7b9ca1b upstream. When the sqpoll is exiting and cancels pending work items, it may need to run task_work. If this happens from within io_uring_cancel_generic(), then it may be under waiting for the io_uring_task waitqueue. This results in the below splat from the scheduler, as the ring mutex may be attempted grabbed while in a TASK_INTERRUPTIBLE state. Ensure that the task state is set appropriately for that, just like what is done for the other cases in io_run_task_work(). do not call blocking ops when !TASK_RUNNING; state=1 set at [<0000000029387fd2>] prepare_to_wait+0x88/0x2fc WARNING: CPU: 6 PID: 59939 at kernel/sched/core.c:8561 __might_sleep+0xf4/0x140 Modules linked in: CPU: 6 UID: 0 PID: 59939 Comm: iou-sqp-59938 Not tainted 6.12.0-rc3-00113-g8d020023b155 #7456 Hardware name: linux,dummy-virt (DT) pstate: 61400005 (nZCv daif +PAN -UAO -TCO +DIT -SSBS BTYPE=--) pc : __might_sleep+0xf4/0x140 lr : __might_sleep+0xf4/0x140 sp : ffff80008c5e7830 x29: ffff80008c5e7830 x28: ffff0000d93088c0 x27: ffff60001c2d7230 x26: dfff800000000000 x25: ffff0000e16b9180 x24: ffff80008c5e7a50 x23: 1ffff000118bcf4a x22: ffff0000e16b9180 x21: ffff0000e16b9180 x20: 000000000000011b x19: ffff80008310fac0 x18: 1ffff000118bcd90 x17: 30303c5b20746120 x16: 74657320313d6574 x15: 0720072007200720 x14: 0720072007200720 x13: 0720072007200720 x12: ffff600036c64f0b x11: 1fffe00036c64f0a x10: ffff600036c64f0a x9 : dfff800000000000 x8 : 00009fffc939b0f6 x7 : ffff0001b6327853 x6 : 0000000000000001 x5 : ffff0001b6327850 x4 : ffff600036c64f0b x3 : ffff8000803c35bc x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff0000e16b9180 Call trace: __might_sleep+0xf4/0x140 mutex_lock+0x84/0x124 io_handle_tw_list+0xf4/0x260 tctx_task_work_run+0x94/0x340 io_run_task_work+0x1ec/0x3c0 io_uring_cancel_generic+0x364/0x524 io_sq_thread+0x820/0x124c ret_from_fork+0x10/0x20 Cc: stable@vger.kernel.org Fixes: af5d68f8892f ("io_uring/sqpoll: manage task_work privately") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- io_uring/io_uring.h | 1 + 1 file changed, 1 insertion(+) diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 0d749588ab21b..cdb35cb651dac 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -361,6 +361,7 @@ static inline int io_run_task_work(void) if (current->io_uring) { unsigned int count = 0; + __set_current_state(TASK_RUNNING); tctx_task_work_run(current->io_uring, UINT_MAX, &count); if (count) ret = true; -- 2.53.0