提交 9abcabe3 编写于 作者: E Eric W. Biederman

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.comReviewed-by: NMarco Elver <elver@google.com>
Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
上级 add0b32e
...@@ -123,15 +123,13 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo, ...@@ -123,15 +123,13 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
*/ */
case SIL_FAULT: case SIL_FAULT:
new.ssi_addr = (long) kinfo->si_addr; new.ssi_addr = (long) kinfo->si_addr;
#ifdef __ARCH_SI_TRAPNO break;
case SIL_FAULT_TRAPNO:
new.ssi_addr = (long) kinfo->si_addr;
new.ssi_trapno = kinfo->si_trapno; new.ssi_trapno = kinfo->si_trapno;
#endif
break; break;
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
new.ssi_addr = (long) kinfo->si_addr; new.ssi_addr = (long) kinfo->si_addr;
#ifdef __ARCH_SI_TRAPNO
new.ssi_trapno = kinfo->si_trapno;
#endif
new.ssi_addr_lsb = (short) kinfo->si_addr_lsb; new.ssi_addr_lsb = (short) kinfo->si_addr_lsb;
break; break;
case SIL_PERF_EVENT: case SIL_PERF_EVENT:
......
...@@ -40,6 +40,7 @@ enum siginfo_layout { ...@@ -40,6 +40,7 @@ enum siginfo_layout {
SIL_TIMER, SIL_TIMER,
SIL_POLL, SIL_POLL,
SIL_FAULT, SIL_FAULT,
SIL_FAULT_TRAPNO,
SIL_FAULT_MCEERR, SIL_FAULT_MCEERR,
SIL_FAULT_BNDERR, SIL_FAULT_BNDERR,
SIL_FAULT_PKUERR, SIL_FAULT_PKUERR,
......
...@@ -1194,6 +1194,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info) ...@@ -1194,6 +1194,7 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)
case SIL_TIMER: case SIL_TIMER:
case SIL_POLL: case SIL_POLL:
case SIL_FAULT: case SIL_FAULT:
case SIL_FAULT_TRAPNO:
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
...@@ -2527,6 +2528,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig) ...@@ -2527,6 +2528,7 @@ static void hide_si_addr_tag_bits(struct ksignal *ksig)
{ {
switch (siginfo_layout(ksig->sig, ksig->info.si_code)) { switch (siginfo_layout(ksig->sig, ksig->info.si_code)) {
case SIL_FAULT: case SIL_FAULT:
case SIL_FAULT_TRAPNO:
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
...@@ -3214,6 +3216,10 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code) ...@@ -3214,6 +3216,10 @@ enum siginfo_layout siginfo_layout(unsigned sig, int si_code)
#endif #endif
else if ((sig == SIGTRAP) && (si_code == TRAP_PERF)) else if ((sig == SIGTRAP) && (si_code == TRAP_PERF))
layout = SIL_PERF_EVENT; layout = SIL_PERF_EVENT;
#ifdef __ARCH_SI_TRAPNO
else if (layout == SIL_FAULT)
layout = SIL_FAULT_TRAPNO;
#endif
} }
else if (si_code <= NSIGPOLL) else if (si_code <= NSIGPOLL)
layout = SIL_POLL; layout = SIL_POLL;
...@@ -3317,30 +3323,22 @@ void copy_siginfo_to_external32(struct compat_siginfo *to, ...@@ -3317,30 +3323,22 @@ void copy_siginfo_to_external32(struct compat_siginfo *to,
break; break;
case SIL_FAULT: case SIL_FAULT:
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
#ifdef __ARCH_SI_TRAPNO break;
case SIL_FAULT_TRAPNO:
to->si_addr = ptr_to_compat(from->si_addr);
to->si_trapno = from->si_trapno; to->si_trapno = from->si_trapno;
#endif
break; break;
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_addr_lsb = from->si_addr_lsb; to->si_addr_lsb = from->si_addr_lsb;
break; break;
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_lower = ptr_to_compat(from->si_lower); to->si_lower = ptr_to_compat(from->si_lower);
to->si_upper = ptr_to_compat(from->si_upper); to->si_upper = ptr_to_compat(from->si_upper);
break; break;
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
to->si_addr = ptr_to_compat(from->si_addr); to->si_addr = ptr_to_compat(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_pkey = from->si_pkey; to->si_pkey = from->si_pkey;
break; break;
case SIL_PERF_EVENT: case SIL_PERF_EVENT:
...@@ -3401,30 +3399,22 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to, ...@@ -3401,30 +3399,22 @@ static int post_copy_siginfo_from_user32(kernel_siginfo_t *to,
break; break;
case SIL_FAULT: case SIL_FAULT:
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
#ifdef __ARCH_SI_TRAPNO break;
case SIL_FAULT_TRAPNO:
to->si_addr = compat_ptr(from->si_addr);
to->si_trapno = from->si_trapno; to->si_trapno = from->si_trapno;
#endif
break; break;
case SIL_FAULT_MCEERR: case SIL_FAULT_MCEERR:
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_addr_lsb = from->si_addr_lsb; to->si_addr_lsb = from->si_addr_lsb;
break; break;
case SIL_FAULT_BNDERR: case SIL_FAULT_BNDERR:
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_lower = compat_ptr(from->si_lower); to->si_lower = compat_ptr(from->si_lower);
to->si_upper = compat_ptr(from->si_upper); to->si_upper = compat_ptr(from->si_upper);
break; break;
case SIL_FAULT_PKUERR: case SIL_FAULT_PKUERR:
to->si_addr = compat_ptr(from->si_addr); to->si_addr = compat_ptr(from->si_addr);
#ifdef __ARCH_SI_TRAPNO
to->si_trapno = from->si_trapno;
#endif
to->si_pkey = from->si_pkey; to->si_pkey = from->si_pkey;
break; break;
case SIL_PERF_EVENT: case SIL_PERF_EVENT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册