linux/drivers/nvme/target
Daniel Wagner e207bbf555 nvmet: seset ns->file when open fails
[ Upstream commit 85428beac8 ]

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@suse.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2021-05-26 12:06:50 +02:00
..
admin-cmd.c nvmet: remove unsupported command noise 2021-05-22 11:40:54 +02:00
configfs.c nvmet: fix a memory leak 2020-08-21 17:14:27 -06:00
core.c nvmet: fix memory leak in nvmet_alloc_ctrl() 2021-05-26 12:06:48 +02:00
discovery.c nvmet: return proper error code from discovery ctrl 2021-05-11 14:47:26 +02:00
fabrics-cmd.c nvmet: add metadata/T10-PI support 2020-05-27 07:12:40 +02:00
fc.c nvmet-fc: fix missing check for no hostport struct 2020-09-27 09:14:19 +02:00
fcloop.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
io-cmd-bdev.c nvmet: fix inline bio check for bdev-ns 2021-05-19 10:13:14 +02:00
io-cmd-file.c nvmet: seset ns->file when open fails 2021-05-26 12:06:50 +02:00
Kconfig nvmet: introduce the passthru Kconfig option 2020-07-29 07:45:21 +02:00
loop.c nvme-loop: fix memory leak in nvme_loop_create_ctrl() 2021-05-26 12:06:48 +02:00
Makefile nvmet: add passthru code to process commands 2020-07-29 07:45:21 +02:00
nvmet.h nvmet: remove unused ctrl->cqs 2021-05-26 12:06:48 +02:00
passthru.c nvmet: don't use BLK_MQ_REQ_NOWAIT for passthru 2020-10-22 15:28:02 +02:00
rdma.c nvmet-rdma: Fix NULL deref when SEND is completed with error 2021-05-19 10:13:14 +02:00
tcp.c nvmet-tcp: fix a segmentation fault during io parsing error 2021-05-14 09:50:27 +02:00
trace.c nvmet: trace: parse Get LBA Status command in detail 2019-08-29 12:55:01 -07:00
trace.h nvmet: fix a NULL pointer dereference when tracing the flush command 2020-10-27 10:02:50 +01:00