[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230306122529.44e8d566@gandalf.local.home>
Date: Mon, 6 Mar 2023 12:25:29 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Douglas RAILLARD <douglas.raillard@....com>
Cc: Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
linux-f2fs-devel@...ts.sourceforge.net (open list:F2FS FILE SYSTEM),
linux-kernel@...r.kernel.org (open list:TRACING),
linux-trace-kernel@...r.kernel.org (open list:TRACING)
Subject: Re: [PATCH] f2fs: Fix f2fs_truncate_partial_nodes ftrace event
On Mon, 6 Mar 2023 11:15:13 -0500
Steven Rostedt <rostedt@...dmis.org> wrote:
> > diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
> > index 31d994e6b4ca..8d053838d6cf 100644
> > --- a/include/trace/events/f2fs.h
> > +++ b/include/trace/events/f2fs.h
> > @@ -512,7 +512,7 @@ TRACE_EVENT(f2fs_truncate_partial_nodes,
> > TP_STRUCT__entry(
> > __field(dev_t, dev)
> > __field(ino_t, ino)
> > - __field(nid_t, nid[3])
>
> That should not have even compiled. I'll see if I can add some tricks to
> make that fail.
And this patch makes that happen!
-- Steve
diff --git a/include/trace/stages/stage5_get_offsets.h b/include/trace/stages/stage5_get_offsets.h
index ac5c24d3beeb..e30a13be46ba 100644
--- a/include/trace/stages/stage5_get_offsets.h
+++ b/include/trace/stages/stage5_get_offsets.h
@@ -9,17 +9,30 @@
#undef __entry
#define __entry entry
+/*
+ * Fields should never declare an array: i.e. __field(int, arr[5])
+ * If they do, it will cause issues in parsing and possibly corrupt the
+ * events. To prevent that from happening, test the sizeof() a fictitious
+ * type called "struct _test_no_array_##item" which will fail if "item"
+ * contains array elements (like "arr[5]").
+ *
+ * If you hit this, use __array(int, arr, 5) instead.
+ */
#undef __field
-#define __field(type, item)
+#define __field(type, item) \
+ { (void)sizeof(struct _test_no_array_##item *); }
#undef __field_ext
-#define __field_ext(type, item, filter_type)
+#define __field_ext(type, item, filter_type) \
+ { (void)sizeof(struct _test_no_array_##item *); }
#undef __field_struct
-#define __field_struct(type, item)
+#define __field_struct(type, item) \
+ { (void)sizeof(struct _test_no_array_##item *); }
#undef __field_struct_ext
-#define __field_struct_ext(type, item, filter_type)
+#define __field_struct_ext(type, item, filter_type) \
+ { (void)sizeof(struct _test_no_array_##item *); }
#undef __array
#define __array(type, item, len)
Powered by blists - more mailing lists