In the Linux kernel, the following vulnerability has been resolved:
watch_queue: Fix NULL dereference in error cleanup
In watchqueuesetsize(), the error cleanup code doesn't take account of the fact that _free_page() can't handle a NULL pointer when trying to free up buffer pages that did get allocated.
Fix this by only calling _freepage() on the pages actually allocated.
Without the fix, this can lead to something like the following:
BUG: KASAN: null-ptr-deref in _freepages+0x1f/0x1b0 mm/pagealloc.c:5473 Read of size 4 at addr 0000000000000034 by task syz-executor168/3599 ... Call Trace: <TASK> _dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0xcd/0x134 lib/dumpstack.c:106 _kasanreport mm/kasan/report.c:446 [inline] kasanreport.cold+0x66/0xdf mm/kasan/report.c:459 checkregioninline mm/kasan/generic.c:183 [inline] kasancheckrange+0x13d/0x180 mm/kasan/generic.c:189 instrumentatomicread include/linux/instrumented.h:71 [inline] atomicread include/linux/atomic/atomic-instrumented.h:27 [inline] pagerefcount include/linux/pageref.h:67 [inline] putpagetestzero include/linux/mm.h:717 [inline] _freepages+0x1f/0x1b0 mm/pagealloc.c:5473 watchqueuesetsize+0x499/0x630 kernel/watchqueue.c:275 pipeioctl+0xac/0x2b0 fs/pipe.c:632 vfsioctl fs/ioctl.c:51 [inline] _dosysioctl fs/ioctl.c:874 [inline] _sesysioctl fs/ioctl.c:860 [inline] _x64sysioctl+0x193/0x200 fs/ioctl.c:860 dosyscallx64 arch/x86/entry/common.c:50 [inline] dosyscall64+0x35/0xb0 arch/x86/entry/common.c:80 entrySYSCALL64afterhwframe+0x44/0xae
{ "vanir_signatures": [ { "signature_version": "v1", "signature_type": "Line", "target": { "file": "kernel/watch_queue.c" }, "deprecated": false, "digest": { "line_hashes": [ "43262517691715942257670191058740776878", "275112086765420350613866260230741757028", "242087733265366431217218807782885859929", "71047390175725218241309330336171080411" ], "threshold": 0.9 }, "id": "CVE-2022-49257-35a5bb5c", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@695c47cea02b9101e2fc2e7d36d552128592b347" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "kernel/watch_queue.c" }, "deprecated": false, "digest": { "line_hashes": [ "43262517691715942257670191058740776878", "275112086765420350613866260230741757028", "242087733265366431217218807782885859929", "71047390175725218241309330336171080411" ], "threshold": 0.9 }, "id": "CVE-2022-49257-36f6ff04", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5ae75b4ed30322b42abaa75ef1b784addfdb7dc9" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "kernel/watch_queue.c", "function": "watch_queue_set_size" }, "deprecated": false, "digest": { "length": 1334.0, "function_hash": "285794844204289758030245428210368091390" }, "id": "CVE-2022-49257-4ddbe878", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b6f5ad3e45d19f9c4ee3e8a2aff829f28d68591d" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "kernel/watch_queue.c", "function": "watch_queue_set_size" }, "deprecated": false, "digest": { "length": 1334.0, "function_hash": "285794844204289758030245428210368091390" }, "id": "CVE-2022-49257-60fd8b1e", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a635415a064e77bcfbf43da413fd9dfe0bbed9cb" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "kernel/watch_queue.c", "function": "watch_queue_set_size" }, "deprecated": false, "digest": { "length": 1447.0, "function_hash": "282780513518245143971803437731879579721" }, "id": "CVE-2022-49257-61588e5b", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@695c47cea02b9101e2fc2e7d36d552128592b347" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "kernel/watch_queue.c" }, "deprecated": false, "digest": { "line_hashes": [ "43262517691715942257670191058740776878", "275112086765420350613866260230741757028", "242087733265366431217218807782885859929", "71047390175725218241309330336171080411" ], "threshold": 0.9 }, "id": "CVE-2022-49257-7f17fe24", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@a635415a064e77bcfbf43da413fd9dfe0bbed9cb" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "kernel/watch_queue.c" }, "deprecated": false, "digest": { "line_hashes": [ "43262517691715942257670191058740776878", "275112086765420350613866260230741757028", "242087733265366431217218807782885859929", "71047390175725218241309330336171080411" ], "threshold": 0.9 }, "id": "CVE-2022-49257-8be68e00", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b6f5ad3e45d19f9c4ee3e8a2aff829f28d68591d" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "kernel/watch_queue.c", "function": "watch_queue_set_size" }, "deprecated": false, "digest": { "length": 1447.0, "function_hash": "282780513518245143971803437731879579721" }, "id": "CVE-2022-49257-9c4a2622", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@112a2f9b0a8457794095a0450598f150724ec456" }, { "signature_version": "v1", "signature_type": "Line", "target": { "file": "kernel/watch_queue.c" }, "deprecated": false, "digest": { "line_hashes": [ "43262517691715942257670191058740776878", "275112086765420350613866260230741757028", "242087733265366431217218807782885859929", "71047390175725218241309330336171080411" ], "threshold": 0.9 }, "id": "CVE-2022-49257-ee122640", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@112a2f9b0a8457794095a0450598f150724ec456" }, { "signature_version": "v1", "signature_type": "Function", "target": { "file": "kernel/watch_queue.c", "function": "watch_queue_set_size" }, "deprecated": false, "digest": { "length": 1447.0, "function_hash": "282780513518245143971803437731879579721" }, "id": "CVE-2022-49257-f258575d", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5ae75b4ed30322b42abaa75ef1b784addfdb7dc9" } ] }