CVE-2021-47298: bpf, sockmap: Fix potential memory leak on unlikely error case
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
bpf, sockmap: Fix potential memory leak on unlikely error case
If skb_linearize is needed and fails we could leak a msg on the error handling. To fix ensure we kfree the msg block before returning error. Found during code review.
The Linux kernel CVE team has assigned CVE-2021-47298 to this issue.
Affected and fixed versions
===========================
Issue introduced in 5.10 with commit 4363023d2668 and fixed in 5.10.54 with commit 715f378f4290 Issue introduced in 5.10 with commit 4363023d2668 and fixed in 5.13.6 with commit 6c508a1c6c62 Issue introduced in 5.10 with commit 4363023d2668 and fixed in 5.14 with commit 7e6b27a69167
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2021-47298
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
net/core/skmsg.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/715f378f42909c401ec043f5150c4fdf57fb8889 https://git.kernel.org/stable/c/6c508a1c6c62793dc6e6872cad4b200097bab7c9 https://git.kernel.org/stable/c/7e6b27a69167f97c56b5437871d29e9722c3e470