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=1796379529; b=rlQNuVm4W9nVKxEZE9qbsf+aR5i9Xl3XsR48jI40gYdDm0xllcVbo7Ijea9qHNVez9h2 gdoJ2np6v1uEXWmPuup9nJP6HHSa3KlPbmLqjSzXAEkSaPr8BGrYmed16gNkEdg2y7x7s Uvf2QiRHA200yWrEG922f825LpC/f1/Mth4iHRBGSXvzyLMuBgItJvLY/PM3dODcDnafZ Cyceg8mNSFwReNMjzjxHKcZD8RiX4jTU42FCkTbfHD+R0+Ham9k+rpxYZ3NEwoNFON8RP Bbe7QZPYgaRHP3CEF0gr+8TmrPCs++stZT3e4jzUFQxBprrVmqDmoTNUyTUWT1IkGfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379529; 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=tGqIjKelLslreO7THkrdALcjqUQy3zmSzAxEDKcrNLk=; b=1Jdlq8zyMmWcn9Y8ay6m/qCvSuDeqE/Ex1GsqzRDYuMaiefWCRre/mHSUbcW0q6kCoEP YJ5RPqQJzK8hZp6gWa1e5lZlNGt0OYcAOHIrvm4uQejYk5E9OzLsBTvyhgkNQHyNS66m5 TFFba+x6CmAbLkBmdVfJrFNYnHNGNKrH+AxbVqW1WaARTXSz9kdPLGCyl3JgG1tg6ow0W ejnNpFp2jd3a/AvEH4iYO9mTUgp/tAwrHdwylcigHUVuEP9s0FEsf2wQRv+oDr0jZugpu d4D+P7BmTyTWdZn67nWglO7C5cBWlN49Cerv+gfb3wF5uCAoPF/d1YnNTDNf0+b5gzg== 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=WOzT9zmI; 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 5FE29606A322; Fri, 4 Dec 2026 10:18:49 +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=WOzT9zmI Received: by smtp.kernel.org (Postfix) with ESMTPSA id C7C261F00931; Fri, 4 Dec 2026 10:18:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379529; bh=tGqIjKelLslreO7THkrdALcjqUQy3zmSzAxEDKcrNLk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WOzT9zmI6CFsyGVH2kOMghx4T4PYm2FkAd8GjHts7tEKUA1uudFGJXAoZviOdURV6 l2elaFgGKVBAeNNVed3CxQmmyOWHB22aNSIqU2E9UQFc/EWGLumORUhZAstLRO7k7C Gw8ozmlSENICeFjzCsHtqhxyLmBuE40YFxh3xwaY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, syzbot+3d92cfcfa84070b0a470@syzkaller.appspotmail.com, Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 6.6 0031/1167] io_uring/sqpoll: zero sqd->thread on tctx errors Date: Fri, 4 Dec 2026 18:50:58 +0900 Message-ID: <20261204100702.854941553@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: Pavel Begunkov Commit 4b7cfa8b6c28a9fa22b86894166a1a34f6d630ba upstream. Syzkeller reports: BUG: KASAN: slab-use-after-free in thread_group_cputime+0x409/0x700 kernel/sched/cputime.c:341 Read of size 8 at addr ffff88803578c510 by task syz.2.3223/27552 Call Trace: ... kasan_report+0x143/0x180 mm/kasan/report.c:602 thread_group_cputime+0x409/0x700 kernel/sched/cputime.c:341 thread_group_cputime_adjusted+0xa6/0x340 kernel/sched/cputime.c:639 getrusage+0x1000/0x1340 kernel/sys.c:1863 io_uring_show_fdinfo+0xdfe/0x1770 io_uring/fdinfo.c:197 seq_show+0x608/0x770 fs/proc/fd.c:68 ... That's due to sqd->task not being cleared properly in cases where SQPOLL task tctx setup fails, which can essentially only happen with fault injection to insert allocation errors. Cc: stable@vger.kernel.org Fixes: 1251d2025c3e1 ("io_uring/sqpoll: early exit thread if task_context wasn't allocated") Reported-by: syzbot+3d92cfcfa84070b0a470@syzkaller.appspotmail.com Signed-off-by: Pavel Begunkov Link: https://lore.kernel.org/r/efc7ec7010784463b2e7466d7b5c02c2cb381635.1736519461.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- io_uring/sqpoll.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/io_uring/sqpoll.c b/io_uring/sqpoll.c index b1428f91b5ee9..bde67560ace8d 100644 --- a/io_uring/sqpoll.c +++ b/io_uring/sqpoll.c @@ -280,8 +280,12 @@ static int io_sq_thread(void *data) DEFINE_WAIT(wait); /* offload context creation failed, just exit */ - if (!current->io_uring) + if (!current->io_uring) { + mutex_lock(&sqd->lock); + sqd->thread = NULL; + mutex_unlock(&sqd->lock); goto err_out; + } snprintf(buf, sizeof(buf), "iou-sqp-%d", sqd->task_pid); set_task_comm(current, buf); -- 2.53.0