Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp26032548rwd; Mon, 3 Jul 2023 04:42:32 -0700 (PDT) X-Google-Smtp-Source: APBJJlEI19MK8yzuyc5Te69ylRKB/+2TOEO5xt+XRly4XMwiBetD+410Hj/Blp/Uqz1cJwvljBSi X-Received: by 2002:a05:6808:1409:b0:3a3:9965:19c5 with SMTP id w9-20020a056808140900b003a3996519c5mr4647339oiv.27.1688384552044; Mon, 03 Jul 2023 04:42:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688384552; cv=none; d=google.com; s=arc-20160816; b=VVHBl2QAeKl6X98zFT7JkvdB4T8+nLKsNgpPDJN54/ilZ2cOXW4mymReeaIAXEfkWf mqd5YSjKBQYYlvS4ZEmSf5vGMiZEizqKyyvDAxj6AGhzcaW8NtmQ4d5GQO4fl1G2NoLP S4MZVkkOaA1ECMynWAgGJsJr1yN8eudIHCs4JH2pRUwbSP4y70ZM/+6jnssb05PNvB8D 0FOgtsZ2LZRyjBGjQw+7QT5Y6bclvTh55P95gZlxB9bgtFR0mZk4Ak6Yfn0t4gNefSRf Vy0UoFaU1c9zC7vCZgW3fBG+JXe4St/eU7BCCVz2N7YuHFA4v2HOxoReL489lVeRIYJL 38+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=M6hBJAkwInWwXiWguUXB5FNTUSQPF9lEX6qRmGzny4I=; fh=fLcCYCiujSOCF8vx2gWcdxAthqJkfQNNrRgY4s7VYZY=; b=ruchd1FjXiZWgucBJkT5TFeC2ehC+33RFUDQipC3QKNWPmnT1XHRByQjTuMTU1d80l 0SxYnzu6S0Bpl7rUL449UnnTknUeWACjlk3HsPyp1noqjZjCby4Evljtm9amxwY4Dv2b l6PBp0JdUDNW8JVSXZORkqANX02XYOkCB2S2Cri3UIIlsZwPr2mNgVGSTcf5S4Avreka HKeF53KelCgXFSLF4Ntd3cDCQ+n9OxH34ygE6zqkqPeDDWDLFv3q8CegTItR3llIKB4C H2vhQmEkHXMxr6cRo8Evv0g3mViaONSc1Skm5T7PNZwhIsP4pSqOIQGaTyZDBRvtZFqc li/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUJp2I4t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc4-20020a17090b3b8400b0025bcbba10c6si19950460pjb.85.2023.07.03.04.42.11; Mon, 03 Jul 2023 04:42:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BUJp2I4t; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231152AbjGCLiF (ORCPT + 99 others); Mon, 3 Jul 2023 07:38:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbjGCLhy (ORCPT ); Mon, 3 Jul 2023 07:37:54 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67140198; Mon, 3 Jul 2023 04:37:45 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EE59760F00; Mon, 3 Jul 2023 11:37:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 00269C433C9; Mon, 3 Jul 2023 11:37:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688384264; bh=NWdm4COWp2k09VYLKv3/EMMJkaiYec6oWrtpHhnAdio=; h=From:To:Cc:Subject:Date:From; b=BUJp2I4tfvNJnQyBQ7mRS4r9bhjY6iDaZatDtPvGUGRSMTW+yTIuvFgIodu6nfukJ Ir3sfcG1YlLLR9YZXB6YIKumcnsyEd1orp1XlNfFS9pcIYFUF7hYuu/PLv1gquQ+MX eUbjrWhcdg89M2+/8hr9u8aM5D7jmRhg49yjetMcM2Yp8lbDHDfIxnBf8Xxqiul2LG IQeQdjKFGFzUHJTaDSlprBM7iQ2e3D5C84bDauoUdzk5V7ZQxGBB9sGJMT7vjXYjv7 rLfln/mxaLdx0zGVrdVVW4hfbm7SV9AgnrElV5CGJ266xfcDdY/+71CCzEb+AUQUCR G3sPgBRvhHiig== From: Arnd Bergmann To: Chuck Lever , Jeff Layton , Trond Myklebust , Anna Schumaker Cc: Arnd Bergmann , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Nathan Chancellor , Nick Desaulniers , Tom Rix , Dan Carpenter , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] sunrpc: avoid constant-out-of-range warning with clang Date: Mon, 3 Jul 2023 13:37:22 +0200 Message-Id: <20230703113737.694995-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,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-nfs@vger.kernel.org From: Arnd Bergmann The overflow check in xdr_stream_decode_uint32_array() was added for 32-bit systems, but on 64-bit builds it causes a build warning when building with clang and W=1: In file included from init/do_mounts.c:22: include/linux/sunrpc/xdr.h:778:10: error: result of comparison of constant 4611686018427387903 with expression of type '__u32' (aka 'unsigned int') is always false [-Werror,-Wtautological-constant-out-of-range-compare] 778 | if (len > SIZE_MAX / sizeof(*p)) Shut up the warning with a type cast. Fixes: 23a9dbbe0faf1 ("NFSD: prevent integer overflow on 32 bit systems") Signed-off-by: Arnd Bergmann --- include/linux/sunrpc/xdr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/sunrpc/xdr.h b/include/linux/sunrpc/xdr.h index f89ec4b5ea169..6736121ee6a03 100644 --- a/include/linux/sunrpc/xdr.h +++ b/include/linux/sunrpc/xdr.h @@ -775,7 +775,7 @@ xdr_stream_decode_uint32_array(struct xdr_stream *xdr, if (unlikely(xdr_stream_decode_u32(xdr, &len) < 0)) return -EBADMSG; - if (len > SIZE_MAX / sizeof(*p)) + if ((size_t)len > SIZE_MAX / sizeof(*p)) return -EBADMSG; p = xdr_inline_decode(xdr, len * sizeof(*p)); if (unlikely(!p)) -- 2.39.2