CVE-2021-47162: tipc: skb_linearize the head skb when reassembling msgs
In the Linux kernel, the following vulnerability has been resolved:
tipc: skblinearize the head skb when reassembling msgs
It's not a good idea to append the frag skb to a skb's fraglist if the fraglist already has skbs from elsewhere, such as this skb was created by pskbcopy() where the fraglist was cloned (all the skbs in it were skbget'ed) and shared by multiple skbs.
However, the new appended frag skb should have been only seen by the current skb. Otherwise, it will cause use after free crashes as this appended frag skb are seen by multiple skbs but it only got skbget called once.
The same thing happens with a skb updated by pskbmaypull() with a skbcloned skb. Li Shuang has reported quite a few crashes caused by this when doing testing over macvlan devices:
[] kernel BUG at net/core/skbuff.c:1970! [] Call Trace: [] skbclone+0x4d/0xb0 [] macvlanbroadcast+0xd8/0x160 [macvlan] [] macvlanprocessbroadcast+0x148/0x150 [macvlan] [] processonework+0x1a7/0x360 [] workerthread+0x30/0x390
[] kernel BUG at mm/usercopy.c:102! [] Call Trace: [] checkheapobject+0xd3/0x100 [] checkobjectsize+0xff/0x16b [] simplecopytoiter+0x1c/0x30 [] skbdatagramiter+0x7d/0x310 [] skbdatagramiter+0x2a5/0x310 [] skbcopydatagramiter+0x3b/0x90 [] tipcrecvmsg+0x14a/0x3a0 [tipc] [] sysrecvmsg+0x91/0x150 [] sysrecvmsg+0x7b/0xc0
[] kernel BUG at mm/slub.c:305! [] Call Trace: [] <IRQ> [] kmemcachefree+0x3ff/0x400 [] netifreceiveskbcore+0x12c/0xc40 [] ? kmemcachealloc+0x12e/0x270 [] netifreceiveskbinternal+0x3d/0xb0 [] ? getrxpageinfo+0x8e/0xa0 [be2net] [] bepoll+0x6ef/0xd00 [be2net] [] ? irqexit+0x4f/0x100 [] netrxaction+0x149/0x3b0
...
This patch is to fix it by linearizing the head skb if it has fraglist set in tipcbufappend(). Note that we choose to do this before calling skbunshare(), as skblinearize() will avoid skbcopy(). Also, we can not just drop the fraglist either as the early time.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Configuration
Update the kernel networking code/patch so that when reassembling TIPC messages, the head skb is linearized if it has a frag_list (avoid appending frag skb into a skb's frag_list).
Linux kernel networking (SKB handling in TIPC) skb linearization behavior when reassembling messages with head frag_list = linearize head skb when frag_list is present
Event History
Frequently Asked Questions
What is the severity of CVE-2021-47162?
CVE-2021-47162 has been categorized as having a moderate severity level.
How do I fix CVE-2021-47162?
To fix CVE-2021-47162, you should update to the latest stable version of the Linux kernel that includes the patch.
What systems are affected by CVE-2021-47162?
CVE-2021-47162 affects various versions of the Linux kernel that are vulnerable to the described issue.
What is the nature of the vulnerability in CVE-2021-47162?
The vulnerability in CVE-2021-47162 involves improper handling of the skb's frag_list during message reassembly.
Is CVE-2021-47162 actively exploited in the wild?
As of now, there is no evidence to suggest that CVE-2021-47162 is being actively exploited in the wild.