Re: [PATCH v3 00/12] signal: sort out si_trapno and si_perf

From: Eric W. Biederman
Date: Thu May 06 2021 - 11:14:34 EST


Geert Uytterhoeven <geert@xxxxxxxxxxxxxx> writes:

> Hi Eric,
>
> On Tue, May 4, 2021 at 11:14 PM Eric W. Biederman <ebiederm@xxxxxxxxxxxx> wrote:
>> This set of changes sorts out the ABI issues with SIGTRAP TRAP_PERF, and
>> hopefully will can get merged before any userspace code starts using the
>> new ABI.
>>
>> The big ideas are:
>> - Placing the asserts first to prevent unexpected ABI changes
>> - si_trapno becomming ordinary fault subfield.
>> - struct signalfd_siginfo is almost full
>>
>> This set of changes starts out with Marco's static_assert changes and
>> additional one of my own that enforces the fact that the alignment of
>> siginfo_t is also part of the ABI. Together these build time
>> checks verify there are no unexpected ABI changes in the changes
>> that follow.
>>
>> The field si_trapno is changed to become an ordinary extension of the
>> _sigfault member of siginfo.
>>
>> The code is refactored a bit and then si_perf_type is added along side
>> si_perf_data in the _perf subfield of _sigfault of siginfo_t.
>>
>> Finally the signalfd_siginfo fields are removed as they appear to be
>> filling up the structure without userspace actually being able to use
>> them.
>
> Thanks for your series, which is now in next-20210506.
>
>> arch/alpha/include/uapi/asm/siginfo.h | 2 -
>> arch/alpha/kernel/osf_sys.c | 2 +-
>> arch/alpha/kernel/signal.c | 4 +-
>> arch/alpha/kernel/traps.c | 24 ++---
>> arch/alpha/mm/fault.c | 4 +-
>> arch/arm/kernel/signal.c | 39 +++++++
>> arch/arm64/kernel/signal.c | 39 +++++++
>> arch/arm64/kernel/signal32.c | 39 +++++++
>> arch/mips/include/uapi/asm/siginfo.h | 2 -
>> arch/sparc/include/uapi/asm/siginfo.h | 3 -
>> arch/sparc/kernel/process_64.c | 2 +-
>> arch/sparc/kernel/signal32.c | 37 +++++++
>> arch/sparc/kernel/signal_64.c | 36 +++++++
>> arch/sparc/kernel/sys_sparc_32.c | 2 +-
>> arch/sparc/kernel/sys_sparc_64.c | 2 +-
>> arch/sparc/kernel/traps_32.c | 22 ++--
>> arch/sparc/kernel/traps_64.c | 44 ++++----
>> arch/sparc/kernel/unaligned_32.c | 2 +-
>> arch/sparc/mm/fault_32.c | 2 +-
>> arch/sparc/mm/fault_64.c | 2 +-
>> arch/x86/kernel/signal_compat.c | 15 ++-
>
> No changes needed for other architectures?
> All m68k configs are broken with

Thanks. I hadn't realized that si_perf asserts existed on m68k.
Thankfully linux-next caught this these.

Looking a little more deeply, it is strange that this is tested on m68k.
The architecture does not implement HAVE_PERF_EVENTS so it is impossible
for this signal to be generated.

On the off chance this these new signals will appear on m68k someday I
will update the assertion.

> arch/m68k/kernel/signal.c:626:35: error: 'siginfo_t' {aka 'struct
> siginfo'} has no member named 'si_perf'; did you mean 'si_errno'?
>
> See e.g. http://kisskb.ellerman.id.au/kisskb/buildresult/14537820/
>
> There are still a few more references left to si_perf:
>
> $ git grep -n -w si_perf
> Next/merge.log:2902:Merging userns/for-next (4cf4e48fff05 signal: sort
> out si_trapno and si_perf)
> arch/m68k/kernel/signal.c:626: BUILD_BUG_ON(offsetof(siginfo_t,
> si_perf) != 0x10);
> include/uapi/linux/perf_event.h:467: * siginfo_t::si_perf, e.g. to
> permit user to identify the event.
> tools/testing/selftests/perf_events/sigtrap_threads.c:46:/* Unique
> value to check si_perf is correctly set from
> perf_event_attr::sig_data. */

I will sweep them up as well.

Eric