Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1417716
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!gothmog.csi.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Dave Hansen <dave@sr71.net> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 1/3] x86, signals: add missing signal_compat code for x86 features |
| Date | Wed, 08 Jun 2016 19:30:01 +0200 |
| Message-ID | <rHPsJ-367-13@gated-at.bofh.it> (permalink) |
| References | <rHPsJ-367-15@gated-at.bofh.it> |
| X-Extloop1 | 1 |
| X-Ironport-Av | E=Sophos;i="5.26,440,1459839600"; d="scan'208";a="997970220" |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 88 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | x86@kernel.org, Dave Hansen <dave@sr71.net>, dave.hansen@linux.intel.com, tony.luck@intel.com, bp@alien8.de, linux-edac@vger.kernel.org, luto@kernel.org |
| X-Original-Date | Wed, 08 Jun 2016 10:25:33 -0700 |
| X-Original-Message-ID | <20160608172533.F8F05637@viggo.jf.intel.com> |
| X-Original-References | <20160608172531.E4FC5E65@viggo.jf.intel.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1417716 |
Show key headers only | View raw
From: Dave Hansen <dave.hansen@linux.intel.com>
The 32-bit siginfo is a different binary format than the 64-bit
one. So, when running 32-bit binaries on 64-bit kernels, we have
to convert the kernel's 64-bit version to a 32-bit version that
userspace can grok.
We've added a few features to siginfo over the past few years and
neglected to add them to arch/x86/kernel/signal_compat.c:
1. The si_addr_lsb used in SIGBUS's sent for machine checks
2. The upper/lower bounds for MPX SIGSEGV faults
3. The protection key for pkey faults
I caught this with some protection keys unit tests and realized
it affected a few more features.
This was tested only with my protection keys patch that looks
for a proper value in si_pkey. I didn't actually test the machine
check or MPX code.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: linux-edac@vger.kernel.org
Cc: x86@kernel.org
Cc: Andy Lutomirski <luto@kernel.org>
---
b/arch/x86/include/asm/compat.h | 11 +++++++++++
b/arch/x86/kernel/signal_compat.c | 15 +++++++++++++++
2 files changed, 26 insertions(+)
diff -puN arch/x86/include/asm/compat.h~add-signal-compat-for-mpx-pkeys arch/x86/include/asm/compat.h
--- a/arch/x86/include/asm/compat.h~add-signal-compat-for-mpx-pkeys 2016-06-08 10:23:23.559472773 -0700
+++ b/arch/x86/include/asm/compat.h 2016-06-08 10:23:23.564472998 -0700
@@ -40,6 +40,7 @@ typedef s32 compat_long_t;
typedef s64 __attribute__((aligned(4))) compat_s64;
typedef u32 compat_uint_t;
typedef u32 compat_ulong_t;
+typedef u32 compat_u32;
typedef u64 __attribute__((aligned(4))) compat_u64;
typedef u32 compat_uptr_t;
@@ -181,6 +182,16 @@ typedef struct compat_siginfo {
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
struct {
unsigned int _addr; /* faulting insn/memory ref. */
+ short int _addr_lsb; /* Valid LSB of the reported address. */
+ union {
+ /* used when si_code=SEGV_BNDERR */
+ struct {
+ compat_uptr_t _lower;
+ compat_uptr_t _upper;
+ } _addr_bnd;
+ /* used when si_code=SEGV_PKUERR */
+ compat_u32 _pkey;
+ };
} _sigfault;
/* SIGPOLL */
diff -puN arch/x86/kernel/signal_compat.c~add-signal-compat-for-mpx-pkeys arch/x86/kernel/signal_compat.c
--- a/arch/x86/kernel/signal_compat.c~add-signal-compat-for-mpx-pkeys 2016-06-08 10:23:23.561472863 -0700
+++ b/arch/x86/kernel/signal_compat.c 2016-06-08 10:23:23.565473043 -0700
@@ -32,6 +32,21 @@ int copy_siginfo_to_user32(compat_siginf
&to->_sifields._pad[0]);
switch (from->si_code >> 16) {
case __SI_FAULT >> 16:
+ if (from->si_signo == SIGBUS &&
+ (from->si_code == BUS_MCEERR_AR ||
+ from->si_code == BUS_MCEERR_AO))
+ put_user_ex(from->si_addr_lsb, &to->si_addr_lsb);
+
+ if (from->si_signo == SIGSEGV) {
+ if (from->si_code == SEGV_BNDERR) {
+ compat_uptr_t lower = (unsigned long)&to->si_lower;
+ compat_uptr_t upper = (unsigned long)&to->si_upper;
+ put_user_ex(lower, &to->si_lower);
+ put_user_ex(upper, &to->si_upper);
+ }
+ if (from->si_code == SEGV_PKUERR)
+ put_user_ex(from->si_pkey, &to->si_pkey);
+ }
break;
case __SI_SYS >> 16:
put_user_ex(from->si_syscall, &to->si_syscall);
_
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[PATCH 1/3] x86, signals: add missing signal_compat code for x86 features Dave Hansen <dave@sr71.net> - 2016-06-08 19:30 +0200
csiph-web