Skip to content

Commit 9abcabe

Browse files
committed
signal: Implement SIL_FAULT_TRAPNO
Now that si_trapno is part of the union in _si_fault and available on all architectures, add SIL_FAULT_TRAPNO and update siginfo_layout to return SIL_FAULT_TRAPNO when the code assumes si_trapno is valid. There is room for future changes to reduce when si_trapno is valid but this is all that is needed to make si_trapno and the other members of the the union in _sigfault mutually exclusive. Update the code that uses siginfo_layout to deal with SIL_FAULT_TRAPNO and have the same code ignore si_trapno in in all other cases. v1: https://lkml.kernel.org/r/m1o8dvs7s7.fsf_-_@fess.ebiederm.org v2: https://lkml.kernel.org/r/20210505141101.11519-6-ebiederm@xmission.com Link: https://lkml.kernel.org/r/20210517195748.8880-2-ebiederm@xmission.com Reviewed-by: Marco Elver <elver@google.com> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
1 parent add0b32 commit 9abcabe

3 files changed

Lines changed: 16 additions & 27 deletions

File tree

fs/signalfd.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,13 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
123123
*/
124124
case SIL_FAULT:
125125
new.ssi_addr = (long) kinfo->si_addr;
126-
#ifdef __ARCH_SI_TRAPNO
126+
break;
127+
case SIL_FAULT_TRAPNO:
128+
new.ssi_addr = (long) kinfo->si_addr;
127129
new.ssi_trapno = kinfo->si_trapno;
128-
#endif
129130
break;
130131
case SIL_FAULT_MCEERR:
131132
new.ssi_addr = (long) kinfo->si_addr;
132-
#ifdef __ARCH_SI_TRAPNO
133-
new.ssi_trapno = kinfo->si_trapno;
134-
#endif
135133
new.ssi_addr_lsb = (short) kinfo->si_addr_lsb;
136134
break;
137135
case SIL_PERF_EVENT:

include/linux/signal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ enum siginfo_layout {
4040
SIL_TIMER,
4141
SIL_POLL,
4242
SIL_FAULT,
43+
SIL_FAULT_TRAPNO,
4344
SIL_FAULT_MCEERR,
4445
SIL_FAULT_BNDERR,
4546
SIL_FAULT_PKUERR,

kernel/signal.c

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)
11941194
case SIL_TIMER:
11951195
case SIL_POLL:
11961196
case SIL_FAULT:
1197+
case SIL_FAULT_TRAPNO:
11971198
case SIL_FAULT_MCEERR:
11981199
case SIL_FAULT_BNDERR:
11991200
case SIL_FAULT_PKUERR:
@@ -2527,6 +2528,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig)
25272528
{
25282529
switch (siginfo_layout(ksig->sig, ksig->info.si_code)) {
25292530
case SIL_FAULT:
2531+
case SIL_FAULT_TRAPNO:
25302532
case SIL_FAULT_MCEERR:
25312533
case SIL_FAULT_BNDERR:
25322534
case SIL_FAULT_PKUERR:
@@ -3214,6 +3216,10 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
32143216
#endif
32153217
else if ((sig == SIGTRAP) && (si_code == TRAP_PERF))
32163218
layout = SIL_PERF_EVENT;
3219+
#ifdef __ARCH_SI_TRAPNO
3220+
else if (layout == SIL_FAULT)
3221+
layout = SIL_FAULT_TRAPNO;
3222+
#endif
32173223
}
32183224
else if (si_code <= NSIGPOLL)
32193225
layout = SIL_POLL;
@@ -3317,30 +3323,22 @@ void copy_siginfo_to_external32(struct compat_siginfo *to,
33173323
break;
33183324
case SIL_FAULT:
33193325
to->si_addr = ptr_to_compat(from->si_addr);
3320-
#ifdef __ARCH_SI_TRAPNO
3326+
break;
3327+
case SIL_FAULT_TRAPNO:
3328+
to->si_addr = ptr_to_compat(from->si_addr);
33213329
to->si_trapno = from->si_trapno;
3322-
#endif
33233330
break;
33243331
case SIL_FAULT_MCEERR:
33253332
to->si_addr = ptr_to_compat(from->si_addr);
3326-
#ifdef __ARCH_SI_TRAPNO
3327-
to->si_trapno = from->si_trapno;
3328-
#endif
33293333
to->si_addr_lsb = from->si_addr_lsb;
33303334
break;
33313335
case SIL_FAULT_BNDERR:
33323336
to->si_addr = ptr_to_compat(from->si_addr);
3333-
#ifdef __ARCH_SI_TRAPNO
3334-
to->si_trapno = from->si_trapno;
3335-
#endif
33363337
to->si_lower = ptr_to_compat(from->si_lower);
33373338
to->si_upper = ptr_to_compat(from->si_upper);
33383339
break;
33393340
case SIL_FAULT_PKUERR:
33403341
to->si_addr = ptr_to_compat(from->si_addr);
3341-
#ifdef __ARCH_SI_TRAPNO
3342-
to->si_trapno = from->si_trapno;
3343-
#endif
33443342
to->si_pkey = from->si_pkey;
33453343
break;
33463344
case SIL_PERF_EVENT:
@@ -3401,30 +3399,22 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
34013399
break;
34023400
case SIL_FAULT:
34033401
to->si_addr = compat_ptr(from->si_addr);
3404-
#ifdef __ARCH_SI_TRAPNO
3402+
break;
3403+
case SIL_FAULT_TRAPNO:
3404+
to->si_addr = compat_ptr(from->si_addr);
34053405
to->si_trapno = from->si_trapno;
3406-
#endif
34073406
break;
34083407
case SIL_FAULT_MCEERR:
34093408
to->si_addr = compat_ptr(from->si_addr);
3410-
#ifdef __ARCH_SI_TRAPNO
3411-
to->si_trapno = from->si_trapno;
3412-
#endif
34133409
to->si_addr_lsb = from->si_addr_lsb;
34143410
break;
34153411
case SIL_FAULT_BNDERR:
34163412
to->si_addr = compat_ptr(from->si_addr);
3417-
#ifdef __ARCH_SI_TRAPNO
3418-
to->si_trapno = from->si_trapno;
3419-
#endif
34203413
to->si_lower = compat_ptr(from->si_lower);
34213414
to->si_upper = compat_ptr(from->si_upper);
34223415
break;
34233416
case SIL_FAULT_PKUERR:
34243417
to->si_addr = compat_ptr(from->si_addr);
3425-
#ifdef __ARCH_SI_TRAPNO
3426-
to->si_trapno = from->si_trapno;
3427-
#endif
34283418
to->si_pkey = from->si_pkey;
34293419
break;
34303420
case SIL_PERF_EVENT:

0 commit comments

Comments
 (0)