In the Linux kernel, the following vulnerability has been resolved:
USB: gadget: Fix the memory leak in raw_gadget driver
Currently, increasing rawdev->count happens before invoke the rawqueueevent(), if the rawqueueevent() return error, invoke rawrelease() will not trigger the dev_free() to be called.
[ 268.905865][ T5067] raw-gadget.0 gadget.0: failed to queue event [ 268.912053][ T5067] udc dummyudc.0: failed to start USB Raw Gadget: -12 [ 268.918885][ T5067] raw-gadget.0: probe of gadget.0 failed with error -12 [ 268.925956][ T5067] UDC core: USB Raw Gadget: couldn't find an available UDC or it's busy [ 268.934657][ T5067] misc raw-gadget: fail, usbgadgetregisterdriver returned -16
BUG: memory leak
[<ffffffff8154bf94>] kmalloctrace+0x24/0x90 mm/slabcommon.c:1076 [<ffffffff8347eb55>] kmalloc include/linux/slab.h:582 [inline] [<ffffffff8347eb55>] kzalloc include/linux/slab.h:703 [inline] [<ffffffff8347eb55>] devnew drivers/usb/gadget/legacy/rawgadget.c:191 [inline] [<ffffffff8347eb55>] rawopen+0x45/0x110 drivers/usb/gadget/legacy/rawgadget.c:385 [<ffffffff827d1d09>] misc_open+0x1a9/0x1f0 drivers/char/misc.c:165
[<ffffffff8154bf94>] kmalloctrace+0x24/0x90 mm/slabcommon.c:1076 [<ffffffff8347cd2f>] kmalloc include/linux/slab.h:582 [inline] [<ffffffff8347cd2f>] rawioctlinit+0xdf/0x410 drivers/usb/gadget/legacy/rawgadget.c:460 [<ffffffff8347dfe9>] rawioctl+0x5f9/0x1120 drivers/usb/gadget/legacy/rawgadget.c:1250 [<ffffffff81685173>] vfsioctl fs/ioctl.c:51 [inline]
[<ffffffff8154bf94>] kmalloctrace+0x24/0x90 mm/slabcommon.c:1076 [<ffffffff833ecc6a>] kmalloc include/linux/slab.h:582 [inline] [<ffffffff833ecc6a>] kzalloc include/linux/slab.h:703 [inline] [<ffffffff833ecc6a>] dummyallocrequest+0x5a/0xe0 drivers/usb/gadget/udc/dummyhcd.c:665 [<ffffffff833e9132>] usbepallocrequest+0x22/0xd0 drivers/usb/gadget/udc/core.c:196 [<ffffffff8347f13d>] gadgetbind+0x6d/0x370 drivers/usb/gadget/legacy/rawgadget.c:292
This commit therefore invoke krefget() under the condition that rawqueue_event() return success.
[
{
"id": "CVE-2023-53693-285f5016",
"target": {
"function": "gadget_bind",
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@de77000c1923d7942f9b4f08447c8feeae1c0f33",
"signature_type": "Function",
"digest": {
"function_hash": "107809755153617586987432695335124601498",
"length": 1063.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-2be2014d",
"target": {
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@83e30f2bf86ef7c38fbd476ed81a88522b620628",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"63972950712171406360950372104035862825",
"257229550901802810341771217129919489743",
"319545631476149858960453386693147700752",
"160715866906034222387357348088885971198",
"35132972706777336089278655435558411311",
"300884043908164086886696929928911820559",
"115355046150766595379862356043791884400"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-2f75d306",
"target": {
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9934e5d07c0dc294169a7d52f6309f35cd6d7755",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"63972950712171406360950372104035862825",
"257229550901802810341771217129919489743",
"319545631476149858960453386693147700752",
"160715866906034222387357348088885971198",
"35132972706777336089278655435558411311",
"300884043908164086886696929928911820559",
"115355046150766595379862356043791884400"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-38ae82df",
"target": {
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@68e6287ac61dc22513cd39f02b9ac1fef28513e4",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"63972950712171406360950372104035862825",
"257229550901802810341771217129919489743",
"319545631476149858960453386693147700752",
"160715866906034222387357348088885971198",
"35132972706777336089278655435558411311",
"300884043908164086886696929928911820559",
"115355046150766595379862356043791884400"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-4584ed42",
"target": {
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@de77000c1923d7942f9b4f08447c8feeae1c0f33",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"63972950712171406360950372104035862825",
"257229550901802810341771217129919489743",
"319545631476149858960453386693147700752",
"160715866906034222387357348088885971198",
"35132972706777336089278655435558411311",
"300884043908164086886696929928911820559",
"115355046150766595379862356043791884400"
]
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-5a6e5152",
"target": {
"function": "gadget_bind",
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9934e5d07c0dc294169a7d52f6309f35cd6d7755",
"signature_type": "Function",
"digest": {
"function_hash": "107809755153617586987432695335124601498",
"length": 1063.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-72ab936d",
"target": {
"function": "gadget_bind",
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@68e6287ac61dc22513cd39f02b9ac1fef28513e4",
"signature_type": "Function",
"digest": {
"function_hash": "107809755153617586987432695335124601498",
"length": 1063.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-d422e8f7",
"target": {
"function": "gadget_bind",
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@83e30f2bf86ef7c38fbd476ed81a88522b620628",
"signature_type": "Function",
"digest": {
"function_hash": "107809755153617586987432695335124601498",
"length": 1063.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-d68111bb",
"target": {
"function": "gadget_bind",
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@0f7a2b567197798da7bfa2252f4485c0ca6c6266",
"signature_type": "Function",
"digest": {
"function_hash": "107809755153617586987432695335124601498",
"length": 1063.0
},
"deprecated": false,
"signature_version": "v1"
},
{
"id": "CVE-2023-53693-dd91a499",
"target": {
"file": "drivers/usb/gadget/legacy/raw_gadget.c"
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@0f7a2b567197798da7bfa2252f4485c0ca6c6266",
"signature_type": "Line",
"digest": {
"threshold": 0.9,
"line_hashes": [
"63972950712171406360950372104035862825",
"257229550901802810341771217129919489743",
"319545631476149858960453386693147700752",
"160715866906034222387357348088885971198",
"35132972706777336089278655435558411311",
"300884043908164086886696929928911820559",
"115355046150766595379862356043791884400"
]
},
"deprecated": false,
"signature_version": "v1"
}
]