mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Kees Cook <keescook@chromium.org>,
	Masami Hiramatsu <mhiramat@kernel.org>
Subject: [for-linus][PATCH 03/10] tracing: Avoid -Warray-bounds warning for __rel_loc macro
Date: Fri, 28 Jan 2022 11:18:05 -0500	[thread overview]
Message-ID: <20220128162343.802534491@goodmis.org> (raw)
In-Reply-To: <20220128161802.711119424@goodmis.org>

From: Masami Hiramatsu <mhiramat@kernel.org>

Since -Warray-bounds checks the destination size from the type of given
pointer, __assign_rel_str() macro gets warned because it passes the
pointer to the 'u32' field instead of 'trace_event_raw_*' data structure.
Pass the data address calculated from the 'trace_event_raw_*' instead of
'u32' __rel_loc field.

Link: https://lkml.kernel.org/r/20220125233154.dac280ed36944c0c2fe6f3ac@kernel.org

Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
[ This did not fix the warning, but is still a nice clean up ]
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 include/trace/trace_events.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/trace/trace_events.h b/include/trace/trace_events.h
index 8c6f7c433518..65d927e059d3 100644
--- a/include/trace/trace_events.h
+++ b/include/trace/trace_events.h
@@ -318,9 +318,10 @@ TRACE_MAKE_SYSTEM_STR();
 #define __get_str(field) ((char *)__get_dynamic_array(field))
 
 #undef __get_rel_dynamic_array
-#define __get_rel_dynamic_array(field)	\
-		((void *)(&__entry->__rel_loc_##field) +	\
-		 sizeof(__entry->__rel_loc_##field) +		\
+#define __get_rel_dynamic_array(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
-- 
2.33.0

  parent reply	other threads:[~2022-01-28 16:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28 16:18 [for-linus][PATCH 00/10] tracing: Fixes for 5.17-rc1 Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 01/10] ftrace: Have architectures opt-in for mcount build time sorting Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 02/10] tracing/histogram: Fix a potential memory leak for kstrdup() Steven Rostedt
2022-01-28 16:18 ` Steven Rostedt [this message]
2022-01-28 16:18 ` [for-linus][PATCH 04/10] tracing/perf: Avoid -Warray-bounds warning for __rel_loc macro Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 05/10] rtla: Make doc build optional Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 06/10] tools/tracing: Update Makefile to build rtla Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 07/10] tracing: Fix smatch warning for null glob in event_hist_trigger_parse() Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 08/10] tracing: Fix smatch warning for do while check " Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 09/10] tracing: Propagate is_signed to expression Steven Rostedt
2022-01-28 16:18 ` [for-linus][PATCH 10/10] tracing: Dont inc err_log entry count if entry allocation fails Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220128162343.802534491@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome