Revert "firmware_loader: use kernel credentials when reading firmware"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 14:19:05 +0000 (16:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Apr 2022 14:19:39 +0000 (16:19 +0200)
This reverts commit 3677563eb8731e1ad5970e3e57f74e5f9d63502a as it leaks
memory :(

Reported-by: Qian 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/base/firmware_loader/main.c

index 9a8579e..921d955 100644 (file)
@@ -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);