Subject: CVE-2023-52653: SUNRPC: fix a memleak in gss_import_v2_context

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

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

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

SUNRPC: fix a memleak in gss_import_v2_context

The ctx->mech_used.data allocated by kmemdup is not freed in neither
gss_import_v2_context nor it only caller gss_krb5_import_sec_context,
which frees ctx on error.

Thus, this patch reform the last call of gss_import_v2_context to the
gss_krb5_import_ctx_v2, preventing the memleak while keepping the return
formation.

The Linux kernel CVE team has assigned CVE-2023-52653 to this issue.

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

	Issue introduced in 2.6.35 with commit 47d848077629 and fixed in 6.6.23 with commit 99044c01ed53
	Issue introduced in 2.6.35 with commit 47d848077629 and fixed in 6.7.11 with commit 47ac11db93e7
	Issue introduced in 2.6.35 with commit 47d848077629 and fixed in 6.8.2 with commit d111e30d9cd8
	Issue introduced in 2.6.35 with commit 47d848077629 and fixed in 6.9 with commit e67b652d8e85

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-2023-52653
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/sunrpc/auth_gss/gss_krb5_mech.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/99044c01ed5329e73651c054d8a4baacdbb1a27c
	https://git.kernel.org/stable/c/47ac11db93e74ac49cd6c3fc69bcbc5964c4a8b4
	https://git.kernel.org/stable/c/d111e30d9cd846bb368faf3637dc0f71fcbcf822
	https://git.kernel.org/stable/c/e67b652d8e8591d3b1e569dbcdfcee15993e91fa