All of lore.kernel.org
 help / color / mirror / Atom feed
From: Klaus Jensen <its@irrelevant.dk>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
	qemu-block@nongnu.org, Klaus Jensen <k.jensen@samsung.com>,
	Max Reitz <mreitz@redhat.com>, Klaus Jensen <its@irrelevant.dk>,
	Minwoo Im <minwoo.im.dev@gmail.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Keith Busch <kbusch@kernel.org>
Subject: [PULL for-6.0 v2 10/10] hw/block/nvme: fix out-of-bounds read in nvme_subsys_ctrl
Date: Wed,  7 Apr 2021 07:46:35 +0200	[thread overview]
Message-ID: <20210407054635.189440-11-its@irrelevant.dk> (raw)
In-Reply-To: <20210407054635.189440-1-its@irrelevant.dk>

From: Klaus Jensen <k.jensen@samsung.com>

nvme_subsys_ctrl() is used in contexts where the given controller
identifier is from an untrusted source. Like its friends nvme_ns() and
nvme_subsys_ns(), nvme_subsys_ctrl() should just return NULL if an
invalid identifier is given.

Fixes: 645ce1a70cb6 ("hw/block/nvme: support namespace attachment command")
Cc: Minwoo Im <minwoo.im.dev@gmail.com>
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
---
 hw/block/nvme-subsys.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/block/nvme-subsys.h b/hw/block/nvme-subsys.h
index 1cbcad9be23e..7d7ef5f7f12b 100644
--- a/hw/block/nvme-subsys.h
+++ b/hw/block/nvme-subsys.h
@@ -36,7 +36,7 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp);
 static inline NvmeCtrl *nvme_subsys_ctrl(NvmeSubsystem *subsys,
         uint32_t cntlid)
 {
-    if (!subsys) {
+    if (!subsys || cntlid >= NVME_SUBSYS_MAX_CTRLS) {
         return NULL;
     }
 
-- 
2.31.1



  parent reply	other threads:[~2021-04-07  6:06 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-07  5:46 [PULL for-6.0 v2 00/10] emulated nvme fixes for -rc3 Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 01/10] hw/block/nvme: fix pi constraint check Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 02/10] hw/block/nvme: fix missing string representation for ns attachment Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 03/10] hw/block/nvme: fix the nsid 'invalid' value Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 04/10] hw/block/nvme: fix warning about legacy namespace configuration Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 05/10] hw/block/nvme: update dmsrl limit on namespace detachment Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 06/10] hw/block/nvme: fix handling of private namespaces Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 07/10] hw/block/nvme: add missing copyright headers Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 08/10] hw/block/nvme: fix ns attachment out-of-bounds read Klaus Jensen
2021-04-07  5:46 ` [PULL for-6.0 v2 09/10] hw/block/nvme: fix assert crash in nvme_subsys_ns Klaus Jensen
2021-04-07  5:46 ` Klaus Jensen [this message]
2021-04-07  8:03 ` [PULL for-6.0 v2 00/10] emulated nvme fixes for -rc3 Peter Maydell
2021-04-07  8:45   ` Klaus Jensen

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=20210407054635.189440-11-its@irrelevant.dk \
    --to=its@irrelevant.dk \
    --cc=fam@euphon.net \
    --cc=k.jensen@samsung.com \
    --cc=kbusch@kernel.org \
    --cc=kwolf@redhat.com \
    --cc=minwoo.im.dev@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.