Subject: CVE-2024-26739: net/sched: act_mirred: don't override retval if we already lost the skb

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

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

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

net/sched: act_mirred: don't override retval if we already lost the skb

If we're redirecting the skb, and haven't called tcf_mirred_forward(),
yet, we need to tell the core to drop the skb by setting the retcode
to SHOT. If we have called tcf_mirred_forward(), however, the skb
is out of our hands and returning SHOT will lead to UaF.

Move the retval override to the error path which actually need it.

The Linux kernel CVE team has assigned CVE-2024-26739 to this issue.

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

	Issue introduced in 4.19 with commit e5cf1baf92cb and fixed in 6.6.19 with commit 28cdbbd38a44
	Issue introduced in 4.19 with commit e5cf1baf92cb and fixed in 6.7.7 with commit f4e294bbdca8
	Issue introduced in 4.19 with commit e5cf1baf92cb and fixed in 6.8 with commit 166c2c8a6a4d

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-26739
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/sched/act_mirred.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/28cdbbd38a4413b8eff53399b3f872fd4e80db9d
	https://git.kernel.org/stable/c/f4e294bbdca8ac8757db436fc82214f3882fc7e7
	https://git.kernel.org/stable/c/166c2c8a6a4dc2e4ceba9e10cfe81c3e469e3210