In the Linux kernel, the following vulnerability has been resolved:
NFC: port100: fix use-after-free in port100sendcomplete
Syzbot reported UAF in port100sendcomplete(). The root case is in missing usbkillurb() calls on error handling path of ->probe function.
port100sendcomplete() accesses devm allocated memory which will be freed on probe failure. We should kill this urbs before returning an error from probe function to prevent reported use-after-free
Fail log:
BUG: KASAN: use-after-free in port100sendcomplete+0x16e/0x1a0 drivers/nfc/port100.c:935 Read of size 1 at addr ffff88801bb59540 by task ksoftirqd/2/26 ... Call Trace: <TASK> _dumpstack lib/dumpstack.c:88 [inline] dumpstacklvl+0xcd/0x134 lib/dumpstack.c:106 printaddressdescription.constprop.0.cold+0x8d/0x303 mm/kasan/report.c:255 _kasanreport mm/kasan/report.c:442 [inline] kasanreport.cold+0x83/0xdf mm/kasan/report.c:459 port100sendcomplete+0x16e/0x1a0 drivers/nfc/port100.c:935 _usbhcdgiveback_urb+0x2b0/0x5c0 drivers/usb/core/hcd.c:1670
...
Allocated by task 1255: kasansavestack+0x1e/0x40 mm/kasan/common.c:38 kasansettrack mm/kasan/common.c:45 [inline] setallocinfo mm/kasan/common.c:436 [inline] _kasankmalloc mm/kasan/common.c:515 [inline] kasankmalloc mm/kasan/common.c:474 [inline] _kasankmalloc+0xa6/0xd0 mm/kasan/common.c:524 allocdr drivers/base/devres.c:116 [inline] devmkmalloc+0x96/0x1d0 drivers/base/devres.c:823 devmkzalloc include/linux/device.h:209 [inline] port100_probe+0x8a/0x1320 drivers/nfc/port100.c:1502
Freed by task 1255: kasansavestack+0x1e/0x40 mm/kasan/common.c:38 kasansettrack+0x21/0x30 mm/kasan/common.c:45 kasansetfreeinfo+0x20/0x30 mm/kasan/generic.c:370 kasanslabfree mm/kasan/common.c:366 [inline] _kasanslabfree+0xff/0x140 mm/kasan/common.c:328 kasanslabfree include/linux/kasan.h:236 [inline] _cachefree mm/slab.c:3437 [inline] kfree+0xf8/0x2b0 mm/slab.c:3794 releasenodes+0x112/0x1a0 drivers/base/devres.c:501 devresreleaseall+0x114/0x190 drivers/base/devres.c:530 reallyprobe+0x626/0xcc0 drivers/base/dd.c:670
[ { "signature_type": "Line", "id": "CVE-2022-48857-183566ff", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7194737e1be8fdc89d2a9382bd2f371f7ee2eda8", "signature_version": "v1", "target": { "file": "drivers/nfc/port100.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "16461426479839705277117716419993305780", "104213228530234649437873063774061080960", "336550257817241398759859833125915795230", "6953156480032842498039356151568604804", "186145806575211454612537466872702770626" ] }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2022-48857-611e142b", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7194737e1be8fdc89d2a9382bd2f371f7ee2eda8", "signature_version": "v1", "target": { "function": "port100_probe", "file": "drivers/nfc/port100.c" }, "digest": { "function_hash": "273440978956857076430364407816006123991", "length": 2955.0 }, "deprecated": false }, { "signature_type": "Function", "id": "CVE-2022-48857-aa163471", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cd2a5c0da0d1ddf11d1f84e9c9b1949f50f6e161", "signature_version": "v1", "target": { "function": "port100_probe", "file": "drivers/nfc/port100.c" }, "digest": { "function_hash": "273440978956857076430364407816006123991", "length": 2955.0 }, "deprecated": false }, { "signature_type": "Line", "id": "CVE-2022-48857-e2b82778", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cd2a5c0da0d1ddf11d1f84e9c9b1949f50f6e161", "signature_version": "v1", "target": { "file": "drivers/nfc/port100.c" }, "digest": { "threshold": 0.9, "line_hashes": [ "16461426479839705277117716419993305780", "104213228530234649437873063774061080960", "336550257817241398759859833125915795230", "6953156480032842498039356151568604804", "186145806575211454612537466872702770626" ] }, "deprecated": false } ]