Subject: CVE-2022-48809: net: fix a memleak when uncloning an skb dst and its metadata

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

net: fix a memleak when uncloning an skb dst and its metadata

When uncloning an skb dst and its associated metadata, a new
dst+metadata is allocated and later replaces the old one in the skb.
This is helpful to have a non-shared dst+metadata attached to a specific
skb.

The issue is the uncloned dst+metadata is initialized with a refcount of
1, which is increased to 2 before attaching it to the skb. When
tun_dst_unclone returns, the dst+metadata is only referenced from a
single place (the skb) while its refcount is 2. Its refcount will never
drop to 0 (when the skb is consumed), leading to a memory leak.

Fix this by removing the call to dst_hold in tun_dst_unclone, as the
dst+metadata refcount is already 1.

The Linux kernel CVE team has assigned CVE-2022-48809 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 4.9.302 with commit 4ac84498fbe8
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 4.14.267 with commit c1ff27d100e2
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 4.19.230 with commit 0be943916d78
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 5.4.180 with commit a80817adc2a4
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 5.10.101 with commit 00e6d6c3bc14
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 5.15.24 with commit fdcb263fa5cd
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 5.16.10 with commit 8b1087b998e2
	Issue introduced in 4.3 with commit fc4099f17240 and fixed in 5.17 with commit 9eeabdf17fa0

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-2022-48809
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:
	include/net/dst_metadata.h

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/4ac84498fbe84a00e7aef185e2bb3e40ce71eca4
	https://git.kernel.org/stable/c/c1ff27d100e2670b03cbfddb9117e5f9fc672540
	https://git.kernel.org/stable/c/0be943916d781df2b652793bb2d3ae4f9624c10a
	https://git.kernel.org/stable/c/a80817adc2a4c1ba26a7aa5f3ed886e4a18dff88
	https://git.kernel.org/stable/c/00e6d6c3bc14dfe32824e2c515f0e0f2d6ecf2f1
	https://git.kernel.org/stable/c/fdcb263fa5cda15b8cb24a641fa2718c47605314
	https://git.kernel.org/stable/c/8b1087b998e273f07be13dcb5f3ca4c309c7f108
	https://git.kernel.org/stable/c/9eeabdf17fa0ab75381045c867c370f4cc75a613