mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
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.
This commit is contained in:
@ -92,7 +92,6 @@ __new_semctl (int semid, int semnum, int cmd, ...)
|
||||
|
||||
int ret = semctl_syscall (semid, semnum, cmd, arg);
|
||||
|
||||
#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
|
||||
if (ret >= 0)
|
||||
{
|
||||
switch (cmd)
|
||||
@ -100,10 +99,16 @@ __new_semctl (int semid, int semnum, int cmd, ...)
|
||||
case IPC_STAT:
|
||||
case SEM_STAT:
|
||||
case SEM_STAT_ANY:
|
||||
#ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
|
||||
arg.buf->sem_perm.mode >>= 16;
|
||||
#else
|
||||
/* Old Linux kernel versions might not clear the mode padding. */
|
||||
if (sizeof ((struct semid_ds){0}.sem_perm.mode)
|
||||
!= sizeof (__kernel_mode_t))
|
||||
arg.buf->sem_perm.mode &= 0xFFFF;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
Reference in New Issue
Block a user