Patch "nvme-core: fix memory leak in dhchap_secret_store" has been added to the 6.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    nvme-core: fix memory leak in dhchap_secret_store

to the 6.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvme-core-fix-memory-leak-in-dhchap_secret_store.patch
and it can be found in the queue-6.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 896136bce2d9b1561fa1ab3372acf579775f9dd4
Author: Chaitanya Kulkarni <kch@xxxxxxxxxx>
Date:   Fri Apr 28 00:31:12 2023 -0700

    nvme-core: fix memory leak in dhchap_secret_store
    
    [ Upstream commit a836ca33c5b07d34dd5347af9f64d25651d12674 ]
    
    Free dhchap_secret in nvme_ctrl_dhchap_secret_store() before we return
    fix following kmemleack:-
    
    unreferenced object 0xffff8886376ea800 (size 64):
      comm "check", pid 22048, jiffies 4344316705 (age 92.199s)
      hex dump (first 32 bytes):
        44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67  DHHC-1:00:nxr5Kg
        75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c  uX4uoAxsJa4c/huL
      backtrace:
        [<0000000030ce5d4b>] __kmalloc+0x4b/0x130
        [<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
        [<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
        [<00000000437e7ced>] vfs_write+0x2ba/0x3c0
        [<00000000f9491baf>] ksys_write+0x5f/0xe0
        [<000000001c46513d>] do_syscall_64+0x3b/0x90
        [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    unreferenced object 0xffff8886376eaf00 (size 64):
      comm "check", pid 22048, jiffies 4344316736 (age 92.168s)
      hex dump (first 32 bytes):
        44 48 48 43 2d 31 3a 30 30 3a 6e 78 72 35 4b 67  DHHC-1:00:nxr5Kg
        75 58 34 75 6f 41 78 73 4a 61 34 63 2f 68 75 4c  uX4uoAxsJa4c/huL
      backtrace:
        [<0000000030ce5d4b>] __kmalloc+0x4b/0x130
        [<000000009be1cdc1>] nvme_ctrl_dhchap_secret_store+0x8f/0x160 [nvme_core]
        [<00000000ac06c96a>] kernfs_fop_write_iter+0x12b/0x1c0
        [<00000000437e7ced>] vfs_write+0x2ba/0x3c0
        [<00000000f9491baf>] ksys_write+0x5f/0xe0
        [<000000001c46513d>] do_syscall_64+0x3b/0x90
        [<00000000ecf348fe>] entry_SYSCALL_64_after_hwframe+0x72/0xdc
    
    Fixes: f50fff73d620 ("nvme: implement In-Band authentication")
    Signed-off-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>
    Tested-by: Yi Zhang <yi.zhang@xxxxxxxxxx>
    Reviewed-by: Christoph Hellwig <hch@xxxxxx>
    Reviewed-by: Sagi Grimberg <sagi@xxxxxxxxxxx>
    Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3ec38e2b91732..c2096f0d50537 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3872,8 +3872,10 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
 		int ret;
 
 		ret = nvme_auth_generate_key(dhchap_secret, &key);
-		if (ret)
+		if (ret) {
+			kfree(dhchap_secret);
 			return ret;
+		}
 		kfree(opts->dhchap_secret);
 		opts->dhchap_secret = dhchap_secret;
 		host_key = ctrl->host_key;
@@ -3881,7 +3883,8 @@ static ssize_t nvme_ctrl_dhchap_secret_store(struct device *dev,
 		ctrl->host_key = key;
 		mutex_unlock(&ctrl->dhchap_auth_mutex);
 		nvme_auth_free_key(host_key);
-	}
+	} else
+		kfree(dhchap_secret);
 	/* Start re-authentication */
 	dev_info(ctrl->device, "re-authenticating controller\n");
 	queue_work(nvme_wq, &ctrl->dhchap_auth_work);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux