mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] nvmet: validate device_path before enabling namespace
@ 2026-09-08 19:34 pavankumaryalagada
  2026-09-08 19:57 ` Keith Busch
  0 siblings, 1 reply; 3+ messages in thread
From: pavankumaryalagada @ 2026-09-08 19:34 UTC (permalink / raw)
  To: hch, sagi
  Cc: kch, linux-nvme, linux-kernel, skhan, Yalagada Pavan Kumar,
	syzbot+6c46a179b56c651c4c96

From: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>

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.

Fixes: 6f6d604b4ef8 ("nvmet: allow bdev in buffered_io mode")
Reported-by: syzbot+6c46a179b56c651c4c96@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=6c46a179b56c651c4c96
Tested-by: syzbot+6c46a179b56c651c4c96@syzkaller.appspotmail.com
Signed-off-by: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
---
 drivers/nvme/target/core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c
index d74c01c98f19..336013139ef6 100644
--- a/drivers/nvme/target/core.c
+++ b/drivers/nvme/target/core.c
@@ -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);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet: validate device_path before enabling namespace
  2026-09-08 19:34 [PATCH] nvmet: validate device_path before enabling namespace pavankumaryalagada
@ 2026-09-08 19:57 ` Keith Busch
  2026-09-09  8:11   ` Yalagada Pavan Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: Keith Busch @ 2026-09-08 19:57 UTC (permalink / raw)
  To: pavankumaryalagada
  Cc: hch, sagi, kch, linux-nvme, linux-kernel, skhan,
	syzbot+6c46a179b56c651c4c96

On Wed, Sep 09, 2026 at 01:04:52AM +0530, pavankumaryalagada@gmail.com wrote:
> From: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
> 
> 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.

This was alraedy closed:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=09d0c07bd9ce3b2f2d993f672698d32a17543c32

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] nvmet: validate device_path before enabling namespace
  2026-09-08 19:57 ` Keith Busch
@ 2026-09-09  8:11   ` Yalagada Pavan Kumar
  0 siblings, 0 replies; 3+ messages in thread
From: Yalagada Pavan Kumar @ 2026-09-09  8:11 UTC (permalink / raw)
  To: Keith Busch
  Cc: hch, sagi, kch, linux-nvme, linux-kernel, skhan,
	syzbot+6c46a179b56c651c4c96

On Tue, Sep 08, 2026 at 01:57:17PM -0600, Keith Busch wrote:
> On Wed, Sep 09, 2026 at 01:04:52AM +0530, pavankumaryalagada@gmail.com wrote:
> > From: Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>
> > 
> > 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.
> 
> This was alraedy closed:
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=09d0c07bd9ce3b2f2d993f672698d32a17543c32

Good to hear this has already been fixed. I'll drop the patch.

Thanks
Pavan


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-09  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-08 19:34 [PATCH] nvmet: validate device_path before enabling namespace pavankumaryalagada
2026-09-08 19:57 ` Keith Busch
2026-09-09  8:11   ` Yalagada Pavan Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®