Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp3889981rwb; Mon, 5 Sep 2022 21:51:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR7PwG7AT8UMEV85jUIPgKG0GCU9hgaP0cO5NBuhHPZoV/8bBYSDAnrS/oUpZK9hUIwDwLWB X-Received: by 2002:a05:6402:5c9:b0:446:fb0:56bb with SMTP id n9-20020a05640205c900b004460fb056bbmr46774853edx.173.1662439892751; Mon, 05 Sep 2022 21:51:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662439892; cv=none; d=google.com; s=arc-20160816; b=c2ztB7hZkwABjYN/tqvOHWv/zVfXEReyKFEoRS8RaE1c+mykW3AF30CQh9mQY+Vl7g EWO768KA0Ya4+konAHgNr8IxTP98/dtyWaRxqv4MOmxJDzuy4X983eD2cm2eB/yTYKCP uIysDm2IfMWyMeE2NQoi6xuzehBwwTVTh/leAtsGGb064MIlwjiPOKKPlVk/qbCdIqrQ 9HxT9RoiMpH/E55SkprLARxQ1bN0QETbbsLTUor8TrSUiXjwDcHKZPg49vw6x4Ryu0UJ rMhz0BbfUlDskDYvc6znZLxOkS2nZpBAKDdeqA//jZ4BDYabF0/UekKJu+ir6Ix12cGZ Izvw== 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=g4QYwLVwBSQMkNQtPqrGryY3aE2OppiG2yCu9oNUQe0=; b=aGMK2QBZ5TWGKNtbxur1yAJ2+E2mq5IKezWbFgTEJBa54SsnLSY6iDV+RFfi9NRnxu VRIZ0DWk7cQa/9sb7wllJPqL/R6QmRjDbOdrDO12mhYS+4bHpxLbCP5U3iCQUPRXFbtM X/AEiDrpGPiEzDEdo9ZpNLP0XC4nTKwVTI6tnuIGWLn/w3WsxFMSXkdolLpuVu22bmxu 1BdGpTY+aEzHCsnIeggi87B+C3MMlh7ssZJrIMTb0n+Rfi7nGRfSRdTo1hRu4OqTv886 EPD7eIGS6MfyXRZwPg4oZoh8WN+QbyG1tgiEm9pvy4ZwHmz5P/5z9mbAD4ZhiZb+XuZL cV9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e16-20020a17090658d000b0073d92cad668si1632288ejs.664.2022.09.05.21.51.03; Mon, 05 Sep 2022 21:51:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230056AbiIFEqA (ORCPT + 99 others); Tue, 6 Sep 2022 00:46:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229601AbiIFEp6 (ORCPT ); Tue, 6 Sep 2022 00:45:58 -0400 Received: from verein.lst.de (verein.lst.de [213.95.11.211]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9FEA644E for ; Mon, 5 Sep 2022 21:45:52 -0700 (PDT) Received: by verein.lst.de (Postfix, from userid 2407) id 6A4AA68AA6; Tue, 6 Sep 2022 06:45:49 +0200 (CEST) Date: Tue, 6 Sep 2022 06:45:49 +0200 From: Christoph Hellwig To: Dennis Maisenbacher Cc: linux-nvme@lists.infradead.org, Niklas Cassel , Christoph Hellwig , Sagi Grimberg , Chaitanya Kulkarni , linux-kernel@vger.kernel.org Subject: Re: [PATCH] nvmet: fix mar and mor off-by-one errors Message-ID: <20220906044549.GC32413@lst.de> References: <20220905122116.2678206-1-Dennis.Maisenbacher@wdc.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220905122116.2678206-1-Dennis.Maisenbacher@wdc.com> User-Agent: Mutt/1.5.17 (2007-11-01) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 05, 2022 at 02:21:16PM +0200, Dennis Maisenbacher wrote: > Cast the unsigned int values that are returned by bdev_max_open_zones and > bdev_max_active_zones into u32 vales which need to be decremented as the > returned values of the block layer helpers are not 0's based. > The cast to u32 is necessary because the size of unsigned int is > architecture dependent and a 0 reported by the block layer helpers > indicates no limit, thus it needs to be converted to 0xffffffff which > happens by underflowing the u32. unsigned int (in Linux, not the C standard) is not architecture dependent but always a 32-bit unsigned integer type. But I'd much rather see an explicit check for 0 and conversion to 0xffffffff anyway. Yes, unsigned integer underflow is well defined, but having the explicit check explains much better to the read that it is intentional. Can you also add a Fixes tag, please?