From: Klaus Jensen <its@irrelevant.dk>
To: Minwoo Im <minwoo.im.dev@gmail.com>
Cc: fam@euphon.net, kwolf@redhat.com, qemu-block@nongnu.org,
Gollu Appalanaidu <anaidu.gollu@samsung.com>,
qemu-devel@nongnu.org, mreitz@redhat.com, stefanha@redhat.com,
kbusch@kernel.org
Subject: Re: [PATCH] hw/block/nvme: slba equal to nsze is out of bounds if nlb is 1-based
Date: Fri, 9 Apr 2021 13:55:01 +0200 [thread overview]
Message-ID: <YHBAlXnRdYTU1m1P@apples.localdomain> (raw)
In-Reply-To: <20210409110518.GC2085@localhost>
[-- Attachment #1: Type: text/plain, Size: 1433 bytes --]
On Apr 9 20:05, Minwoo Im wrote:
>On 21-04-09 13:14:02, Gollu Appalanaidu wrote:
>> NSZE is the total size of the namespace in logical blocks. So the max
>> addressable logical block is NLB minus 1. So your starting logical
>> block is equal to NSZE it is a out of range.
>>
>> Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
>> ---
>> hw/block/nvme.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/block/nvme.c b/hw/block/nvme.c
>> index 953ec64729..be9edb1158 100644
>> --- a/hw/block/nvme.c
>> +++ b/hw/block/nvme.c
>> @@ -2527,7 +2527,7 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
>> uint64_t slba = le64_to_cpu(range[i].slba);
>> uint32_t nlb = le32_to_cpu(range[i].nlb);
>>
>> - if (nvme_check_bounds(ns, slba, nlb)) {
>> + if (nvme_check_bounds(ns, slba, nlb) || slba == ns->id_ns.nsze) {
>
>This patch also looks like check the boundary about slba. Should it be
>also checked inside of nvme_check_bounds() ?
The catch here is that DSM is like the only command where the number of
logical blocks is a 1s-based value. Otherwise we always have nlb > 0,
which means that nvme_check_bounds() will always "do the right thing".
My main gripe here is that (in my mind), by definition, a "zero length
range" does not reference any LBAs at all. So how can it result in LBA
Out of Range?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2021-04-09 11:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20210409074451epcas5p391e5b072e6245b8fe691d67bb42fb234@epcas5p3.samsung.com>
2021-04-09 7:44 ` [PATCH] hw/block/nvme: slba equal to nsze is out of bounds if nlb is 1-based Gollu Appalanaidu
2021-04-09 11:05 ` Minwoo Im
2021-04-09 11:55 ` Klaus Jensen [this message]
2021-04-09 12:31 ` Minwoo Im
2021-04-09 12:36 ` Klaus Jensen
2021-04-09 12:48 ` Minwoo Im
2021-04-09 15:30 ` Keith Busch
2021-04-09 16:57 ` 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=YHBAlXnRdYTU1m1P@apples.localdomain \
--to=its@irrelevant.dk \
--cc=anaidu.gollu@samsung.com \
--cc=fam@euphon.net \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).