Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1317671 > unrolled thread

[patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2016-01-26 10:40 +0100
Last post2016-01-26 11:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity() Dan Carpenter <dan.carpenter@oracle.com> - 2016-01-26 10:40 +0100
    Re: [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity() Matias Bjørling <m@bjorling.me> - 2016-01-26 11:00 +0100

#1317671 — [patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()

FromDan Carpenter <dan.carpenter@oracle.com>
Date2016-01-26 10:40 +0100
Subject[patch] nvme: lightnvm: buffer overflow in nvme_nvm_identity()
Message-ID<qV8gq-28S-5@gated-at.bofh.it>
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:

[toc] | [next] | [standalone]


#1317681

FromMatias Bjørling <m@bjorling.me>
Date2016-01-26 11:00 +0100
Message-ID<qV8zL-2fZ-5@gated-at.bofh.it>
In reply to#1317671
On 01/26/2016 10:27 AM, Dan Carpenter wrote:
> 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.
> 

Thanks, Dan. You are right. The four bytes are overwritten afterwards
and hid the issue.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web