Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3525837iob; Tue, 17 May 2022 01:49:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjLPpbHr8hHRBQePKLgOu0OMsgCkPpysmpCuoNYdUAZQFUfm4aaYG69I20JZ4WcJvO8VBN X-Received: by 2002:a17:906:d54e:b0:6f6:3ea:8e7b with SMTP id cr14-20020a170906d54e00b006f603ea8e7bmr19302513ejc.292.1652777351965; Tue, 17 May 2022 01:49:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652777351; cv=none; d=google.com; s=arc-20160816; b=psFpSwa+3h6PAO8kiEI3VqwgNqm3ZDXEnWmtfTUeJ95Yu6ixP4b24ZJTnALBIibK4T 8Kkm/sRwGZwTV++OiugStdRVCfwaMfv4jCSh8rnqTy9dbnc4aM0kUagTjEiX5q1l7aFG jjHHvPq8E8/iq+Uhl54POyDDZ/KrEqPmIJcWUzG7MHK+B+vDfUrdhMZPO8EVbq6fLGLv HcKUzXrsCLAdfqu6wlQ3tTfolVnxmo9TnfNTY+ArIuxQzWYOjbz+DtxHDc5KgBSh2feZ hZDlO9F3Vtu2bWjfxks8/wSwXybbGKIVAKiWLb423Re4uL9KuOsvD+gFx+B2Xn9NwxFb 11+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=Hj5kYkQm+5pJCHACOG/iSMHm84jLQAzCIMv4tchrLiw=; b=iqwzzqRANZUHF0QpmVUs2V1HEUOhKTVs8lNZeUPq6nmSjSG/lZArZ3SPVFRHHDMJ8i 5XBVzDd/TlTkg1fLSxIN0kMJGetJ+E0U6EPn61l9bRN4HzPWCkQPxVip0iSTg8qnoTpv OxJzWHFw6HQSA+/Z6cAX57gynsPinMou0YnDV46Lx0aUIaeboGbZOioVMD8FoIrgoQhF DB8MiPWy6C96fiAJZUXyyYJQPFXAHETP77qklLea8FCB7aGVbo1Vq9Vii222W4hdrczy C8t+qCcpqvnIaaKvmVGfTuqR9MI1YrhpLEeziNKQPhnb/asom6f89RKooT6Ps/oG76eU XtOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZFlMXIq+; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb35-20020a170907162300b006efc5a2c483si2167586ejc.958.2022.05.17.01.48.45; Tue, 17 May 2022 01:49:11 -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=@chromium.org header.s=google header.b=ZFlMXIq+; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346189AbiEPTtt (ORCPT + 99 others); Mon, 16 May 2022 15:49:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231749AbiEPTn0 (ORCPT ); Mon, 16 May 2022 15:43:26 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26ACD3ED35 for ; Mon, 16 May 2022 12:42:52 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id l14so4510216pjk.2 for ; Mon, 16 May 2022 12:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hj5kYkQm+5pJCHACOG/iSMHm84jLQAzCIMv4tchrLiw=; b=ZFlMXIq+IQUeeyDt6fafn2sjvdLxHOAjmD8mb8sFvqASHoEehVDVTCYMkCf1ElZy1X p7FthQqGWMKsLygocu8Bd6oL/O7B6yP+HcMJxPBPO+3rCHhrFqtjaATafc7avEsv06QF T81J0wbb5LOe3xLJDV/e9aH44Z65F/Iu+buYk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=Hj5kYkQm+5pJCHACOG/iSMHm84jLQAzCIMv4tchrLiw=; b=L5RV5X73Zezb0I/lcpR8fc3zyg4kd6Dx6arTkrZF+Mlh/VYmj5EJ0a8rOoIKKXHqG+ pbXVH0bNAuL1lw7jrd4v0wBehbfxt0gQIOhlesBRSGVRfcE/cK84721/i0OhTmLSRNzr R81nZOXcA60xnGNEeMxoSekZBA85zGMJymrIxSnWz5qi1Mg38okshf5BF7lSX16ui7Z6 eZgBhxYszVpTTGwtuCMU2IaKWIjQu+0KbAlqUakdrEaaDahq3CXKo1kzHSdKFU+iyXoJ vPuSmLx5heQjf1GNFDaznSodmQAF8zC64XCFOGiMe/ap3pmakTwHJx6Q8phCKk9VWmG+ ZzQA== X-Gm-Message-State: AOAM532XXqz/PIyNjyfyLVXg6Pf2x53fkwfCo/uz3bErbj493b8d66aR C2+ibke2Hfdz736DTkTqM6Hacw== X-Received: by 2002:a17:902:d483:b0:15e:9e44:8a07 with SMTP id c3-20020a170902d48300b0015e9e448a07mr19046812plg.77.1652730171655; Mon, 16 May 2022 12:42:51 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h125-20020a62de83000000b0050dc7628173sm7282259pfg.77.2022.05.16.12.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 12:42:51 -0700 (PDT) From: Kees Cook To: Ingo Molnar , Peter Zijlstra Cc: Kees Cook , Christophe de Dinechin , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Davidlohr Bueso , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH] sched/core: Do not treat class list boundary markers as arrays Date: Mon, 16 May 2022 12:42:41 -0700 Message-Id: <20220516194241.3064242-1-keescook@chromium.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=2796; h=from:subject; bh=UUhCQXF+TJsScoULeerZiaeI/lJVAC/bHGDo6ByIWx0=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBigqkx7kVZ/e0yr2DdH/3zd4rgBLL7WPMgcNF3paNW LbCFk0CJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYoKpMQAKCRCJcvTf3G3AJiHPD/ 9lSb4utJjgIxavP3rGUgfkcC0PXcXc8Ps6ff/Rq75RS5jqff9QLpLrdgE/KbWOycSznvbAkWw2tZxe VX+xsllAAyK9NrZjrtIqfnwcYMe90VBDv98fdMgHdprktFx81hmnDKGJ6n6ulxTEM+54ADkxlcehTg PP+pQoptZI4EAYl3mtPMTdK1HXikH4gqegkilEl0DzGCfTBbuLjanKQ1+w0RqsNIhA0q8znQxVOVJC rHdEWa+1wm5nh6TT6sXVfCIAUVICqOQ5cpQcQ9cCODvFbi9pxKjOBzHPA7VKbT0uRltVcyWYDkDQn/ mrRO1JdlDi3qL2Te6q2lxcOoqjvjo0NySWt9dOBjvYWMW07Sev95E3OFyBWkYnOagSAjOFi76I1eIZ rZXEPnSy1eTAhpYyI6WyD58OVIxWkl9eXMVWfvpQgFCUyYYypEsroaxgoblsq1L1JYJgO1YP66XhFI iPiyrvyg8hYTA6GZxhxn6LFL/9pIW502TB1g+rlRT4DuDb/kVu4bi9hPPbTlhef7HybRsN+r7ZLtyb mcfMtMVr+EUTkEb2n1m3FiOdMlq2ZDUAEajMs3EYQUvEFyprvi1CYLmIfdHjVJKX1ZY/so/0VqCfHA u2jQBC8KUHUfiYlMb3Z5dmJXiuLGWpHhxL5uJdRJGLJOSWSZCq0wzQNxH+7Q== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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 GCC 12 is very sensitive about array checking, and views all negative array accesses as unsafe (a not unreasonable position). Avoid the warnings about __begin_sched_classes being accessed via negative bounds by converting them to the pointers they actually are. Silences this warning: In file included from kernel/sched/core.c:81: kernel/sched/core.c: In function ‘set_rq_online.part.0’: kernel/sched/sched.h:2197:52: error: array subscript -1 is outside array bounds of ‘struct sched_class[44343134792571037]’ [-Werror=array-bounds] 2197 | #define sched_class_lowest (__begin_sched_classes - 1) | ^ kernel/sched/sched.h:2200:41: note: in definition of macro ‘for_class_range’ 2200 | for (class = (_from); class != (_to); class--) | ^~~ kernel/sched/sched.h:2203:53: note: in expansion of macro ‘sched_class_lowest’ 2203 |for_class_range(class, sched_class_highest, sched_class_lowest) | ^~~~~~~~~~~~~~~~~~ kernel/sched/core.c:9115:17: note: in expansion of macro ‘for_each_class’ 9115 | for_each_class(class) { | ^~~~~~~~~~~~~~ kernel/sched/sched.h:2193:27: note: at offset -208 into object ‘__begin_sched_classes’ of size [0, 9223372036854775807] 2193 | extern struct sched_class __begin_sched_classes[]; | ^~~~~~~~~~~~~~~~~~~~~ Reported-by: Christophe de Dinechin Link: https://lore.kernel.org/lkml/20220414150855.2407137-2-dinechin@redhat.com/ Cc: Ingo Molnar Cc: Juri Lelli Cc: Vincent Guittot Cc: Dietmar Eggemann Cc: Steven Rostedt Cc: Ben Segall Cc: Mel Gorman Cc: Daniel Bristot de Oliveira Signed-off-by: Kees Cook --- kernel/sched/sched.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index 8dccb34eb190..3d31ed9d33fa 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -2190,8 +2190,8 @@ const struct sched_class name##_sched_class \ __section("__" #name "_sched_class") /* Defined in include/asm-generic/vmlinux.lds.h */ -extern struct sched_class __begin_sched_classes[]; -extern struct sched_class __end_sched_classes[]; +extern struct sched_class *__begin_sched_classes; +extern struct sched_class *__end_sched_classes; #define sched_class_highest (__end_sched_classes - 1) #define sched_class_lowest (__begin_sched_classes - 1) -- 2.32.0