lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEK8JBC8SzabKnG_K-axf-7Fbvc6Ng57gh=5CJjfd8U1uqjvRQ@mail.gmail.com>
Date:   Thu, 14 Jan 2021 13:17:03 +0800
From:   Feng Li <lifeng1519@...il.com>
To:     Sagi Grimberg <sagi@...mberg.me>
Cc:     Johannes Thumshirn <Johannes.Thumshirn@....com>,
        Li Feng <fengli@...rtx.com>,
        "martin.petersen@...cle.com" <martin.petersen@...cle.com>,
        Keith Busch <kbusch@...nel.org>, Jens Axboe <axboe@...com>,
        Christoph Hellwig <hch@....de>,
        "open list:NVM EXPRESS DRIVER" <linux-nvme@...ts.infradead.org>,
        open list <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] nvme: reject the ns when the block size is smaller than a sector

Sagi Grimberg <sagi@...mberg.me> 于2021年1月14日周四 上午6:13写道:
>
>
> >> The nvme spec(1.4a, figure 248) says:
> >> "A value smaller than 9 (i.e., 512 bytes) is not supported."
> >>
> >> Signed-off-by: Li Feng <fengli@...rtx.com>
> >> ---
> >>   drivers/nvme/host/core.c | 6 ++++++
> >>   1 file changed, 6 insertions(+)
> >>
> >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> >> index f320273fc672..1f02e6e49a05 100644
> >> --- a/drivers/nvme/host/core.c
> >> +++ b/drivers/nvme/host/core.c
> >> @@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *ns, struct nvme_id_ns *id)
> >>
> >>      blk_mq_freeze_queue(ns->disk->queue);
> >>      ns->lba_shift = id->lbaf[lbaf].ds;
> >> +    if (ns->lba_shift < 9) {
> >> +            pr_warn("%s: bad lba_shift(%d)\n", ns->disk->disk_name, ns->lba_shift);
> >> +            ret = -1;
>
> Meaningful errno would be useful. Also better to use dev_warn
>
> >> +            goto out_unfreeze;
> >> +    }
> >> +
> >>      nvme_set_queue_limits(ns->ctrl, ns->queue);
> >>
> >>      if (ns->head->ids.csi == NVME_CSI_ZNS) {
> >>
> >
> >
> > But this only catches a physical block size < 512 for NVMe, not any other block device.
> >
> > Please fix it for the general case in blk_queue_physical_block_size().
>
> We actually call that later and would probably be better to check here..
Thanks for your comments.

The prototype is:
void blk_queue_logical_block_size(struct request_queue *, unsigned int);

So change it to:
bool blk_queue_logical_block_size(struct request_queue *, unsigned int);

And check all callers of this function, right?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ