In the Linux kernel, the following vulnerability has been resolved:
can: isotp: fix potential CAN frame reception race in isotp_rcv()
When receiving a CAN frame the current code logic does not consider concurrently receiving processes which do not show up in real world usage.
Ziyang Xuan writes:
The following syz problem is one of the scenarios. so->rx.len is changed by isotprcvff() during isotprcvcf(), so->rx.len equals 0 before allocskb() and equals 4096 after allocskb(). That will trigger skboverpanic() in skb_put().
======================================================= CPU: 1 PID: 19 Comm: ksoftirqd/1 Not tainted 5.16.0-rc8-syzkaller #0 RIP: 0010:skbpanic+0x16c/0x16e net/core/skbuff.c:113 Call Trace: <TASK> skboverpanic net/core/skbuff.c:118 [inline] skbput.cold+0x24/0x24 net/core/skbuff.c:1990 isotprcvcf net/can/isotp.c:570 [inline] isotprcv+0xa38/0x1e30 net/can/isotp.c:668 deliver net/can/afcan.c:574 [inline] canrcvfilter+0x445/0x8d0 net/can/afcan.c:635 canreceive+0x31d/0x580 net/can/afcan.c:665 canrcv+0x120/0x1c0 net/can/afcan.c:696 _netifreceiveskbonecore+0x114/0x180 net/core/dev.c:5465 _netifreceive_skb+0x24/0x1b0 net/core/dev.c:5579
Therefore we make sure the state changes and data structures stay consistent at CAN frame reception time by adding a spinlock in isotprcv(). This fixes the issue reported by syzkaller but does not affect real world operation.
{ "vanir_signatures": [ { "signature_version": "v1", "digest": { "length": 1100.0, "function_hash": "294895818130174989360678105078570897775" }, "id": "CVE-2022-48830-0a42b6ca", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_rcv" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7b53d2204ce79b27a878074a77d64f40ec21dbca" }, { "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "121814727917269825992131836999985050963", "298267915154587452876886544777427068938", "282573389757620155815616580531410822510", "269720996699874041568060301118804221307", "249485973173475354699874583791255338974", "163003489577756010779999028251281952452", "218298565025257988988789408720540365376", "169778653232398226371230222016112937610", "319617917630390611906981834359995872729", "35605940954645578034094000539336851577", "143172898726842876009787125349408616457", "199456423979748562218296294895497466579", "121703461158421987751558183568836888460", "119252131887575870254911058204892656126", "154209073899366858489076971940195901144", "288445759025385252526285905757035961241", "339822914855695523957998899001429830011", "340035948791806997037086204323442388482", "102538741992484052745193791205931064368", "93058470078601136049217408318380656754", "248302819031810314742980675807672767100", "331486682590955069761620275803417523282" ] }, "id": "CVE-2022-48830-11e6c148", "deprecated": false, "target": { "file": "net/can/isotp.c" }, "signature_type": "Line", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7b53d2204ce79b27a878074a77d64f40ec21dbca" }, { "signature_version": "v1", "digest": { "length": 1304.0, "function_hash": "87326571918448109347011092351753801296" }, "id": "CVE-2022-48830-232558f5", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_init" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c759040c1dd03954f650f147ae7175476d51314" }, { "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "121814727917269825992131836999985050963", "298267915154587452876886544777427068938", "282573389757620155815616580531410822510", "269720996699874041568060301118804221307", "249485973173475354699874583791255338974", "163003489577756010779999028251281952452", "218298565025257988988789408720540365376", "169778653232398226371230222016112937610", "319617917630390611906981834359995872729", "35605940954645578034094000539336851577", "143172898726842876009787125349408616457", "199456423979748562218296294895497466579", "121703461158421987751558183568836888460", "119252131887575870254911058204892656126", "154209073899366858489076971940195901144", "288445759025385252526285905757035961241", "339822914855695523957998899001429830011", "340035948791806997037086204323442388482", "102538741992484052745193791205931064368", "93058470078601136049217408318380656754", "248302819031810314742980675807672767100", "331486682590955069761620275803417523282" ] }, "id": "CVE-2022-48830-2e532779", "deprecated": false, "target": { "file": "net/can/isotp.c" }, "signature_type": "Line", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5b068f33bc8acfcfd5ea7992a2dafb30d89bad30" }, { "signature_version": "v1", "digest": { "length": 1304.0, "function_hash": "87326571918448109347011092351753801296" }, "id": "CVE-2022-48830-323ef57b", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_init" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5b068f33bc8acfcfd5ea7992a2dafb30d89bad30" }, { "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "121814727917269825992131836999985050963", "298267915154587452876886544777427068938", "282573389757620155815616580531410822510", "269720996699874041568060301118804221307", "249485973173475354699874583791255338974", "163003489577756010779999028251281952452", "218298565025257988988789408720540365376", "169778653232398226371230222016112937610", "319617917630390611906981834359995872729", "35605940954645578034094000539336851577", "143172898726842876009787125349408616457", "199456423979748562218296294895497466579", "121703461158421987751558183568836888460", "119252131887575870254911058204892656126", "154209073899366858489076971940195901144", "288445759025385252526285905757035961241", "339822914855695523957998899001429830011", "340035948791806997037086204323442388482", "102538741992484052745193791205931064368", "93058470078601136049217408318380656754", "248302819031810314742980675807672767100", "331486682590955069761620275803417523282" ] }, "id": "CVE-2022-48830-370b5af9", "deprecated": false, "target": { "file": "net/can/isotp.c" }, "signature_type": "Line", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c759040c1dd03954f650f147ae7175476d51314" }, { "signature_version": "v1", "digest": { "length": 1100.0, "function_hash": "294895818130174989360678105078570897775" }, "id": "CVE-2022-48830-7aad8c69", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_rcv" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7c759040c1dd03954f650f147ae7175476d51314" }, { "signature_version": "v1", "digest": { "length": 1100.0, "function_hash": "294895818130174989360678105078570897775" }, "id": "CVE-2022-48830-83e94112", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_rcv" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@5b068f33bc8acfcfd5ea7992a2dafb30d89bad30" }, { "signature_version": "v1", "digest": { "threshold": 0.9, "line_hashes": [ "121814727917269825992131836999985050963", "298267915154587452876886544777427068938", "282573389757620155815616580531410822510", "269720996699874041568060301118804221307", "249485973173475354699874583791255338974", "163003489577756010779999028251281952452", "218298565025257988988789408720540365376", "169778653232398226371230222016112937610", "319617917630390611906981834359995872729", "35605940954645578034094000539336851577", "143172898726842876009787125349408616457", "199456423979748562218296294895497466579", "121703461158421987751558183568836888460", "119252131887575870254911058204892656126", "154209073899366858489076971940195901144", "288445759025385252526285905757035961241", "339822914855695523957998899001429830011", "340035948791806997037086204323442388482", "102538741992484052745193791205931064368", "93058470078601136049217408318380656754", "248302819031810314742980675807672767100", "331486682590955069761620275803417523282" ] }, "id": "CVE-2022-48830-9683e6f4", "deprecated": false, "target": { "file": "net/can/isotp.c" }, "signature_type": "Line", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f90cc68f9f4b5d8585ad5d0a206a9d37ac299ef3" }, { "signature_version": "v1", "digest": { "length": 1304.0, "function_hash": "87326571918448109347011092351753801296" }, "id": "CVE-2022-48830-e3d36c0e", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_init" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f90cc68f9f4b5d8585ad5d0a206a9d37ac299ef3" }, { "signature_version": "v1", "digest": { "length": 1100.0, "function_hash": "294895818130174989360678105078570897775" }, "id": "CVE-2022-48830-f92d9a2f", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_rcv" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@f90cc68f9f4b5d8585ad5d0a206a9d37ac299ef3" }, { "signature_version": "v1", "digest": { "length": 1304.0, "function_hash": "87326571918448109347011092351753801296" }, "id": "CVE-2022-48830-fd68d26e", "deprecated": false, "target": { "file": "net/can/isotp.c", "function": "isotp_init" }, "signature_type": "Function", "source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@7b53d2204ce79b27a878074a77d64f40ec21dbca" } ] }