Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp837243rdh; Thu, 23 Nov 2023 21:54:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IGr363tq4ioZm6tLwmtkXRapC0PxR6NDPQMvjynH9d8eCyFYj8W4BiwkK3ERCciuGMEZVWh X-Received: by 2002:a05:6a20:4f13:b0:187:f58d:daf2 with SMTP id gi19-20020a056a204f1300b00187f58ddaf2mr1989042pzb.58.1700805248433; Thu, 23 Nov 2023 21:54:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700805248; cv=none; d=google.com; s=arc-20160816; b=xJtuEfhG2tbPJgJUNbO+VK2qbjL3H+clGrGhuGQZ0mT6VgzeqGkZv3d8gXLr4ZiWV0 4pQqDL2eFPOvdnC4S4tPXW+P/gr0yqd5OQMvoqVWpS7pzcGOqsieKcWQVW0xziV44fbZ 1tXkSlDPyM7+kDevz1zi2C0QIpcNSNZ2u+CQ2KrbLb0V4hezdTjyvZ1KBQIWpYgy9iQe 4cgHZ5NuXLE7F7XrRoUg2PCP3C7jq3uT8yFKcH01Ygq/Up+fT6X2QvDja/gX6Luj3/va wEWvmrsB0iH62G0N4Qm/tZSO0mzM1Ml1fRcowzuINEXwpFZrvipchr13cHjLAYmuul03 CwIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:content-language:references:to:subject:user-agent :mime-version:date:message-id:dkim-signature; bh=HzWUmiWUzaeZq56BFoa9Zv7GCmiptzsNbdQr2afm3CM=; fh=0sYEMUzZr1SeXWcGtURomxBgMzNAKhISJbATbHxSEtw=; b=fWrlhhn2dHPTZ6yMhnIOyobB8OSU5MrQy1H6wf+qIowEqa/M7NnC9psVsxelUpkgYy amm+SLxLB8jEMqvezg7NL6YTO0nua4tVGZPbq91Lfz7HwAqcbES5ewGIEUFbrBDA3U6v HwiBk8/bqP8lQpSHAXy80Uw1kU6cYWYTeyr87aiTMnixMa9Us7UpgWF59HoHJckh7Euv NT92QXo7ezxZoTH/1BhKRyEqpRC1cJR+QrDeHdW/uvnU9ukK80fkQg9lGVs4JubBtNQm Uw/jfG/3iK6GsdO2iRqzKma8hc33vPOr7+4iIWyGzEEMC7K1BrGQNaXDkjFhAHoHb/tv J2fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pvjVf3eA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id a6-20020a654186000000b005bd42f65dc5si2761011pgq.285.2023.11.23.21.54.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 21:54:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pvjVf3eA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 1154F80A7321; Thu, 23 Nov 2023 21:54:06 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229705AbjKXFxv (ORCPT + 99 others); Fri, 24 Nov 2023 00:53:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55984 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229453AbjKXFxt (ORCPT ); Fri, 24 Nov 2023 00:53:49 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23E5E189 for ; Thu, 23 Nov 2023 21:53:56 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66C6BC433C8; Fri, 24 Nov 2023 05:53:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700805235; bh=ooIeM9zrPd8Y6XlkSVUl/UIr5uogzou+iMHiysRXOmI=; h=Date:Subject:To:References:From:In-Reply-To:From; b=pvjVf3eA1p3rHJkqINuxxR4IP8hMbx8P8QVIV4YR5N39wRw0FTq/1AIz+cwLh6EGB ANTyDwmH+VuKddT+AhnSljiU34hUSmDg6/GDU90UM9//u6Tef8D+mXOQAi9iIPlECd Twigc69OQSiyOCn0IJTl+eecOz2jhA7qTJvTw7VAlT0oIaSsDg/1PpzT9uTHQOHhRb 5SAV8k/uq2OWe+WImgPiNt8NrzeUNJ+W4rTEDMxzq0M1bCLzAaNq7DzNaRS/Wurpr5 jP1y1RbaTtVZlmxZ32TFV7dbXEC6X4mVInKw9S/43DQRztmPPEqALBZQQt4jdZ4pcD lnZcpVeSVRrzw== Message-ID: <160ecdfc-cb58-47fe-b9ce-fd126acc10fe@kernel.org> Date: Fri, 24 Nov 2023 14:53:52 +0900 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1] block: ioprio: Fix ioprio_check_cap() validation logic To: Wei Gao , axboe@kernel.dk, hare@suse.de, hch@lst.de, niklas.cassel@wdc.com, martin.petersen@oracle.com, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231124030525.31426-1-wegao@suse.com> Content-Language: en-US From: Damien Le Moal Organization: Western Digital Research In-Reply-To: <20231124030525.31426-1-wegao@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.3 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 23 Nov 2023 21:54:06 -0800 (PST) On 11/24/23 12:05, Wei Gao wrote: > The current logic "if (level >= IOPRIO_NR_LEVELS)" can not be reached since > level value get from IOPRIO_PRIO_LEVEL ONLY extract lower 3-bits of ioprio. > (IOPRIO_NR_LEVELS=8) > > So this trigger LTP test case ioprio_set03 failed, the test case expect > error when set IOPRIO_CLASS_BE prio 8, in current implementation level > value will be 0 and obviously can not return error. > > Fixes: eca2040972b4 ("scsi: block: ioprio: Clean up interface definition") No. Please see below. > Signed-off-by: Wei Gao > --- > block/ioprio.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/block/ioprio.c b/block/ioprio.c > index b5a942519a79..f83029208f2a 100644 > --- a/block/ioprio.c > +++ b/block/ioprio.c > @@ -33,7 +33,7 @@ > int ioprio_check_cap(int ioprio) > { > int class = IOPRIO_PRIO_CLASS(ioprio); > - int level = IOPRIO_PRIO_LEVEL(ioprio); > + int data = IOPRIO_PRIO_DATA(ioprio); > > switch (class) { > case IOPRIO_CLASS_RT: > @@ -49,13 +49,13 @@ int ioprio_check_cap(int ioprio) > fallthrough; > /* rt has prio field too */ > case IOPRIO_CLASS_BE: > - if (level >= IOPRIO_NR_LEVELS) > + if (data >= IOPRIO_NR_LEVELS || data < 0) This is incorrect: data is the combination of level AND hints, so that value can be larger than or equal to 8 with the level still being valid. Hard NACK on this. The issue with LTP test case has been fixed in LTP and by changing the ioprio.h header file. See commit 01584c1e2337 ("scsi: block: Improve ioprio value validity checks") which introduces IOPRIO_BAD_VALUE() macro for that. And for ltp, the commits are: 6b7f448fe392 ("ioprio: Use IOPRIO_PRIO_NUM to check prio range") 7c84fa710f75 ("ioprio: use ioprio.h kernel header if it exists") So please update your setup, including your install of kernel user API header files. > return -EINVAL; > break; > case IOPRIO_CLASS_IDLE: > break; > case IOPRIO_CLASS_NONE: > - if (level) > + if (data) > return -EINVAL; > break; > case IOPRIO_CLASS_INVALID: -- Damien Le Moal Western Digital Research