Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: pavankumaryalagada@gmail.com
To: hch@lst.de, sagi@grimberg.me
Cc: kch@nvidia.com, linux-nvme@lists.infradead.org,
	linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
	Yalagada Pavan Kumar <pavankumaryalagada@gmail.com>,
	syzbot+6c46a179b56c651c4c96@syzkaller.appspotmail.com
Subject: [PATCH] nvmet: validate device_path before enabling namespace
Date: Wed,  9 Sep 2026 01:04:52 +0530	[thread overview]
Message-ID: <20260908193452.53347-1-pavankumaryalagada@gmail.com> (raw)

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



             reply	other threads:[~2026-09-08 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 19:34 pavankumaryalagada [this message]
2026-09-08 19:57 ` [PATCH] nvmet: validate device_path before enabling namespace Keith Busch
2026-09-09  8:11   ` Yalagada Pavan Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260908193452.53347-1-pavankumaryalagada@gmail.com \
    --to=pavankumaryalagada@gmail.com \
    --cc=hch@lst.de \
    --cc=kch@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=sagi@grimberg.me \
    --cc=skhan@linuxfoundation.org \
    --cc=syzbot+6c46a179b56c651c4c96@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox