Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3411400pxb; Wed, 13 Oct 2021 05:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3K+gGwJROHkR4In2FkynxMYiYn72dmpnto6xtaxo6V5N6G3ou+wtBoxumcN6uED+E6yck X-Received: by 2002:a05:6a00:1352:b0:44d:4573:3ac2 with SMTP id k18-20020a056a00135200b0044d45733ac2mr7457451pfu.12.1634128567669; Wed, 13 Oct 2021 05:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634128567; cv=none; d=google.com; s=arc-20160816; b=KuzOlRyIgsiSyHoxByz/VT6japxhfXopbatp6wuFb7G7hRDex2eXp57joQU7gPusbN UhpfyDevoEDSJpqtADyNJ4IkOwmhThfu9+nPO4TYX/bYokj9a7INX+e7IGH8WgtVoYyQ Gt7YKO7dA5/nWktrx8z5wANUlrwKngHWzH715uR8CJii0rniEiTTtaUg5twVrWQXLCQw uDihN5U21K4Uf1Bn0NnolFUjPVo8PnhOECRB6XlxQLJ4y+ncu0NathUh6W2BFqODSAyR O6Vg0DLmp8iBlq9LhxfLRl8MLcWqXcEJbXuO6M+qm9N67CXwAn8pmT9t5n2pDlEDSQ4C 4Q/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=icmQtzGW1I9aNeYIPHd+HyscMc2NTbBX1tevUyNL3tU=; b=IZngdkfthZ9LvpYeJVVM9eb1B8xqB9c9UbiNEWUFH5Ruyg92uH8zo+wO8yvCUjiXA+ PmYY1QL9vOukBDSpiBoIMcXSWa4MBqzklb34tDSZ+K5X7AH2zEa9iS7TH+S695bBwiuk asxxQxE3FrvfxSxOpqFEGxpb4XRkLta8+qCcA5DYUfUc1gDkv6ApB45Q8j8sprVi/cSs /dxCmAzQWZp8lCno3TB5J3f4IlfdX7stkDTJ/zLRL5ElxkTbISzu6M1Nqt2CflmAqdPj vjl+V+lcR2dH8AW1/oB+UZih48D0Jd6CX9APkiLfQx7UJfQIbWP/+8scrfsdJgjCV2Ne yWsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=8F3RiOv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v11si17534654pgj.19.2021.10.13.05.35.54; Wed, 13 Oct 2021 05:36:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=8F3RiOv1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232491AbhJMMgl (ORCPT + 99 others); Wed, 13 Oct 2021 08:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231145AbhJMMgk (ORCPT ); Wed, 13 Oct 2021 08:36:40 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB466C061570 for ; Wed, 13 Oct 2021 05:34:36 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id a25so9557882edx.8 for ; Wed, 13 Oct 2021 05:34:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=icmQtzGW1I9aNeYIPHd+HyscMc2NTbBX1tevUyNL3tU=; b=8F3RiOv1P1mDb3ddBj4vql6etzsVA/HQ8bcyDNuhobirPCXuxk5IXPSrQqZZkBo3A+ SHKFL0Rv8ONqLvky2T3/RtxFWy4omkDz2DFJyIKLX8SIZmILoe+CflWW84y56fM0FxMe iP1X66dCzePfV57iNCKktzMjSPSlNgrsNosysu0GxfCJRdwwGJlbaFf/QGtQuSGyZWhr 7BpwKeu7Cwh2MHRTm0ZAxQ245e6w3l48WzVwmsz+8G9sbiqCEcv561SGNgQmqHMtRaps OcZ3081EIdTBRNIHuSoOnvkgoZ+KvCUTNY+TADO4S+KxNDXYtr5dR8rfsY7+CP+Bu8Ch AbpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=icmQtzGW1I9aNeYIPHd+HyscMc2NTbBX1tevUyNL3tU=; b=gFoStXbqwSowiPSq2xbzgGxKGnNlsbxz/7mEB6aHBwsqnHuJKE7TNdBg+QjLIbPBhK jMUVhpbwxgU5tW5A2zVsBf4H4WgujD5JaztBPOTR7PUpzLCO3WNZIG6Gahrbd6zyV0rL o4rd2jR4xh8kty+2zc3ksAYYSBvAiFPGNw7dLYJ1lH+1CBludIQpylw8djhOlen22hJW YTeLK9XA2iZLjnQChBv46+l1FswZWA2gQWNcklSYv+R6LKbXpJEsZFRX/VJd7L7ovnGl juhwBgRjt0xp1zvLzcbu/4W6eZskceMPR4Jf0EC+f3TI5rUlEGai4fo28/JWBugjqiTr Sn3A== X-Gm-Message-State: AOAM532noTxSW8DI0/SOgycMwonrR5np5jUhVXGdnD/R6c02TORcQD6+ jAkm5zclsuC1dgiKWlQqqfyTYqQQ9zjjJNd4MfFm X-Received: by 2002:a17:906:5590:: with SMTP id y16mr40139659ejp.286.1634128473086; Wed, 13 Oct 2021 05:34:33 -0700 (PDT) MIME-Version: 1.0 References: <20210809101609.148-1-xieyongji@bytedance.com> <20211004112623-mutt-send-email-mst@kernel.org> <20211005062359-mutt-send-email-mst@kernel.org> <20211011114041.GB16138@lst.de> <20211013082025-mutt-send-email-mst@kernel.org> In-Reply-To: <20211013082025-mutt-send-email-mst@kernel.org> From: Yongji Xie Date: Wed, 13 Oct 2021 20:34:22 +0800 Message-ID: Subject: Re: [PATCH v5] virtio-blk: Add validation for block size in config space To: "Michael S. Tsirkin" Cc: Christoph Hellwig , Jason Wang , Stefan Hajnoczi , virtualization , linux-block@vger.kernel.org, linux-kernel , Kevin Wolf , Jens Axboe Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 8:21 PM Michael S. Tsirkin wrote: > > On Mon, Oct 11, 2021 at 01:40:41PM +0200, Christoph Hellwig wrote: > > On Tue, Oct 05, 2021 at 06:42:43AM -0400, Michael S. Tsirkin wrote: > > > Stefan also pointed out this duplicates the logic from > > > > > > if (blksize < 512 || blksize > PAGE_SIZE || !is_power_of_2(blksize)) > > > return -EINVAL; > > > > > > > > > and a bunch of other places. > > > > > > > > > Would it be acceptable for blk layer to validate the input > > > instead of having each driver do it's own thing? > > > Maybe inside blk_queue_logical_block_size? > > > > I'm pretty sure we want down that before. Let's just add a helper > > just for that check for now as part of this series. Actually validating > > in in blk_queue_logical_block_size seems like a good idea, but returning > > errors from that has a long tail. > > Xie Yongji, I think I will revert this patch for now - can you > please work out adding that helper and using it in virtio? > Fine, I will do it. Thanks, Yongji