linux/include
Steven Rostedt (Google) 0ab3e0d31a tracing: Use a struct alignof to determine trace event field alignment
[ Upstream commit 4c3d2f9388 ]

alignof() gives an alignment of types as they would be as standalone
variables. But alignment in structures might be different, and when
building the fields of events, the alignment must be the actual
alignment otherwise the field offsets may not match what they actually
are.

This caused trace-cmd to crash, as libtraceevent did not check if the
field offset was bigger than the event. The write_msr and read_msr
events on 32 bit had their fields incorrect, because it had a u64 field
between two ints. alignof(u64) would give 8, but the u64 field was at a
4 byte alignment.

Define a macro as:

   ALIGN_STRUCTFIELD(type) ((int)(offsetof(struct {char a; type b;}, b)))

which gives the actual alignment of types in a structure.

Link: https://lkml.kernel.org/r/20220731015928.7ab3a154@rorschach.local.home

Cc: Ingo Molnar <mingo@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: stable@vger.kernel.org
Fixes: 04ae87a520 ("ftrace: Rework event_create_dir()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2022-08-17 15:16:15 +02:00
..
acpi ACPI: CPPC: Do not prevent CPPC from working in the future 2022-08-17 15:16:13 +02:00
asm-generic asm-generic fixes for 5.19, part 2 2022-07-27 09:50:18 -07:00
clocksource pwm: Changes for v5.19-rc1 2022-06-01 10:49:11 -07:00
crypto crypto: blake2s - remove shash module 2022-08-17 15:16:07 +02:00
drm devcoredump: remove the useless gfp_t parameter in dev_coredumpv and dev_coredumpm 2022-08-17 15:15:21 +02:00
dt-bindings clk: qcom: gcc-msm8939: Add missing SYSTEM_MM_NOC_BFDCD_CLK_SRC 2022-08-17 15:15:23 +02:00
keys certs: Move load_certificate_list() to be with the asymmetric keys code 2022-06-21 16:05:06 +01:00
kunit kunit: take kunit_assert as const 2022-05-16 13:23:00 -06:00
kvm Merge branch kvm-arm64/per-vcpu-host-pmu-data into kvmarm-master/next 2022-05-16 17:48:36 +01:00
linux dm: fix dm-raid crash if md_handle_request() splits bio 2022-08-17 15:16:14 +02:00
math-emu math-emu: Fix fall-through warning 2021-07-13 13:57:44 -05:00
media media: uapi: HEVC: Change pic_order_cnt definition in v4l2_hevc_dpb_entry 2022-08-17 15:14:50 +02:00
memory memory: renesas-rpc-if: Fix HF/OSPI data transfer in Manual Mode 2022-04-21 17:00:24 +02:00
misc ocxl: Update the Process Element Entry 2020-12-04 01:01:30 +11:00
net 9p: Add client parameter to p9_req_put() 2022-08-17 15:15:53 +02:00
pcmcia ARM: pxa/sa1100: move I/O space to PCI_IOBASE 2022-05-07 22:56:17 +02:00
ras Revert "mm/memory-failure.c: fix race with changing page compound again" 2022-04-28 23:16:02 -07:00
rdma RDMA/core: Fix typo in comment 2022-05-24 11:24:58 -03:00
scsi scsi: iscsi: Fix session removal on shutdown 2022-08-17 15:15:22 +02:00
soc net: dsa: felix: keep reference on entire tc-taprio config 2022-08-17 15:14:39 +02:00
sound ASoC: Remove unused hw_write_t type 2022-06-24 16:21:41 +01:00
target SCSI misc on 20220524 2022-05-25 19:09:48 -07:00
trace tracing: Use a struct alignof to determine trace event field alignment 2022-08-17 15:16:15 +02:00
uapi dm: fix dm-raid crash if md_handle_request() splits bio 2022-08-17 15:16:14 +02:00
ufs scsi: ufs: Split the drivers/scsi/ufs directory 2022-05-19 20:27:37 -04:00
vdso time64.h: Consolidated PSEC_PER_SEC definition 2021-04-06 16:32:17 -07:00
video video: of_display_timing.h: include errno.h 2022-07-06 17:16:20 +02:00
xen xen: don't require virtio with grants for non-PV guests 2022-08-17 15:15:41 +02:00