nvmet: validate device_path before enabling namespace
Subsystems (2)
PATCH 1/1 nvmet: validate device_path before enabling namespace
From: Yalagada Pavan Kumar <[email protected]>
When buffered_io is enabled, nvmet_bdev_ns_enable() returns -ENOTBLK without checking whether device_path is configured. nvmet_ns_enable() then falls back to nvmet_file_ns_enable(), which passes the NULL device_path to filp_open() and causes a NULL pointer dereference.
Validate device_path before attempting to enable to namespace and return -EINVAL when it has not been configured.
--- drivers/nvme/target/core.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/nvme/target/core.c +5 -0
@@ -591,6 +591,11 @@ int nvmet_ns_enable(struct nvmet_ns *ns)if (ns->enabled) goto out_unlock; +if (!ns->device_path) { + ret = -EINVAL ; + goto out_unlock; + } + ret =nvmet_bdev_ns_enable (ns);if (ret == -ENOTBLK ) ret =nvmet_file_ns_enable (ns);
Signature · 1 line
2.43.0
Keith Busch
maintainerQuoted 9 lines · On Wed, Sep 09, 2026 at 01:04:52AM +0530, [email protected] wrote:
From: Yalagada Pavan Kumar <[email protected]>
When
buffered_iois enabled,nvmet_bdev_ns_enable()returns-ENOTBLKwithout checking whetherdevice_pathis configured.nvmet_ns_enable()then falls back tonvmet_file_ns_enable(), which passes the NULLdevice_pathtofilp_open()and causes a NULL pointer dereference.Validate
device_pathbefore attempting to enable to namespace and return-EINVALwhen it has not been configured.
This was alraedy closed:
Quoted 8 lines · Keith Busch
Quoted 7 lines · On Wed, Sep 09, 2026 at 01:04:52AM +0530, [email protected] wrote:
From: Yalagada Pavan Kumar <[email protected]>
When
buffered_iois enabled,nvmet_bdev_ns_enable()returns-ENOTBLKwithout checking whetherdevice_pathis configured.nvmet_ns_enable()then falls back tonvmet_file_ns_enable(), which passes the NULLdevice_pathtofilp_open()and causes a NULL pointer dereference.
Quoted 6 lines
Quoted 2 lines
Validate
device_pathbefore attempting to enable to namespace and return-EINVALwhen it has not been configured.This was alraedy closed:
Good to hear this has already been fixed. I'll drop the patch.
Thanks
Pavan