Commit 4388f887 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

Revert "firmware_loader: use kernel credentials when reading firmware"



This reverts commit 3677563e as it leaks
memory :(

Reported-by: default avatarQian Cai <quic_qiancai@quicinc.com>
Link: https://lore.kernel.org/r/20220427135823.GD71@qian


Cc: Thiébaud Weksteen <tweek@google.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: John Stultz <jstultz@google.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bd900901
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -798,8 +798,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
		  size_t offset, u32 opt_flags)
{
	struct firmware *fw = NULL;
	struct cred *kern_cred = NULL;
	const struct cred *old_cred;
	bool nondirect = false;
	int ret;

@@ -816,18 +814,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
	if (ret <= 0) /* error or already assigned */
		goto out;

	/*
	 * We are about to try to access the firmware file. Because we may have been
	 * called by a driver when serving an unrelated request from userland, we use
	 * the kernel credentials to read the file.
	 */
	kern_cred = prepare_kernel_cred(NULL);
	if (!kern_cred) {
		ret = -ENOMEM;
		goto out;
	}
	old_cred = override_creds(kern_cred);

	ret = fw_get_filesystem_firmware(device, fw->priv, "", NULL);

	/* Only full reads can support decompression, platform, and sysfs. */
@@ -858,8 +844,6 @@ _request_firmware(const struct firmware **firmware_p, const char *name,
	} else
		ret = assign_fw(fw, device);

	revert_creds(old_cred);

 out:
	if (ret < 0) {
		fw_abort_batch_reqs(fw);