Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2887670rwb; Mon, 15 Aug 2022 13:20:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR7r2Nja5p0wLOCwGHNpiPwh9nnHURVAulqpoOWRXoigKTAGzKeeZ8S2uz/Pm6Nad5271HQg X-Received: by 2002:a17:907:969f:b0:730:df57:123d with SMTP id hd31-20020a170907969f00b00730df57123dmr11624269ejc.430.1660594842708; Mon, 15 Aug 2022 13:20:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660594842; cv=none; d=google.com; s=arc-20160816; b=Kf3KCbgetiGwty2+fXKLVNSQlFlRWJ5rssyaj8PGeFSuJOV4OqCk+hM0/D4ZMzi0tj RyGWk74daZSxTK2hMvIg0WJC2MSRTGDsYcg86mOhGerrDAK4IklDfo3WNbZ9qSbuBnXG KEmE6AQx5i7cnyJrnVLAVbwzRERgkIK2/cxKqHKOfCeklNDpgGQqumbXtCnMO8aU8GJo NqQz8b0zEX7sv1IkHsYTqy0fk6F01UPF/+KhTLw623x+2KOzRHwr5dS8FLc1v22twZXr 7khauKAkJrff9tMiqBMpfMcOWQ55+oZZQWokWKnBZaF1TcQFh0jM9C3oGX+RuKWOd4hn CVfg== 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=V+9MBFPemX37GCqj5OhdYEwSGGlWTWd9nY8UMGJ6sU4=; b=T+odOyYVAQ1bFFYQHiyoehMKG2seyjOprGUBz2JwjFMgZzMtmTBcEhJj6Aw45VTlvF 29+vq1btlRpk07oNSG6kBxH/xx7h2Y3ZlU2Wa5ygZlg2q++493g4dNm/h7uNLPZCq9kZ n/EKDrJK+sWcEel521cG8TB7JVIpzCv1HVABHENdtx+Om+r1JPi6HtUWDyltnAs7r+0R +jFWB7msI/OQ1f324e/Pbt2kxwmhLLgFBpyrDtigidpRXQs7uzgYa/0Jyx3DpTi/Ptu9 gC5s1stRqJyh+rPW6r/PP0OBeFijKLGSQWBLQiNr1djgEEfvwpx4n6iAagQWvDE6O5pY qi3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Mac2T1PV; 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 hd43-20020a17090796ab00b00734b26a17e8si10805949ejc.36.2022.08.15.13.20.13; Mon, 15 Aug 2022 13:20:42 -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=Mac2T1PV; 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 S1345807AbiHOUES (ORCPT + 99 others); Mon, 15 Aug 2022 16:04:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345780AbiHOUD0 (ORCPT ); Mon, 15 Aug 2022 16:03:26 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FF107E022; Mon, 15 Aug 2022 11:54:16 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 91102611D6; Mon, 15 Aug 2022 18:54:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16186C433D6; Mon, 15 Aug 2022 18:54:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660589655; bh=0dG4uuL291nO1aV8Tjx0Cq3qOuuLfuwV842Ght+TL5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Mac2T1PVCxmOtUJ1WiFKMJVHTVvUKAvZGGMWgQAEsJspn6v0L/LcO94ps8y4mGpFi DhwRpf6kYrCWZg40NCyxmpWJAleQNVUDCRXzZAjd4i5ORE2XVqCIK26ZSsVLxL+RI8 0eb3oWG9oS0P+TvSMrEC1yGU4wkoX7diWgPVKl3s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Steven Rostedt , Masami Hiramatsu , Stephen Rothwell , Kees Cook Subject: [PATCH 5.15 770/779] tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro Date: Mon, 15 Aug 2022 20:06:54 +0200 Message-Id: <20220815180410.302077206@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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 commit c6d777acdf8f62d4ebaef0e5c6cd8fedbd6e8546 upstream. As done for trace_events.h, also fix the __rel_loc macro in perf.h, which silences the -Warray-bounds warning: In file included from ./include/linux/string.h:253, from ./include/linux/bitmap.h:11, from ./include/linux/cpumask.h:12, from ./include/linux/mm_types_task.h:14, from ./include/linux/mm_types.h:5, from ./include/linux/buildid.h:5, from ./include/linux/module.h:14, from samples/trace_events/trace-events-sample.c:2: In function '__fortify_strcpy', inlined from 'perf_trace_foo_rel_loc' at samples/trace_events/./trace-events-sample.h:519:1: ./include/linux/fortify-string.h:47:33: warning: '__builtin_strcpy' offset 12 is out of the bounds [ 0, 4] [-Warray-bounds] 47 | #define __underlying_strcpy __builtin_strcpy | ^ ./include/linux/fortify-string.h:445:24: note: in expansion of macro '__underlying_strcpy' 445 | return __underlying_strcpy(p, q); | ^~~~~~~~~~~~~~~~~~~ Also make __data struct member a proper flexible array to avoid future problems. Link: https://lkml.kernel.org/r/20220125220037.2738923-1-keescook@chromium.org Cc: Steven Rostedt Cc: Masami Hiramatsu Fixes: 55de2c0b5610c ("tracing: Add '__rel_loc' using trace event macros") Reported-by: Stephen Rothwell Signed-off-by: Kees Cook Signed-off-by: Steven Rostedt (Google) Signed-off-by: Greg Kroah-Hartman --- include/trace/perf.h | 5 +++-- include/trace/trace_events.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) --- a/include/trace/perf.h +++ b/include/trace/perf.h @@ -23,8 +23,9 @@ #undef __get_rel_dynamic_array #define __get_rel_dynamic_array(field) \ - ((void *)(&__entry->__rel_loc_##field) + \ - sizeof(__entry->__rel_loc_##field) + \ + ((void *)__entry + \ + offsetof(typeof(*__entry), __rel_loc_##field) + \ + sizeof(__entry->__rel_loc_##field) + \ (__entry->__rel_loc_##field & 0xffff)) #undef __get_rel_dynamic_array_len --- a/include/trace/trace_events.h +++ b/include/trace/trace_events.h @@ -128,7 +128,7 @@ TRACE_MAKE_SYSTEM_STR(); struct trace_event_raw_##name { \ struct trace_entry ent; \ tstruct \ - char __data[0]; \ + char __data[]; \ }; \ \ static struct trace_event_class event_class_##name;