Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 77FA31FEFB5 for ; Mon, 21 Oct 2024 20:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729541648; cv=none; b=cF+J/4JeK12A0htOpBXq5bQtGqWlSVvtD8KmaZl02fUYd+WwLLc2a/iAkc9GrBO9i3EKYDhUHuDLy52CpHv54PXMFse/Z/xMEdZn8NyFV12Tnuvb4ri2tQQ4YR9Ej5GnNlrW3klGX61ibnm01Gc3gRgj4rw71ERGuycDNNm79wc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729541648; c=relaxed/simple; bh=LYSBoOh5J+ROeRIq+ELZRwSYMWLQiqE3gullRb6M8L0=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=S6HC7MWZ91LDBil7xT5qZyfI7GbgoNtMdsJxVNMYNpHmFoqo9ZxSZZwpieU2ZqjLOWXvVo1+WHeqdELRiQLyewGTLDjRyJgRKbtiXkRWpX5sHn1q0z7mdPM3Dq9UB83hn5K2pcWgw1wrcmxKNB7jIEfAeeGVCxgAfK8am+/wa/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=C1vEtelR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="C1vEtelR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id F259AC4CEC7; Mon, 21 Oct 2024 20:14:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1729541648; bh=LYSBoOh5J+ROeRIq+ELZRwSYMWLQiqE3gullRb6M8L0=; h=From:To:Cc:Subject:Date:Reply-to:From; b=C1vEtelRhqtTNMGZYwmrTHS7zLoqhKx4g31xKHihNFD7EZSz2/LMM/g2do1JgU8Vz rRleMDLyZ8U2WwA+bCnAqTYV1tdeX6XOYanGK6zIRx+Nc2kkUn0Oq2WGSevhWdMqyv 7zralqCoDxmm0kKeHHqlsPkJJJTotvhi9EmUAkDc= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48983: io_uring: Fix a null-ptr-deref in io_tctx_exit_cb() Date: Mon, 21 Oct 2024 22:06:15 +0200 Message-ID: <2024102147-CVE-2022-48983-7e0c@gregkh> X-Mailer: git-send-email 2.47.0 Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Reply-to: , X-Developer-Signature: v=1; a=openpgp-sha256; l=4252; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=LYSBoOh5J+ROeRIq+ELZRwSYMWLQiqE3gullRb6M8L0=; b=owGbwMvMwCRo6H6F97bub03G02pJDOliW6TT12563OUXWj1X71FX5Zwd8exdJmLPjT5y885ee Usjbur+jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZjIDVOGeUYKBT9vv7j549P9 BU3XGatLzjKfcmdY0L64+eTkKYs6hKwv+ntkdv1X21ylCwA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Description =========== In the Linux kernel, the following vulnerability has been resolved: io_uring: Fix a null-ptr-deref in io_tctx_exit_cb() Syzkaller reports a NULL deref bug as follows: BUG: KASAN: null-ptr-deref in io_tctx_exit_cb+0x53/0xd3 Read of size 4 at addr 0000000000000138 by task file1/1955 CPU: 1 PID: 1955 Comm: file1 Not tainted 6.1.0-rc7-00103-gef4d3ea40565 #75 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.11.0-2.el7 04/01/2014 Call Trace: dump_stack_lvl+0xcd/0x134 ? io_tctx_exit_cb+0x53/0xd3 kasan_report+0xbb/0x1f0 ? io_tctx_exit_cb+0x53/0xd3 kasan_check_range+0x140/0x190 io_tctx_exit_cb+0x53/0xd3 task_work_run+0x164/0x250 ? task_work_cancel+0x30/0x30 get_signal+0x1c3/0x2440 ? lock_downgrade+0x6e0/0x6e0 ? lock_downgrade+0x6e0/0x6e0 ? exit_signals+0x8b0/0x8b0 ? do_raw_read_unlock+0x3b/0x70 ? do_raw_spin_unlock+0x50/0x230 arch_do_signal_or_restart+0x82/0x2470 ? kmem_cache_free+0x260/0x4b0 ? putname+0xfe/0x140 ? get_sigframe_size+0x10/0x10 ? do_execveat_common.isra.0+0x226/0x710 ? lockdep_hardirqs_on+0x79/0x100 ? putname+0xfe/0x140 ? do_execveat_common.isra.0+0x238/0x710 exit_to_user_mode_prepare+0x15f/0x250 syscall_exit_to_user_mode+0x19/0x50 do_syscall_64+0x42/0xb0 entry_SYSCALL_64_after_hwframe+0x63/0xcd RIP: 0023:0x0 Code: Unable to access opcode bytes at 0xffffffffffffffd6. RSP: 002b:00000000fffb7790 EFLAGS: 00000200 ORIG_RAX: 000000000000000b RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000 RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000 R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000000 R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000 Kernel panic - not syncing: panic_on_warn set ... This happens because the adding of task_work from io_ring_exit_work() isn't synchronized with canceling all work items from eg exec. The execution of the two are ordered in that they are both run by the task itself, but if io_tctx_exit_cb() is queued while we're canceling all work items off exec AND gets executed when the task exits to userspace rather than in the main loop in io_uring_cancel_generic(), then we can find current->io_uring == NULL and hit the above crash. It's safe to add this NULL check here, because the execution of the two paths are done by the task itself. [axboe: add code comment and also put an explanation in the commit msg] The Linux kernel CVE team has assigned CVE-2022-48983 to this issue. Affected and fixed versions =========================== Issue introduced in 5.12 with commit d56d938b4bef and fixed in 5.15.83 with commit f895511de9d2 Issue introduced in 5.12 with commit d56d938b4bef and fixed in 6.0.13 with commit d91edca19434 Issue introduced in 5.12 with commit d56d938b4bef and fixed in 6.1 with commit 998b30c3948e Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2022-48983 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: io_uring/io_uring.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/f895511de9d27fff71dad2c234ad53b4afd2b06c https://git.kernel.org/stable/c/d91edca1943453aaaba4f380f6f364346222e5cf https://git.kernel.org/stable/c/998b30c3948e4d0b1097e639918c5cff332acac5