Patch "nvme: prevent double free in nvme_alloc_ns() error handling" has been added to the 5.6-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: prevent double free in nvme_alloc_ns() error handling

to the 5.6-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-prevent-double-free-in-nvme_alloc_ns-error-hand.patch
and it can be found in the queue-5.6 subdirectory.

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



commit 30accff1e2b86a657b6ba4b3d35e1cf9fedb7a59
Author: Niklas Cassel <niklas.cassel@xxxxxxx>
Date:   Mon Apr 27 14:34:41 2020 +0200

    nvme: prevent double free in nvme_alloc_ns() error handling
    
    commit 132be62387c7a72a38872676c18b0dfae264adb8 upstream.
    
    When jumping to the out_put_disk label, we will call put_disk(), which will
    trigger a call to disk_release(), which calls blk_put_queue().
    
    Later in the cleanup code, we do blk_cleanup_queue(), which will also call
    blk_put_queue().
    
    Putting the queue twice is incorrect, and will generate a KASAN splat.
    
    Set the disk->queue pointer to NULL, before calling put_disk(), so that the
    first call to blk_put_queue() will not free the queue.
    
    The second call to blk_put_queue() uses another pointer to the same queue,
    so this call will still free the queue.
    
    Fixes: 85136c010285 ("lightnvm: simplify geometry enumeration")
    Signed-off-by: Niklas Cassel <niklas.cassel@xxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 652ca87dac949..fb4c35a430650 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -3580,6 +3580,8 @@ static int nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid)
 
 	return 0;
  out_put_disk:
+	/* prevent double queue cleanup */
+	ns->disk->queue = NULL;
 	put_disk(ns->disk);
  out_unlink_ns:
 	mutex_lock(&ctrl->subsys->lock);



[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