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 49D3C134CC2 for ; Wed, 10 Apr 2024 19:02:18 +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=1712775739; cv=none; b=hWIkkrrtRFfE3LuaH07c3nFI/G+qCoxo9uGDKJyg1Ok9VfbrvfbEMkDiTNbuvlgISXJmchZ19MS8AWNinqdwicrKTv5HkeBkAclzoMabsI31n1dxefBssJl6arWsyzRW4dYV7QtWyuCRwS/sKcx7lB2Wvccp/Vl843YYwyTviDQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712775739; c=relaxed/simple; bh=7P9Bj6IXqU1WT7dB1vSNNHq0pC+fpKMtFONNERw3iag=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BNc4Qsrh5UZx0RVy/3ymsixD6+UD4dekJ/KpcsqWwgDMNJoYrT+xdJ8BJf6K0JZs/Xb2VUBXasKbpkxj+CbZQMvEh4Mq9yCbjIIzmRTje1Ilc9U4Rx0wOyO1bvV2EIzD5V51rYowpbEij0i10DYei86QlO8Fr86t2Cxg5lq/pew= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=bOdsjHGV; 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="bOdsjHGV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E328C433F1; Wed, 10 Apr 2024 19:02:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1712775738; bh=7P9Bj6IXqU1WT7dB1vSNNHq0pC+fpKMtFONNERw3iag=; h=From:To:Cc:Subject:Date:Reply-to:From; b=bOdsjHGV8t/akQosXbdxNQFWamtIwwJAHnSI5QFjQihG0I21bzU4XbijOkQLQqCct OaHxqBT9IL2YnPCjBmchKnj6N/vlP+O0WavELP7VFKYlSO7v/2kYKA49kqezy5lFXF SxKuXDHB8XbW9deBjo7dlR37xkONXnz7BIKFHLEg= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2021-47219: scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs() Date: Wed, 10 Apr 2024 21:02:12 +0200 Message-ID: <2024041006-CVE-2021-47219-c09e@gregkh> X-Mailer: git-send-email 2.44.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=3655; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=7P9Bj6IXqU1WT7dB1vSNNHq0pC+fpKMtFONNERw3iag=; b=owGbwMvMwCRo6H6F97bub03G02pJDGlij/TOe8bN9dj/M/nBvkeyXw8KdP5Ll57WET9Z+Nunh p0ls9Zwd8SyMAgyMciKKbJ82cZzdH/FIUUvQ9vTMHNYmUCGMHBxCsBEfi1gmM2asL83Yk3PNAaG LR8Zp0WlsjAsTmJYcEJPpG9fmunM7+vOPJE+zh7mU7+uCgA= 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: scsi: scsi_debug: Fix out-of-bound read in resp_report_tgtpgs() The following issue was observed running syzkaller: BUG: KASAN: slab-out-of-bounds in memcpy include/linux/string.h:377 [inline] BUG: KASAN: slab-out-of-bounds in sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831 Read of size 2132 at addr ffff8880aea95dc8 by task syz-executor.0/9815 CPU: 0 PID: 9815 Comm: syz-executor.0 Not tainted 4.19.202-00874-gfc0fe04215a9 #2 Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014 Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0xe4/0x14a lib/dump_stack.c:118 print_address_description+0x73/0x280 mm/kasan/report.c:253 kasan_report_error mm/kasan/report.c:352 [inline] kasan_report+0x272/0x370 mm/kasan/report.c:410 memcpy+0x1f/0x50 mm/kasan/kasan.c:302 memcpy include/linux/string.h:377 [inline] sg_copy_buffer+0x150/0x1c0 lib/scatterlist.c:831 fill_from_dev_buffer+0x14f/0x340 drivers/scsi/scsi_debug.c:1021 resp_report_tgtpgs+0x5aa/0x770 drivers/scsi/scsi_debug.c:1772 schedule_resp+0x464/0x12f0 drivers/scsi/scsi_debug.c:4429 scsi_debug_queuecommand+0x467/0x1390 drivers/scsi/scsi_debug.c:5835 scsi_dispatch_cmd+0x3fc/0x9b0 drivers/scsi/scsi_lib.c:1896 scsi_request_fn+0x1042/0x1810 drivers/scsi/scsi_lib.c:2034 __blk_run_queue_uncond block/blk-core.c:464 [inline] __blk_run_queue+0x1a4/0x380 block/blk-core.c:484 blk_execute_rq_nowait+0x1c2/0x2d0 block/blk-exec.c:78 sg_common_write.isra.19+0xd74/0x1dc0 drivers/scsi/sg.c:847 sg_write.part.23+0x6e0/0xd00 drivers/scsi/sg.c:716 sg_write+0x64/0xa0 drivers/scsi/sg.c:622 __vfs_write+0xed/0x690 fs/read_write.c:485 kill_bdev:block_device:00000000e138492c vfs_write+0x184/0x4c0 fs/read_write.c:549 ksys_write+0x107/0x240 fs/read_write.c:599 do_syscall_64+0xc2/0x560 arch/x86/entry/common.c:293 entry_SYSCALL_64_after_hwframe+0x49/0xbe We get 'alen' from command its type is int. If userspace passes a large length we will get a negative 'alen'. Switch n, alen, and rlen to u32. The Linux kernel CVE team has assigned CVE-2021-47219 to this issue. Affected and fixed versions =========================== Fixed in 5.10.82 with commit 8440377e1a56 Fixed in 5.15.5 with commit 66523553fa62 Fixed in 5.16 with commit f347c26836c2 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-2021-47219 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: drivers/scsi/scsi_debug.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/8440377e1a5644779b4c8d013aa2a917f5fc83c3 https://git.kernel.org/stable/c/66523553fa62c7878fc5441dc4e82be71934eb77 https://git.kernel.org/stable/c/f347c26836c270199de1599c3cd466bb7747caa9