Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1608359pxb; Mon, 11 Oct 2021 09:23:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxT96BNvfDHSEUVoSOmoL4lW7v55KJb1P5cUHGp1rW2eC/2w0AEWJsa1lXiANNP/hZLbuiI X-Received: by 2002:a17:90b:4ac1:: with SMTP id mh1mr9056477pjb.144.1633969427979; Mon, 11 Oct 2021 09:23:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633969427; cv=none; d=google.com; s=arc-20160816; b=yfewGgsHHHNKUSlmIX1i8gtR7Nqwx0VRzzTJXbWBn2bmEB7+SZUEN3P5ToAqD07wQa NWw2F8babuVZ37nIX2F0XWp5wzAscm1qNv4zzAy/7oQ9XUu2x0BQoTQgpi8xgu7VD5Fh DqxpxCVyaVTC2rjQws3SJlN/KG83CC0dev9xYbUpHgdAAx+XcUk9d3js6jw/rcZCT+fB V+2oF6nImFAqewhThIl6rbsws5/Co+QrZfoHFYGNcHbBUxxPizXHLROeJFyynAnASlaT me8PuKxgK9aYzXKQaD9i9kWi9bFRwVS1l7hAs5STkm0ZNIx9UVGM+2QEYHB83Xbq9ngB 1yqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=bJYNt8qVwVN/lsp00HfF57oDocLrYnrI30+0kGuJTVs=; b=083FuWuVTdwkK+95c4u17XsvMyfkOqE9p1A19F7OUlOGJWwt1Y9/sCsSgyhPOnMXGL wzMHnDcPMeql8oV4Nboaa+wyiBGyDEiQk8O9xDwLl2ihYHBR4K0/7xx8M9T6iK1mGTDt H5LP55OpwmJLsF4Os9gGqkoZs1fOR4Nl/9fQwFtyAvVZeKvql2QYX65NDtbCoHBZhZ56 PSQ59xjsigsr85KdnSCKrEVuhNJ0D0pnhbbIlvUbdAwIYv0wQAtp3mZ1iy5cG6Vf/gK1 XPZohWPTU3ghO7/ZdoqvWHLCie/Bi8YxhCJLKF4p33qaDjsKus2jbaOiL2SvPo3Ejwnz ETMg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 68si10072089pfe.367.2021.10.11.09.23.35; Mon, 11 Oct 2021 09:23:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234084AbhJKLmn (ORCPT + 99 others); Mon, 11 Oct 2021 07:42:43 -0400 Received: from verein.lst.de ([213.95.11.211]:37008 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231128AbhJKLmn (ORCPT ); Mon, 11 Oct 2021 07:42:43 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id A095D68BEB; Mon, 11 Oct 2021 13:40:41 +0200 (CEST) Date: Mon, 11 Oct 2021 13:40:41 +0200 From: Christoph Hellwig To: "Michael S. Tsirkin" Cc: Xie Yongji , jasowang@redhat.com, stefanha@redhat.com, virtualization@lists.linux-foundation.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Kevin Wolf , Christoph Hellwig , Jens Axboe Subject: Re: [PATCH v5] virtio-blk: Add validation for block size in config space Message-ID: <20211011114041.GB16138@lst.de> References: <20210809101609.148-1-xieyongji@bytedance.com> <20211004112623-mutt-send-email-mst@kernel.org> <20211005062359-mutt-send-email-mst@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211005062359-mutt-send-email-mst@kernel.org> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.