From patchwork Thu Mar 28 14:30:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13608658 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 1C39912D77B; Thu, 28 Mar 2024 14:31:29 +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=1711636290; cv=none; b=SHlVZSnNDHv4t8Y7Qy/Dn6fnrXuWwc7+VvzhllHQ8OJrgNYVx4phCyuP644iDuWto64Nq2NU54yZyC3bO91tQ6y7XqmPVvRQvol8xH0smk8Z1W2eGmoBixaKDU4OaSqxhu1NUB4lahhMx5P4YeYNXMO19ivjmxAe4HzP0EWWggY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711636290; c=relaxed/simple; bh=CLKmSwfWJ51R7yRH9H4Z02ae07/lsbxBLTkdp9cvOH0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NV6FqXfv7be4XkFVHyDPcZKorlDvkb6Jm74KCAb0jM/UFQCDh44p2Z9/1plwbPi3tPcCd7/osYwZl7iakv1gek7Z8jBSYI5JzMA8hATp/8E8T2C2Gd2vgC7NDarC73VBKLl/B102P6PVdsrFV1ZFe/dSLwavtoAoY28mXelMENo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Q6rPZGLf; 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="Q6rPZGLf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7265C433F1; Thu, 28 Mar 2024 14:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711636289; bh=CLKmSwfWJ51R7yRH9H4Z02ae07/lsbxBLTkdp9cvOH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q6rPZGLfjJ85hVRL9zvH78xHWI71xn2Fvzu/M5q0+HDEkrd6TQ/WnLodC2ogsLTvr sB+1VLU0PVi30PcYICt9g8mTpwOMIDnovxTMxNzgc0eyT/e924ZhQ9TUMmE+BmyMdS Et8bKBZWJ2FTljWdJZ3OH90jTqoDxKWp6NVsDt8xZ5mpFYCJFXWCRSPoG5QUOWJZuu KpwIfSk1FzjWLZacCXDuyX7jJuyJqU31+/HZEs0shtldrC56E5tOQI5oTRs4RyXRHU 2zkvnh6eg1KMYnPyAs6+3p3rTSy9AsqD/VRw+TEMXlc+oqz4tIiOfkfeaOjp6fL+gd Q9E045wcHMrww== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Xiubo Li , Ilya Dryomov , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nathan Chancellor Cc: Arnd Bergmann , Jeff Layton , Nick Desaulniers , Bill Wendling , Justin Stitt , Milind Changire , Patrick Donnelly , Christian Brauner , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 2/9] libceph: avoid clang out-of-range warning Date: Thu, 28 Mar 2024 15:30:40 +0100 Message-Id: <20240328143051.1069575-3-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328143051.1069575-1-arnd@kernel.org> References: <20240328143051.1069575-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann clang-14 points out that on 64-bit architectures, a u32 is never larger than constant based on SIZE_MAX: net/ceph/osdmap.c:1425:10: error: result of comparison of constant 4611686018427387891 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ net/ceph/osdmap.c:1608:10: error: result of comparison of constant 2305843009213693945 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) ~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The code is correct anyway, so just shut up that warning. Fixes: 6f428df47dae ("libceph: pg_upmap[_items] infrastructure") Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt Reviewed-by: Xiubo Li --- fs/ceph/snap.c | 2 +- net/ceph/osdmap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index c65f2b202b2b..521507ea8260 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c @@ -374,7 +374,7 @@ static int build_snap_context(struct ceph_mds_client *mdsc, /* alloc new snap context */ err = -ENOMEM; - if (num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) + if ((size_t)num > (SIZE_MAX - sizeof(*snapc)) / sizeof(u64)) goto fail; snapc = ceph_create_snap_context(num, GFP_NOFS); if (!snapc) diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 295098873861..8e7cb2fde6f1 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c @@ -1438,7 +1438,7 @@ static struct ceph_pg_mapping *__decode_pg_temp(void **p, void *end, ceph_decode_32_safe(p, end, len, e_inval); if (len == 0 && incremental) return NULL; /* new_pg_temp: [] to remove */ - if (len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) + if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / sizeof(u32)) return ERR_PTR(-EINVAL); ceph_decode_need(p, end, len * sizeof(u32), e_inval); @@ -1621,7 +1621,7 @@ static struct ceph_pg_mapping *__decode_pg_upmap_items(void **p, void *end, u32 len, i; ceph_decode_32_safe(p, end, len, e_inval); - if (len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) + if ((size_t)len > (SIZE_MAX - sizeof(*pg)) / (2 * sizeof(u32))) return ERR_PTR(-EINVAL); ceph_decode_need(p, end, 2 * len * sizeof(u32), e_inval); From patchwork Thu Mar 28 14:30:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13608659 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 CD24512F38C; Thu, 28 Mar 2024 14:31:38 +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=1711636298; cv=none; b=N+ra2drUjO1JFuTUzygwQ6DTrQRi7jP6WELmDXs1gJrhOHy45/S5HFEwXspHbE0t+8sgmADfgEc1+9d9F5skzjVErzm98aFxTG13l4vcnv3uKJnPjL9U5VahiHOBEUOsUsUeoCkaXqvFg2mp/aFTVp13IgI3UxDUlywtHFNOBKc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711636298; c=relaxed/simple; bh=R0aUpIukgAH4xjGJj4S14g7ze9BAK3FgVk+vR41wWF4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QEmC9jXBCJyQ9lI45/Ccv0qcLLjcHuZjlI/QUCjOtFNpYh0/6n1RkT7lBtbfLxuKh25KOQXii7Hxl1U6e7rhzdSaBxmFPI5FeBvMCSAztmFcwfY/ro5wFo3mOicvmCroFmk3lmurJViTLv/y7rBg07wLskxLzrx8IPS99mWdVLE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y6nBMvO8; 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="Y6nBMvO8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56A6AC433C7; Thu, 28 Mar 2024 14:31:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711636298; bh=R0aUpIukgAH4xjGJj4S14g7ze9BAK3FgVk+vR41wWF4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y6nBMvO8FUq7wwMpXlu5eU2X+qG2WwQMDrQQcRCXN13QGA7B+OYdbmM3DdmZbLfpd eJcJTquwgfzRZ2I0/ojf1S84gT5/H3gCLYVPq9jfRlj8k5y1H4wZpkhHcWXziQAml5 aJeSJ8DXrTbPoFJB3u+3Cyp9otY+hfgaiuBfkBGclsSwXDoAQXRuAEWvm5pvYnvJhS 0E6tdV7+RfopI4ZvIWUMm6IiTcdbMOVi9nncy4ueupamqPVOJxAgfXAN5H4zYM4HDo MuSfDfCP8h8W94vjEQL85zvUuRBzTmg9ZjMYK3/93ZDgIqf+rHpEjVsQ1kDiY5yHgD T6xlVNXKOCFgw== From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Ilya Dryomov , Jens Axboe , Nathan Chancellor , Alex Elder , Josh Durgin Cc: Arnd Bergmann , Dongsheng Yang , Nick Desaulniers , Bill Wendling , Justin Stitt , Hannes Reinecke , Christian Brauner , Christophe JAILLET , "Ricardo B. Marliere" , Jinjie Ruan , Alex Elder , ceph-devel@vger.kernel.org, linux-block@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH 3/9] rbd: avoid out-of-range warning Date: Thu, 28 Mar 2024 15:30:41 +0100 Message-Id: <20240328143051.1069575-4-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240328143051.1069575-1-arnd@kernel.org> References: <20240328143051.1069575-1-arnd@kernel.org> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann clang-14 points out that the range check is always true on 64-bit architectures since a u32 is not greater than the allowed size: drivers/block/rbd.c:6079:17: error: result of comparison of constant 2305843009213693948 with expression of type 'u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] if (snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context)) ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This is harmless, so just change the type of the temporary to size_t to shut up that warning. Fixes: bb23e37acb2a ("rbd: refactor rbd_header_from_disk()") Signed-off-by: Arnd Bergmann --- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 26ff5cd2bf0a..cb25ee513ada 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -6062,7 +6062,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev, void *p; void *end; u64 seq; - u32 snap_count; + size_t snap_count; struct ceph_snap_context *snapc; u32 i;