CVE-2024-39489: ipv6: sr: fix memleak in seg6_hmac_init_algo
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
ipv6: sr: fix memleak in seg6_hmac_init_algo
seg6_hmac_init_algo returns without cleaning up the previous allocations if one fails, so it's going to leak all that memory and the crypto tfms.
Update seg6_hmac_exit to only free the memory when allocated, so we can reuse the code directly.
The Linux kernel CVE team has assigned CVE-2024-39489 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 4.19.316 with commit afd5730969ae Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 5.4.278 with commit 4a3fcf53725b Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 5.10.219 with commit daf341e0a231 Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 5.15.161 with commit 61d31ac85b45 Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 6.1.93 with commit 599a56542150 Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 6.6.33 with commit 0e44d6cbe8de Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 6.9.4 with commit f6a99ef4e056 Issue introduced in 4.10 with commit bf355b8d2c30 and fixed in 6.10-rc1 with commit efb9f4f19f8e
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-2024-39489
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/ipv6/seg6_hmac.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/afd5730969aec960a2fee4e5ee839a6014643976 https://git.kernel.org/stable/c/4a3fcf53725b70010d1cf869a2ba549fed6b8fb3 https://git.kernel.org/stable/c/daf341e0a2318b813427d5a78788c86f4a7f02be https://git.kernel.org/stable/c/61d31ac85b4572d11f8071855c0ccb4f32d76c0c https://git.kernel.org/stable/c/599a5654215092ac22bfc453f4fd3959c55ea821 https://git.kernel.org/stable/c/0e44d6cbe8de983470c3d2f978649783384fdcb6 https://git.kernel.org/stable/c/f6a99ef4e056c20a138a95cc51332b2b96c8f383 https://git.kernel.org/stable/c/efb9f4f19f8e37fde43dfecebc80292d179f56c6