Skip to content

Commit e4423fc

Browse files
ebiedermgregkh
authored andcommitted
signal: Correct the offset of si_pkey and si_lower in struct siginfo on m68k
commit 8420f71 upstream. The change moving addr_lsb into the _sigfault union failed to take into account that _sigfault._addr_bnd._lower being a pointer forced the entire union to have pointer alignment. The fix for _sigfault._addr_bnd._lower having pointer alignment failed to take into account that m68k has a pointer alignment less than the size of a pointer. So simply making the padding members pointers changed the location of later members in the structure. Fix this by directly computing the needed size of the padding members, and making the padding members char arrays of the needed size. AKA if __alignof__(void *) is 1 sizeof(short) otherwise __alignof__(void *). Which should be exactly the same rules the compiler whould have used when computing the padding. I have tested this change by adding BUILD_BUG_ONs to m68k to verify the offset of every member of struct siginfo, and with those testing that the offsets of the fields in struct siginfo is the same before I changed the generic _sigfault member and after the correction to the _sigfault member. I have also verified that the x86 with it's own BUILD_BUG_ONs to verify the offsets of the siginfo members also compiles cleanly. Cc: stable@vger.kernel.org Reported-by: Eugene Syromiatnikov <esyr@redhat.com> Fixes: 859d880 ("signal: Correct the offset of si_pkey in struct siginfo") Fixes: b68a68d ("signal: Move addr_lsb into the _sigfault union for clarity") Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f85cbc commit e4423fc

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

‎include/linux/compat.h‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ typedef struct compat_siginfo {
222222
#ifdef __ARCH_SI_TRAPNO
223223
int _trapno; /* TRAP # which caused the signal */
224224
#endif
225+
#define __COMPAT_ADDR_BND_PKEY_PAD (__alignof__(compat_uptr_t) < sizeof(short) ? \
226+
sizeof(short) : __alignof__(compat_uptr_t))
225227
union {
226228
/*
227229
* used when si_code=BUS_MCEERR_AR or
@@ -230,13 +232,13 @@ typedef struct compat_siginfo {
230232
short int _addr_lsb; /* Valid LSB of the reported address. */
231233
/* used when si_code=SEGV_BNDERR */
232234
struct {
233-
compat_uptr_t _dummy_bnd;
235+
char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD];
234236
compat_uptr_t _lower;
235237
compat_uptr_t _upper;
236238
} _addr_bnd;
237239
/* used when si_code=SEGV_PKUERR */
238240
struct {
239-
compat_uptr_t _dummy_pkey;
241+
char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD];
240242
u32 _pkey;
241243
} _addr_pkey;
242244
};

‎include/uapi/asm-generic/siginfo.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ typedef struct siginfo {
9494
unsigned int _flags; /* see ia64 si_flags */
9595
unsigned long _isr; /* isr */
9696
#endif
97+
98+
#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
99+
sizeof(short) : __alignof__(void *))
97100
union {
98101
/*
99102
* used when si_code=BUS_MCEERR_AR or
@@ -102,13 +105,13 @@ typedef struct siginfo {
102105
short _addr_lsb; /* LSB of the reported address */
103106
/* used when si_code=SEGV_BNDERR */
104107
struct {
105-
void *_dummy_bnd;
108+
char _dummy_bnd[__ADDR_BND_PKEY_PAD];
106109
void __user *_lower;
107110
void __user *_upper;
108111
} _addr_bnd;
109112
/* used when si_code=SEGV_PKUERR */
110113
struct {
111-
void *_dummy_pkey;
114+
char _dummy_pkey[__ADDR_BND_PKEY_PAD];
112115
__u32 _pkey;
113116
} _addr_pkey;
114117
};

0 commit comments

Comments
 (0)