Patch "nvmet: seset ns->file when open fails" has been added to the 5.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

    nvmet: seset ns->file when open fails

to the 5.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:
     nvmet-seset-ns-file-when-open-fails.patch
and it can be found in the queue-5.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 d730761bc330615a29b5a4783521408cddc75b51
Author: Daniel Wagner <dwagner@xxxxxxx>
Date:   Wed May 12 16:50:05 2021 +0200

    nvmet: seset ns->file when open fails
    
    [ Upstream commit 85428beac80dbcace5b146b218697c73e367dcf5 ]
    
    Reset the ns->file value to NULL also in the error case in
    nvmet_file_ns_enable().
    
    The ns->file variable points either to file object or contains the
    error code after the filp_open() call. This can lead to following
    problem:
    
    When the user first setups an invalid file backend and tries to enable
    the ns, it will fail. Then the user switches over to a bdev backend
    and enables successfully the ns. The first received I/O will crash the
    system because the IO backend is chosen based on the ns->file value:
    
    static u16 nvmet_parse_io_cmd(struct nvmet_req *req)
    {
            [...]
    
            if (req->ns->file)
                    return nvmet_file_parse_io_cmd(req);
    
            return nvmet_bdev_parse_io_cmd(req);
    }
    
    Reported-by: Enzo Matsumiya <ematsumiya@xxxxxxxx>
    Signed-off-by: Daniel Wagner <dwagner@xxxxxxx>
    Signed-off-by: Christoph Hellwig <hch@xxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvme/target/io-cmd-file.c b/drivers/nvme/target/io-cmd-file.c
index 05453f5d1448..6ca17a0babae 100644
--- a/drivers/nvme/target/io-cmd-file.c
+++ b/drivers/nvme/target/io-cmd-file.c
@@ -38,9 +38,11 @@ int nvmet_file_ns_enable(struct nvmet_ns *ns)
 
 	ns->file = filp_open(ns->device_path, flags, 0);
 	if (IS_ERR(ns->file)) {
-		pr_err("failed to open file %s: (%ld)\n",
-				ns->device_path, PTR_ERR(ns->file));
-		return PTR_ERR(ns->file);
+		ret = PTR_ERR(ns->file);
+		pr_err("failed to open file %s: (%d)\n",
+			ns->device_path, ret);
+		ns->file = NULL;
+		return ret;
 	}
 
 	ret = vfs_getattr(&ns->file->f_path,



[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