From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78F40340281 for ; Mon, 23 Mar 2026 17:53:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774288406; cv=none; b=abT9uOtiGx5thVdmvunZaxXSSW0WMsp4oaeDeXkiw2PRpKht1Jxyn1ukAX5GtZ2Fjd2dmpR08tLhM7gpLilTVsZfrMyeINB+tn6uoeX4RhFdX0cLhcy2T35kgVE/sbQbW2WEuEj6Fy3NDT7aWreJNjmKlpMw6woAmyvcyaq4dr4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774288406; c=relaxed/simple; bh=alM9fCPgMmqIyhLMRV0kx45bQP20BzWtRXsBmtgT8dM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Fieoog1BjMmXN7g7NGYRmGio0L3IjwCOcLNsD5M1gXPO93VF0h1cFExR6yP5K8Qetut7BMu/4DK/xfQ9a+wLJCmdCZSclkyZYNUCDF29Ubjca6BVl6GIi3JGZigjwrlXWcj0m5a4Tow8CoLGfF+8hr5VRXFuSsfVLV0KzjZ4oRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mKhy1G81; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mKhy1G81" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0090C2BC9E; Mon, 23 Mar 2026 17:53:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774288406; bh=alM9fCPgMmqIyhLMRV0kx45bQP20BzWtRXsBmtgT8dM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mKhy1G81lHvy3rKGlLWKPOdutap8hJ6rXiMelt0zSB25quqjTIyFLrgpLeM4Unwbq f4HRMh8nfp0DZFBJkhtvkonINGWRizgPy0MHDwpQSYMeA+ojL5KylSxtZWvMZo/ZdB CNcKE/cwjXopc3jk0o+YOVrbVGfu6SiWuqVJftqyH43onGWc+q+Nv9eO0rgpZFqHN8 mslGDLolOdrYsv6joaFZJ69yF1E/MfCwWCfAf2i+Ry4xtm72DM4WRy3UgAQncsHyNF Rs4iy/A6bALJ54yR9yz002QtTCQiL55L51yC+MnuLfBIPppridMQXhnWGMjBPfew2z YV8TDZiI5lwGg== Date: Mon, 23 Mar 2026 11:53:23 -0600 From: Keith Busch To: Dan Carpenter Cc: Sungwoo Kim , Jens Axboe , Christoph Hellwig , Sagi Grimberg , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Harshit Mogalapalli Subject: Re: [PATCH] nvme: remove bogus check in nvme_pr_read_keys() Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Sat, Mar 21, 2026 at 01:26:25PM +0300, Dan Carpenter wrote: > This check for if (rse_len > U32_MAX) is confusing because if > rse_len is > INT_MAX, that will trigger a WARN() in kvzalloc(). > Fortunately, the caller blkdev_pr_read_keys(), puts a limit on num_keys. > The number of keys can't be more than PR_KEYS_MAX (65536) and the > condition is impossible. There's actually two callers: blkdev_pr_read_keys() ensures the number of keys is smaller than 65536 and iblock_pr_read_keys() is a fixed size at 16. But begs the question, what guarantee does nvme_pr_read_keys() have that all the callers validated the number of keys such that it can bravely skip checking it? I think nvme should validate that it's a reasonable value before calling kvalloc so we return an apporpriate EINVAL instead of ENOMEM. The existing UINT_MAX check is certainly far too high, but I think something like a 4MB payload would be a totally reasonable upper limit for nvme on this function.