All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()
Date: Tue, 26 Jan 2016 09:27:34 +0000	[thread overview]
Message-ID: <20160126092734.GE15717@mwanda> (raw)

nvme_nvm_id->ppaf is 4 bytes larger than nvm_id->ppaf.  We're using the
larger size struct for the sizeof() so we end up corrupting the
first four bytes of nvm_id->groups[].  It doesn't look like we actually
want to copy those last bytes anyway.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static analysis, not tested.  Please review this one carefully, I think
this bug would show up in testing.

diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 5cd3725..0f0864f 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -319,7 +319,7 @@ static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id)
 	nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap);
 	nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom);
 	memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf,
-					sizeof(struct nvme_nvm_addr_format));
+					sizeof(struct nvm_addr_format));
 
 	ret = init_grps(nvm_id, nvme_nvm_id);
 out:

WARNING: multiple messages have this Message-ID (diff)
From: dan.carpenter@oracle.com (Dan Carpenter)
Subject: [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()
Date: Tue, 26 Jan 2016 12:27:34 +0300	[thread overview]
Message-ID: <20160126092734.GE15717@mwanda> (raw)

nvme_nvm_id->ppaf is 4 bytes larger than nvm_id->ppaf.  We're using the
larger size struct for the sizeof() so we end up corrupting the
first four bytes of nvm_id->groups[].  It doesn't look like we actually
want to copy those last bytes anyway.

Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>
---
Static analysis, not tested.  Please review this one carefully, I think
this bug would show up in testing.

diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 5cd3725..0f0864f 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -319,7 +319,7 @@ static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id)
 	nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap);
 	nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom);
 	memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf,
-					sizeof(struct nvme_nvm_addr_format));
+					sizeof(struct nvm_addr_format));
 
 	ret = init_grps(nvm_id, nvme_nvm_id);
 out:

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: "Keith Busch" <keith.busch@intel.com>, "Matias Bjørling" <m@bjorling.me>
Cc: Jens Axboe <axboe@fb.com>,
	linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()
Date: Tue, 26 Jan 2016 12:27:34 +0300	[thread overview]
Message-ID: <20160126092734.GE15717@mwanda> (raw)

nvme_nvm_id->ppaf is 4 bytes larger than nvm_id->ppaf.  We're using the
larger size struct for the sizeof() so we end up corrupting the
first four bytes of nvm_id->groups[].  It doesn't look like we actually
want to copy those last bytes anyway.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
Static analysis, not tested.  Please review this one carefully, I think
this bug would show up in testing.

diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c
index 5cd3725..0f0864f 100644
--- a/drivers/nvme/host/lightnvm.c
+++ b/drivers/nvme/host/lightnvm.c
@@ -319,7 +319,7 @@ static int nvme_nvm_identity(struct nvm_dev *nvmdev, struct nvm_id *nvm_id)
 	nvm_id->cap = le32_to_cpu(nvme_nvm_id->cap);
 	nvm_id->dom = le32_to_cpu(nvme_nvm_id->dom);
 	memcpy(&nvm_id->ppaf, &nvme_nvm_id->ppaf,
-					sizeof(struct nvme_nvm_addr_format));
+					sizeof(struct nvm_addr_format));
 
 	ret = init_grps(nvm_id, nvme_nvm_id);
 out:

             reply	other threads:[~2016-01-26  9:27 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26  9:27 Dan Carpenter [this message]
2016-01-26  9:27 ` [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity() Dan Carpenter
2016-01-26  9:27 ` Dan Carpenter
2016-01-26  9:56 ` Matias Bjørling
2016-01-26  9:56   ` Matias Bjørling
2016-01-26  9:56   ` Matias Bjørling

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=20160126092734.GE15717@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    /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.