In the Linux kernel, the following vulnerability has been resolved:
watch_queue: Fix filter limit check
In watchqueuesetfilter(), there are a couple of places where we check that the filter type value does not exceed what the typefilter 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->typefilter) * BITSPER_LONG)
which is not. This can lead to a couple of out-of-bounds writes due to a too-large type:
(1) _setbit() on wfilter->type_filter (2) Writing more elements in wfilter->filters[] than we allocated.
Fix this by just using the proper WATCHTYPE_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 watchqueuesetfilter+0x659/0x740 Write of size 4 at addr ffff88800d2c66bc by task watchqueueoob/611 ... Call Trace: <TASK> dumpstacklvl+0x45/0x59 printaddressdescription.constprop.0+0x1f/0x150 ... kasanreport.cold+0x7f/0x11b ... watchqueuesetfilter+0x659/0x740 ... _x64sysioctl+0x127/0x190 dosyscall64+0x43/0x90 entrySYSCALL64afterhwframe+0x44/0xae
Allocated by task 611: kasansavestack+0x1e/0x40 _kasankmalloc+0x81/0xa0 watchqueuesetfilter+0x23a/0x740 _x64sysioctl+0x127/0x190 dosyscall64+0x43/0x90 entrySYSCALL64afterhwframe+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)
[
{
"deprecated": false,
"id": "CVE-2022-48847-05c7cdfd",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c993ee0f9f81caf5767a50d1faeba39a0dc82af2",
"digest": {
"function_hash": "100681802253888243285185113804963894436",
"length": 1610.0
},
"target": {
"function": "watch_queue_set_filter",
"file": "kernel/watch_queue.c"
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-2013713b",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@648895da69ced90ca770fd941c3d9479a9d72c16",
"digest": {
"function_hash": "100681802253888243285185113804963894436",
"length": 1610.0
},
"target": {
"function": "watch_queue_set_filter",
"file": "kernel/watch_queue.c"
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-229568df",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b36588ebbcef74583824c08352e75838d6fb4ff2",
"digest": {
"threshold": 0.9,
"line_hashes": [
"137711575114100241341513004250176254588",
"4521193905409463404961056291118548270",
"61039842527287373786503834170963495775",
"83746915187150315936989793431489767026",
"179978502218311778361334427312765801980",
"90946958218134933078931379025821795496",
"315062337405339488667935056551045609560",
"69192450663966954410916912513811172184"
]
},
"target": {
"file": "kernel/watch_queue.c"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-3bf10863",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b36588ebbcef74583824c08352e75838d6fb4ff2",
"digest": {
"function_hash": "100681802253888243285185113804963894436",
"length": 1610.0
},
"target": {
"function": "watch_queue_set_filter",
"file": "kernel/watch_queue.c"
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-48bfbebf",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b36588ebbcef74583824c08352e75838d6fb4ff2",
"digest": {
"threshold": 0.9,
"line_hashes": [
"220556643955273045540304130297866366277",
"218192974053790325717759735569621058111",
"235864538394265797283172213633001322753",
"156215045986280034587208338768586602994"
]
},
"target": {
"file": "include/linux/watch_queue.h"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-53ccc532",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1b09f28f70a5046acd64138075ae3f095238b045",
"digest": {
"threshold": 0.9,
"line_hashes": [
"220556643955273045540304130297866366277",
"218192974053790325717759735569621058111",
"235864538394265797283172213633001322753",
"156215045986280034587208338768586602994"
]
},
"target": {
"file": "include/linux/watch_queue.h"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-561cab93",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c993ee0f9f81caf5767a50d1faeba39a0dc82af2",
"digest": {
"threshold": 0.9,
"line_hashes": [
"220556643955273045540304130297866366277",
"218192974053790325717759735569621058111",
"235864538394265797283172213633001322753",
"156215045986280034587208338768586602994"
]
},
"target": {
"file": "include/linux/watch_queue.h"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-ae1c0aa6",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@648895da69ced90ca770fd941c3d9479a9d72c16",
"digest": {
"threshold": 0.9,
"line_hashes": [
"137711575114100241341513004250176254588",
"4521193905409463404961056291118548270",
"61039842527287373786503834170963495775",
"83746915187150315936989793431489767026",
"179978502218311778361334427312765801980",
"90946958218134933078931379025821795496",
"315062337405339488667935056551045609560",
"69192450663966954410916912513811172184"
]
},
"target": {
"file": "kernel/watch_queue.c"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-afc98cad",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@c993ee0f9f81caf5767a50d1faeba39a0dc82af2",
"digest": {
"threshold": 0.9,
"line_hashes": [
"137711575114100241341513004250176254588",
"4521193905409463404961056291118548270",
"61039842527287373786503834170963495775",
"83746915187150315936989793431489767026",
"179978502218311778361334427312765801980",
"90946958218134933078931379025821795496",
"315062337405339488667935056551045609560",
"69192450663966954410916912513811172184"
]
},
"target": {
"file": "kernel/watch_queue.c"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-cf2bc0f9",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1b09f28f70a5046acd64138075ae3f095238b045",
"digest": {
"threshold": 0.9,
"line_hashes": [
"137711575114100241341513004250176254588",
"4521193905409463404961056291118548270",
"61039842527287373786503834170963495775",
"83746915187150315936989793431489767026",
"179978502218311778361334427312765801980",
"90946958218134933078931379025821795496",
"315062337405339488667935056551045609560",
"69192450663966954410916912513811172184"
]
},
"target": {
"file": "kernel/watch_queue.c"
},
"signature_type": "Line",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-e4377e4f",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@1b09f28f70a5046acd64138075ae3f095238b045",
"digest": {
"function_hash": "100681802253888243285185113804963894436",
"length": 1610.0
},
"target": {
"function": "watch_queue_set_filter",
"file": "kernel/watch_queue.c"
},
"signature_type": "Function",
"signature_version": "v1"
},
{
"deprecated": false,
"id": "CVE-2022-48847-f836c21c",
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@648895da69ced90ca770fd941c3d9479a9d72c16",
"digest": {
"threshold": 0.9,
"line_hashes": [
"220556643955273045540304130297866366277",
"218192974053790325717759735569621058111",
"235864538394265797283172213633001322753",
"156215045986280034587208338768586602994"
]
},
"target": {
"file": "include/linux/watch_queue.h"
},
"signature_type": "Line",
"signature_version": "v1"
}
]