Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2925825rwb; Mon, 15 Aug 2022 14:10:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR7VWiFr+Mf1bXrC8Z/XEcqimJQK/8fhLZgRFRww2dwq6Ev5WaZOVDFjgNs58gkD9mrTMjYg X-Received: by 2002:a63:2048:0:b0:41c:daad:450d with SMTP id r8-20020a632048000000b0041cdaad450dmr15028547pgm.240.1660597853431; Mon, 15 Aug 2022 14:10:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660597853; cv=none; d=google.com; s=arc-20160816; b=f98s7Jp4Moh83qv6dUQNGSWTaKzywMct/64kJzF4nX6HGblOriDo0f/aJh4FBbmlmw uNfVhJqxA2TPeja5+EBPAs+Lnrk8s1PGjSS97L41OVBXmtNsoDUCMmWnsJeo9NtwdX18 vOKMFNJ64wcdmgwyPeQXL7+6eDFD/E847PZvQLKyEBGnXkc+6xYA0a1ZKqmS7BBLjpwA qZGAmQkHlmF3Z4qh4YCcXI23pFbPIrP8jSb2U23cf/k6zSjzrxgkuFhrsPZUDcYrCl3e 8st5GFQvgUYZT5d8N+toO8Mk4KXg6sa9cei3qI4bH9TDfx3MmjwC6v1OMn4u6JRselA+ abyw== 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=H/EZ3VP2x+dzgDOM1Qwm9/57IX6DCISIsFUCW+mCxN2/1V8UQfceKbK7LcSLuOd7cH tMFknTfV/ktoE8mde3QulAUWes05EoVGMH+JrHxYVullBJAUVXDWrIavIr25Q2tjd1pv 3C7DrdM02srDolV74XuLjJB+d4D42lmz7Y5NwXFMp31XMpIQvUKM0JUgx33kDjEy6k8z kvhggsM1VfkKPI79uDiv6UpqXrlboHb5mC4PP5Moxofv7aPzJPob9woqItrAZGTEgQ4w zDVPXUM2Hqn8ND1QcmcRETnCopnlfiXqjG/73CrpM2uyD5GdwqN7i7Dw0sb+QEF0VLtQ YYvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cuFHOgvF; 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 bq19-20020a056a000e1300b00534b83880f5si5301405pfb.68.2022.08.15.14.10.41; Mon, 15 Aug 2022 14:10:53 -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=cuFHOgvF; 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 S1346415AbiHOUl1 (ORCPT + 99 others); Mon, 15 Aug 2022 16:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346149AbiHOUfn (ORCPT ); Mon, 15 Aug 2022 16:35:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 918BC2CE18; Mon, 15 Aug 2022 12:06:48 -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 46C37B8107A; Mon, 15 Aug 2022 19:06:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A964C433C1; Mon, 15 Aug 2022 19:06:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660590406; bh=NXZMVp/XCIifham+N8UhWhA8PlWuq+NgCw/dNZwr9+Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cuFHOgvFoxmUlHRjVEfACosbqiDBERuKWTaXJsUw0HIDXi+MrGH3ZfV2zN2jzUuVC ruARYvY+czoutyAmGecLF6RFKhaEHHVOfEjO9cSRRpSejDnRHPjq5EOaQy8S0uWVbw 64R1JxSo2oDzsDBlDz+41gtfsCYxULbD5mn3AHsQ= 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.18 0249/1095] lib: overflow: Do not define 64-bit tests on 32-bit Date: Mon, 15 Aug 2022 19:54:08 +0200 Message-Id: <20220815180440.063954007@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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