Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp784405lqh; Thu, 28 Mar 2024 17:05:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZC4b5vCLD0KOqsqeq38ZgdBlj7VeA4PugZTm4I5LISyKD2G26jlqkRjVjHOGmX2vwN2pEDJ/4c02X704bmvVqubFxf6wAjQTd/VSO7w== X-Google-Smtp-Source: AGHT+IGJHiMO2naDUeMi2LPNnpwKBqt4uIbDv6gm34ytQAxSp490Xbl3XBOVwuTE3qE/jxBAnqwx X-Received: by 2002:a37:db09:0:b0:78a:6dc7:a256 with SMTP id e9-20020a37db09000000b0078a6dc7a256mr905629qki.76.1711670751353; Thu, 28 Mar 2024 17:05:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711670751; cv=pass; d=google.com; s=arc-20160816; b=gY/ljuyvKS8inNeMkhEmjEgFRu/hAHaV7s8zCoji9dPRwBj4IGaj/jYLFVaEgvi8s+ Q8pJR1srQir5ozJ5zmsPiyUQYmgxLC8PNOMRVemRZmA5tcEgQNV48tD3MIu4COCwDcKI Th0dtbXGbUKpPo3XQIGEMuVzGN/mW0jMB2Hl0p1OA+cL39kSCTtwXh3lhSadV7l0+mRb Wdag4JHSq8XpQzfmEdV2f3lkDW3EB8wTGvVW54WLtxqYXv6U26hUwtP1mBJpmZtBF1+q F8JYzY+WbgA0a+AFFhVwMLRwbvIFF0M4xFzwo+tYz+Q5sxx+/Eu/rLzrpdDEe0daLWrE EPkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=oquIsO/B8A2Gk2EwI1tx+d6zNaq8dTKXgOE1D72BOIw=; fh=C0G7W6ha/RgehYiw48SGHc29AG9Nr6ecbqZP6kGG3EQ=; b=mZQzempw0q8KjB3w03xdotmulGNc1ZTEQXTEvjmdIoUdGOY3/5Uem+GXgd8Tquv/wu qhaoe9XtUM4uoKySi5+HtGXALi3ik7V8+9rdavtbGIHoTJzG3RBwRJ5D3gOttTkhRtzw Q5Fd9I8f2ODAsAqitgXSMLU5u6NlA8cFeT0XhvWYfy+6KZtLuPQQV0E6Z+0lVYy2dlt7 L8zvSXGGPfRz60fJNSqMpFzjLi4IQ3DC6DSvM1QHstVjhqKYMcrnjO4CwoAkFvJveA9b 8RYf/bkk1aKcnhkzjrP+CNndHSu+ur+8MAwUIfd2oPBvOaI9COEpTho0jPVBx0/6o7cO 9Hkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i3bTekP7; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m13-20020ae9e00d000000b0078a6865e1a3si2556576qkk.525.2024.03.28.17.05.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 17:05:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i3bTekP7; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-123851-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123851-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 1B43F1C24024 for ; Fri, 29 Mar 2024 00:05:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB43B23B0; Fri, 29 Mar 2024 00:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="i3bTekP7" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 79664631 for ; Fri, 29 Mar 2024 00:05:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711670739; cv=none; b=OyF78RnuJiEKBhMSwZgpF5zuhnDBg3EqPdiOETU7LQbWBTmN6Vjk73sahe2J1CGuZqHOpDNfxu9UWXum3M9W1rx6SolML3Q46f8fZyb4aI7vHuc2dubK5PxmFXbkCfEBL5JjIoMefCEtninOX2DeoQ5UW8BMvKU1MNPCf7XmXw8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711670739; c=relaxed/simple; bh=cjxm1Ryfb5Z9F4sbSdTRXRhffmjVd0tmVnxtg9IiFvg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l+ymQwZeezIjWi5TkzIZLtrQ8WiLEsE/5zhTZYpN2/RJt8PKkvozojuJWWVk6Vhl+zlpVAwZCwjcmWM5cyEXm7Pa0KAsbwXe2lcNOCjpVXJ2qfLrOEbvq3Q5DG+85nWbJcnvehLlRthBWBvEZBMUKAA48u7jpsQvLIU20jzgaeo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=i3bTekP7; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711670736; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oquIsO/B8A2Gk2EwI1tx+d6zNaq8dTKXgOE1D72BOIw=; b=i3bTekP7uHuTkj6ouHBfEKGr8LYAO9pNQDW0BfyP/03t49V2PPgG25WWQDROoKbNz9xbCm DFBCsbYVKXopkWbFIIX1TaJ9JlwHkX1X/KXZR3qDwUvmcQwl+LaU+X+ruTLu0AWzRq3jr6 U45UX+ggdQjXbK+mH5JLW4dYeW+8fAs= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-gF8KtyG4OnqzehyTtglIlA-1; Thu, 28 Mar 2024 20:05:34 -0400 X-MC-Unique: gF8KtyG4OnqzehyTtglIlA-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-22a050166efso1610881fac.3 for ; Thu, 28 Mar 2024 17:05:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711670734; x=1712275534; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=oquIsO/B8A2Gk2EwI1tx+d6zNaq8dTKXgOE1D72BOIw=; b=azMZEHH3HdUVE2dBVzmSUHRbYLutC67jG6T15IuISVEEDpQWlklWF/MpdbzB9Dj4QB 08qnwlDE8UzTiWw+aM6S1ccm9JH/fMThew41X++3u4KmGsg2+w0AnrJ7jFbzrZfISG6u cFFUO5dQvWjwYnbLMZyBapdhuZqPjIuIF3QWSJCnfv3IOHNJwrZuxxoyPvrYpCF/gN5/ 5HZv7a6RekfhNVOt4zUUZlnsHfy+gFh94nZqTpnNIA0BSU/2c0EkUJuQI3LKRElhxseB wM2TqRA2d43IKx0UDbWyHRT0kcTXF7d1hbXepH7molKA1ozT54O3VNVFJNLJ+8kOuZE/ H/uA== X-Forwarded-Encrypted: i=1; AJvYcCXGgDmQtXpXAomkyzv7Z+10WwXg2CcDXQOhhaSZqwFZ7XmykqG5QiK+v59oHvpAUcxOll+SMFIO4eDr95ks4vL4lm8opt/K9yXlwhip X-Gm-Message-State: AOJu0YxLPbD+TDsAoDSmCvO/zVUcN0wThYuCVzBXgA5lygf4oR8HBBXJ 4dAvy4X7fhKGkcwcVhUuLEHL3RigMMsQ3YeOlBau2jZwxSeVvMs9Vymf5K/2z1tZGLnmgamqbqa Ev8bAVGncPm9nFSJZ0+cWMx3/0vGkOvJbPFbTuVugs2NoecbetOEwwZtpjoAxVg== X-Received: by 2002:a05:6870:9213:b0:22a:e91:2d9c with SMTP id e19-20020a056870921300b0022a0e912d9cmr744887oaf.56.1711670733964; Thu, 28 Mar 2024 17:05:33 -0700 (PDT) X-Received: by 2002:a05:6870:9213:b0:22a:e91:2d9c with SMTP id e19-20020a056870921300b0022a0e912d9cmr744867oaf.56.1711670733707; Thu, 28 Mar 2024 17:05:33 -0700 (PDT) Received: from [10.72.112.41] ([43.228.180.230]) by smtp.gmail.com with ESMTPSA id j23-20020aa78d17000000b006e681769ee0sm2020583pfe.145.2024.03.28.17.05.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 28 Mar 2024 17:05:33 -0700 (PDT) Message-ID: <93fc9138-7498-4268-9bd2-d5b87f215963@redhat.com> Date: Fri, 29 Mar 2024 08:05:20 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 3/9] rbd: avoid out-of-range warning Content-Language: en-US To: Alex Elder , Arnd Bergmann , 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 References: <20240328143051.1069575-1-arnd@kernel.org> <20240328143051.1069575-4-arnd@kernel.org> From: Xiubo Li In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 3/28/24 22:53, Alex Elder wrote: > On 3/28/24 9:30 AM, Arnd Bergmann wrote: >> 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] > w >>              ~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> >> This is harmless, so just change the type of the temporary to size_t >> to shut up that warning. > > This fixes the warning, but then the now size_t value is passed > to ceph_decode_32_safe(), which implies a different type conversion. > That too is not harmful, but... > > Could we just cast the value in the comparison instead? > >   if ((size_t)snap_count > (SIZE_MAX - sizeof (struct ceph_snap_context)) > > You could drop the space between sizeof and ( while > you're at it (I always used the space back then). > Agree. - Xiubo > -Alex > >> >> 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; > >