diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-03-03 14:59:13 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2020-03-05 14:40:28 -0300 |
commit | 24fdebe75f6df4c0edacb3f0cdc030913920aa4c (patch) | |
tree | 93fb399c11b914da400ce6f2a08c10b79e939eac /sysdeps/unix/sysv/linux/msgctl.c | |
parent | d5e492ba4ced4a9101f82dbbd9de77223b9932ac (diff) | |
download | glibc-24fdebe75f6df4c0edacb3f0cdc030913920aa4c.tar.gz glibc-24fdebe75f6df4c0edacb3f0cdc030913920aa4c.tar.xz glibc-24fdebe75f6df4c0edacb3f0cdc030913920aa4c.zip |
linux: Clear mode_t padding bits (BZ#25623)
The kernel might not clear the padding value for the ipc_perm mode fields in compat mode (32 bit running on a 64 bit kernel). It was fixed on v4.14 when the ipc compat code was refactored to move (commits 553f770ef71b, 469391684626, c0ebccb6fa1e). Although it is most likely a kernel issue, it was shown only due BZ#18231 fix which made all the SysVIPC mode_t 32-bit regardless of the kABI. This patch fixes it by explicitly zeroing the upper bits for such cases. The __ASSUME_SYSVIPC_BROKEN_MODE_T case already handles it with the shift. (The aarch64 ipc_priv.h is superflous since __ASSUME_SYSVIPC_DEFAULT_IPC_64 is now defined as default). Checked on i686-linux-gnu on 3.10 and on 4.15 kernel.
Diffstat (limited to 'sysdeps/unix/sysv/linux/msgctl.c')
-rw-r--r-- | sysdeps/unix/sysv/linux/msgctl.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sysdeps/unix/sysv/linux/msgctl.c b/sysdeps/unix/sysv/linux/msgctl.c index 27879e76cd..eb28835b3a 100644 --- a/sysdeps/unix/sysv/linux/msgctl.c +++ b/sysdeps/unix/sysv/linux/msgctl.c @@ -61,7 +61,6 @@ __new_msgctl (int msqid, int cmd, struct msqid_ds *buf) int ret = msgctl_syscall (msqid, cmd, buf); -#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T if (ret >= 0) { switch (cmd) @@ -69,10 +68,16 @@ __new_msgctl (int msqid, int cmd, struct msqid_ds *buf) case IPC_STAT: case MSG_STAT: case MSG_STAT_ANY: +#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T buf->msg_perm.mode >>= 16; +#else + /* Old Linux kernel versions might not clear the mode padding. */ + if (sizeof ((struct msqid_ds){0}.msg_perm.mode) + != sizeof (__kernel_mode_t)) + buf->msg_perm.mode &= 0xFFFF; +#endif } } -#endif return ret; } |