Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3090026rwb; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR7WM8TQTnJEuaA0/LjjSmgKLbO+siT+6Hb6oK7rEeti+jfwFgolvbYaM3vKje0s2wdrU3EZ X-Received: by 2002:a17:906:730e:b0:731:48fe:3f10 with SMTP id di14-20020a170906730e00b0073148fe3f10mr12322422ejc.185.1660611186682; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611186; cv=none; d=google.com; s=arc-20160816; b=0qlUFdjdZZzl/RotC5XZ8aINS3DU6JMUeVfhcqjM/iKmGMbjR/dmmepBnjx16FK4Va G/JmPAidLKafkUMIQNdppbWNkgn2cwwExCgZzXzMqeqAMKcASo4Zsor4Z6rmUeBykr2P BHXEAq68RBMEZqgTM87E/ppuWkW+SQUF/PC+pVTkK84Iiwt7K3ULVF04gmd8KXui+dUF FPUme41S2OPbuw/ySA6rkwDCNy6yfBluAmoDif7ZBliuWkkikaWlsaDAbn/atUDHFXuK 9XE/37qLuxPzNrkFh+SV4i6+W7wZw1k4dYi/WDLF65ael7iSFg0WUt52PFldRJ7JTdCG BUEw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=20pCd3aqs23XLbiypJfm4sPPgUWdWib1umB90oQyAcA=; b=qqBWzywgWdxSM0OqBfOpn9Mu4nwixinmtH/1/KhIJPBjXjCoz0Of6vJVmkPZlgpNlT iOKzb62whq4+vsgNw1AKCi5hIuJDp5pSiZM2Hshu1XDk5IKf2LZIPgH9yUTNCtY/uPGp etF41u3v5hZ0omB0GSp8sKetLhTOGIOqOQPMtLKk40EHbSGa9nOSaHAAyTiRXHrhWGVN FA6wmdRyAwPQIWi6LzO7u+STmOdZMYeMGK+0mnwfPOvrSEa9A4uvjjzSHL60JFQVg4qV 9pG6Zlj5MS4lyNs4zfFQ1Q83nOJ7x5x8OC/NPQ8OQvoMjaVymDtAJJU+n7RSo/wHGgkl /Xiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Z2zz3RGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ji21-20020a170907981500b00730e4be74b6si10416057ejc.26.2022.08.15.17.52.41; Mon, 15 Aug 2022 17:53:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=Z2zz3RGG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345848AbiHOXE2 (ORCPT + 99 others); Mon, 15 Aug 2022 19:04:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346109AbiHOXCY (ORCPT ); Mon, 15 Aug 2022 19:02:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECA458604C; Mon, 15 Aug 2022 12:58:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 85408B81136; Mon, 15 Aug 2022 19:58:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CFF00C433C1; Mon, 15 Aug 2022 19:58:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593493; bh=NXZMVp/XCIifham+N8UhWhA8PlWuq+NgCw/dNZwr9+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z2zz3RGGajru4+pAVbv3KwxEWpvTq0FkItfRQXVCoc2Pd0kmPfRyY1yPusRgJU4oG 3FUewygXNBAhw2dda9TXspoHsHqjzYnV3OIBsEmbKuLLidO8lrIlrcuSpttzwx2f5Z sYGt8kOCppzB2kn7FUJpWlCZTi9RDhqvLG6rH5Qc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Rasmus Villemoes , Nick Desaulniers , Vitor Massaru Iha , "Gustavo A. R. Silva" , Daniel Latypov , Kees Cook , Sasha Levin Subject: [PATCH 5.19 0247/1157] lib: overflow: Do not define 64-bit tests on 32-bit Date: Mon, 15 Aug 2022 19:53:23 +0200 Message-Id: <20220815180449.465255125@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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-kernel@vger.kernel.org From: Kees Cook [ Upstream commit 6a022dd29f2cefbac4895a34e2e1f14b2d12d819 ] The 64-bit overflow tests will trigger 64-bit division on 32-bit hosts, which is not currently used anywhere in the kernel, and tickles bugs in at least Clang 13 and earlier: https://github.com/ClangBuiltLinux/linux/issues/1636 In reality, there shouldn't be a reason to not build the 64-bit test cases on 32-bit systems, so these #ifdefs can be removed once the minimum Clang version reaches 13. In the meantime, silence W=1 warnings given by the current code: ../lib/overflow_kunit.c:191:19: warning: 's64_tests' defined but not used [-Wunused-const-variable=] 191 | DEFINE_TEST_ARRAY(s64) = { | ^~~ ../lib/overflow_kunit.c:24:11: note: in definition of macro 'DEFINE_TEST_ARRAY' 24 | } t ## _tests[] | ^ ../lib/overflow_kunit.c:94:19: warning: 'u64_tests' defined but not used [-Wunused-const-variable=] 94 | DEFINE_TEST_ARRAY(u64) = { | ^~~ ../lib/overflow_kunit.c:24:11: note: in definition of macro 'DEFINE_TEST_ARRAY' 24 | } t ## _tests[] | ^ Reported-by: kernel test robot Link: https://lore.kernel.org/lkml/202205110324.7GrtxG8u-lkp@intel.com Fixes: 455a35a6cdb6 ("lib: add runtime test of check_*_overflow functions") Cc: Rasmus Villemoes Cc: Nick Desaulniers Cc: Vitor Massaru Iha Cc: "Gustavo A. R. Silva" Tested-by: Daniel Latypov Link: https://lore.kernel.org/lkml/CAGS_qxokQAjQRip2vPi80toW7hmBnXf=KMTNT51B1wuDqSZuVQ@mail.gmail.com Signed-off-by: Kees Cook Signed-off-by: Sasha Levin --- lib/overflow_kunit.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/overflow_kunit.c b/lib/overflow_kunit.c index 475f0c064bf6..7e3e43679b73 100644 --- a/lib/overflow_kunit.c +++ b/lib/overflow_kunit.c @@ -91,6 +91,7 @@ DEFINE_TEST_ARRAY(u32) = { {-4U, 5U, 1U, -9U, -20U, true, false, true}, }; +#if BITS_PER_LONG == 64 DEFINE_TEST_ARRAY(u64) = { {0, 0, 0, 0, 0, false, false, false}, {1, 1, 2, 0, 1, false, false, false}, @@ -114,6 +115,7 @@ DEFINE_TEST_ARRAY(u64) = { false, true, false}, {-15ULL, 10ULL, -5ULL, -25ULL, -150ULL, false, false, true}, }; +#endif DEFINE_TEST_ARRAY(s8) = { {0, 0, 0, 0, 0, false, false, false}, @@ -188,6 +190,8 @@ DEFINE_TEST_ARRAY(s32) = { {S32_MIN, S32_MIN, 0, 0, 0, true, false, true}, {S32_MAX, S32_MAX, -2, 0, 1, true, false, true}, }; + +#if BITS_PER_LONG == 64 DEFINE_TEST_ARRAY(s64) = { {0, 0, 0, 0, 0, false, false, false}, @@ -216,6 +220,7 @@ DEFINE_TEST_ARRAY(s64) = { {-128, -1, -129, -127, 128, false, false, false}, {0, -S64_MAX, -S64_MAX, S64_MAX, 0, false, false, false}, }; +#endif #define check_one_op(t, fmt, op, sym, a, b, r, of) do { \ t _r; \ @@ -650,6 +655,7 @@ static struct kunit_case overflow_test_cases[] = { KUNIT_CASE(s16_overflow_test), KUNIT_CASE(u32_overflow_test), KUNIT_CASE(s32_overflow_test), +/* Clang 13 and earlier generate unwanted libcalls on 32-bit. */ #if BITS_PER_LONG == 64 KUNIT_CASE(u64_overflow_test), KUNIT_CASE(s64_overflow_test), -- 2.35.1