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 AF131199229 for ; Tue, 16 Jul 2024 12:27:54 +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=1721132874; cv=none; b=WCN4kAf0V39ucm07IIZS2/Gd8q6BFZ2ZJzEsd10zEYYfSTLsgAZ9tfrfQ3UlnC3i0T6cpZ4E4ck5ehsTm80sTWIlX+ZjK4Zk7hopdyQyBKVFJSuc8poAEYn4LBgqu/LwfpXicmO9FEeCPmTYcGkHthOKMbXerMI/3ToFwdzcHac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721132874; c=relaxed/simple; bh=NH73heTxveHng8Z07DFj2P7xqYj5vDRJv9gpU1YsoKU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XwiiXSbXamxK5Qmx1P0/Mj9hiM30Ha6ptMhSU6P1G2RO2FemJAWEieeSqbUjYIqFht+2pYBR1f2MWhvbttbqMGMhEXRXu74DPKzHZCSPNd2EyL07RVI7dQ/XC8a3iqzduQS4L3W/lJ++0p4jcjQpKA4P8bPzT5VRtwIdmdhrshs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FyQBgEKx; 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="FyQBgEKx" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D36C8C116B1; Tue, 16 Jul 2024 12:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1721132874; bh=NH73heTxveHng8Z07DFj2P7xqYj5vDRJv9gpU1YsoKU=; h=From:To:Cc:Subject:Date:Reply-to:From; b=FyQBgEKxOeqXsJqPab6gb8dbiTb8LykKLAlSFhIxypPXd0VrUjDbPoVdsKhyI/ATC cILTTvBPwCmA+pbLXskjJ6g7p8lAep+yyoc5f6JUB6WSQjCEweqXAr8BJKf+V9ziPZ Yw2APDkD7oxrjchiax0WuVCyiJ+CICdh47mXYC5o= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2022-48847: watch_queue: Fix filter limit check Date: Tue, 16 Jul 2024 14:27:32 +0200 Message-ID: <2024071624-CVE-2022-48847-42ea@gregkh> X-Mailer: git-send-email 2.45.2 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=3663; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=NH73heTxveHng8Z07DFj2P7xqYj5vDRJv9gpU1YsoKU=; b=owGbwMvMwCRo6H6F97bub03G02pJDGnT0nUkt2+Jb5sRszbY+WLg/cwZW0zevvQoVzooN8kr6 QPTxu1zO2JZGASZGGTFFFm+bOM5ur/ikKKXoe1pmDmsTCBDGLg4BWAiTO0MMxkvxrw6saS5ttDg eqXsg6AlHaXXfzEs2NO3NauJg8PU8dmVxbG8u2XPlywuBwA= 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: watch_queue: Fix filter limit check In watch_queue_set_filter(), there are a couple of places where we check that the filter type value does not exceed what the type_filter bitmap can hold. One place calculates the number of bits by: if (tf[i].type >= sizeof(wfilter->type_filter) * 8) which is fine, but the second does: if (tf[i].type >= sizeof(wfilter->type_filter) * BITS_PER_LONG) which is not. This can lead to a couple of out-of-bounds writes due to a too-large type: (1) __set_bit() on wfilter->type_filter (2) Writing more elements in wfilter->filters[] than we allocated. Fix this by just using the proper WATCH_TYPE__NR instead, which is the number of types we actually know about. The bug may cause an oops looking something like: BUG: KASAN: slab-out-of-bounds in watch_queue_set_filter+0x659/0x740 Write of size 4 at addr ffff88800d2c66bc by task watch_queue_oob/611 ... Call Trace: dump_stack_lvl+0x45/0x59 print_address_description.constprop.0+0x1f/0x150 ... kasan_report.cold+0x7f/0x11b ... watch_queue_set_filter+0x659/0x740 ... __x64_sys_ioctl+0x127/0x190 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae Allocated by task 611: kasan_save_stack+0x1e/0x40 __kasan_kmalloc+0x81/0xa0 watch_queue_set_filter+0x23a/0x740 __x64_sys_ioctl+0x127/0x190 do_syscall_64+0x43/0x90 entry_SYSCALL_64_after_hwframe+0x44/0xae The buggy address belongs to the object at ffff88800d2c66a0 which belongs to the cache kmalloc-32 of size 32 The buggy address is located 28 bytes inside of 32-byte region [ffff88800d2c66a0, ffff88800d2c66c0) The Linux kernel CVE team has assigned CVE-2022-48847 to this issue. Affected and fixed versions =========================== Issue introduced in 5.8 with commit c73be61cede5 and fixed in 5.10.106 with commit 648895da69ce Issue introduced in 5.8 with commit c73be61cede5 and fixed in 5.15.29 with commit 1b09f28f70a5 Issue introduced in 5.8 with commit c73be61cede5 and fixed in 5.16.15 with commit b36588ebbcef Issue introduced in 5.8 with commit c73be61cede5 and fixed in 5.17 with commit c993ee0f9f81 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-48847 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: include/linux/watch_queue.h kernel/watch_queue.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/648895da69ced90ca770fd941c3d9479a9d72c16 https://git.kernel.org/stable/c/1b09f28f70a5046acd64138075ae3f095238b045 https://git.kernel.org/stable/c/b36588ebbcef74583824c08352e75838d6fb4ff2 https://git.kernel.org/stable/c/c993ee0f9f81caf5767a50d1faeba39a0dc82af2