Skip to content

Commit

Permalink
perf: uapi: Document perf_event_attr::sig_data truncation on 32 bit a…
Browse files Browse the repository at this point in the history
…rchitectures

Due to the alignment requirements of siginfo_t, as described in
3ddb3fd ("signal, perf: Fix siginfo_t by avoiding u64 on 32-bit
architectures"), siginfo_t::si_perf_data is limited to an unsigned long.

However, perf_event_attr::sig_data is an u64, to avoid having to deal
with compat conversions. Due to being an u64, it may not immediately be
clear to users that sig_data is truncated on 32 bit architectures.

Add a comment to explicitly point this out, and hopefully help some
users save time by not having to deduce themselves what's happening.

Reported-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Marco Elver <elver@google.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Link: https://lore.kernel.org/r/20220131103407.1971678-3-elver@google.com
  • Loading branch information
Marco Elver authored and Peter Zijlstra committed Feb 2, 2022
1 parent 95d29fa commit ddecd22
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/uapi/linux/perf_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,8 @@ struct perf_event_attr {
/*
* User provided data if sigtrap=1, passed back to user via
* siginfo_t::si_perf_data, e.g. to permit user to identify the event.
* Note, siginfo_t::si_perf_data is long-sized, and sig_data will be
* truncated accordingly on 32 bit architectures.
*/
__u64 sig_data;
};
Expand Down

0 comments on commit ddecd22

Please sign in to comment.