mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-25 17:30:54 +07:00
signal: Correct the offset of si_pkey and si_lower in struct siginfo on m68k
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:859d880cf5
("signal: Correct the offset of si_pkey in struct siginfo") Fixes:b68a68d3dc
("signal: Move addr_lsb into the _sigfault union for clarity") Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
This commit is contained in:
parent
266da65e91
commit
8420f71943
@ -221,6 +221,8 @@ typedef struct compat_siginfo {
|
|||||||
#ifdef __ARCH_SI_TRAPNO
|
#ifdef __ARCH_SI_TRAPNO
|
||||||
int _trapno; /* TRAP # which caused the signal */
|
int _trapno; /* TRAP # which caused the signal */
|
||||||
#endif
|
#endif
|
||||||
|
#define __COMPAT_ADDR_BND_PKEY_PAD (__alignof__(compat_uptr_t) < sizeof(short) ? \
|
||||||
|
sizeof(short) : __alignof__(compat_uptr_t))
|
||||||
union {
|
union {
|
||||||
/*
|
/*
|
||||||
* used when si_code=BUS_MCEERR_AR or
|
* used when si_code=BUS_MCEERR_AR or
|
||||||
@ -229,13 +231,13 @@ typedef struct compat_siginfo {
|
|||||||
short int _addr_lsb; /* Valid LSB of the reported address. */
|
short int _addr_lsb; /* Valid LSB of the reported address. */
|
||||||
/* used when si_code=SEGV_BNDERR */
|
/* used when si_code=SEGV_BNDERR */
|
||||||
struct {
|
struct {
|
||||||
compat_uptr_t _dummy_bnd;
|
char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD];
|
||||||
compat_uptr_t _lower;
|
compat_uptr_t _lower;
|
||||||
compat_uptr_t _upper;
|
compat_uptr_t _upper;
|
||||||
} _addr_bnd;
|
} _addr_bnd;
|
||||||
/* used when si_code=SEGV_PKUERR */
|
/* used when si_code=SEGV_PKUERR */
|
||||||
struct {
|
struct {
|
||||||
compat_uptr_t _dummy_pkey;
|
char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD];
|
||||||
u32 _pkey;
|
u32 _pkey;
|
||||||
} _addr_pkey;
|
} _addr_pkey;
|
||||||
};
|
};
|
||||||
|
@ -94,6 +94,9 @@ typedef struct siginfo {
|
|||||||
unsigned int _flags; /* see ia64 si_flags */
|
unsigned int _flags; /* see ia64 si_flags */
|
||||||
unsigned long _isr; /* isr */
|
unsigned long _isr; /* isr */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
|
||||||
|
sizeof(short) : __alignof__(void *))
|
||||||
union {
|
union {
|
||||||
/*
|
/*
|
||||||
* used when si_code=BUS_MCEERR_AR or
|
* used when si_code=BUS_MCEERR_AR or
|
||||||
@ -102,13 +105,13 @@ typedef struct siginfo {
|
|||||||
short _addr_lsb; /* LSB of the reported address */
|
short _addr_lsb; /* LSB of the reported address */
|
||||||
/* used when si_code=SEGV_BNDERR */
|
/* used when si_code=SEGV_BNDERR */
|
||||||
struct {
|
struct {
|
||||||
void *_dummy_bnd;
|
char _dummy_bnd[__ADDR_BND_PKEY_PAD];
|
||||||
void __user *_lower;
|
void __user *_lower;
|
||||||
void __user *_upper;
|
void __user *_upper;
|
||||||
} _addr_bnd;
|
} _addr_bnd;
|
||||||
/* used when si_code=SEGV_PKUERR */
|
/* used when si_code=SEGV_PKUERR */
|
||||||
struct {
|
struct {
|
||||||
void *_dummy_pkey;
|
char _dummy_pkey[__ADDR_BND_PKEY_PAD];
|
||||||
__u32 _pkey;
|
__u32 _pkey;
|
||||||
} _addr_pkey;
|
} _addr_pkey;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user