mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
sysvipc: Fix IPC_INFO and SHM_INFO handling [BZ #26636]
Both commands are Linux extensions where the third argument is either a 'struct shminfo' (IPC_INFO) or a 'struct shm_info' (SHM_INFO) instead of 'struct shmid_ds'. And their information does not contain any time related fields, so there is no need to extra conversion for __IPC_TIME64. The regression testcase checks for Linux specifix SysV ipc message control extension. For SHM_INFO it tries to match the values against the tunable /proc values and for MSG_STAT/MSG_STAT_ANY it check if the create\ shared memory is within the global list returned by the kernel. Checked on x86_64-linux-gnu and on i686-linux-gnu (Linux v5.4 and on Linux v4.15).
This commit is contained in:
@ -90,8 +90,15 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
|
||||
struct kernel_shmid64_ds kshmid, *arg = NULL;
|
||||
if (buf != NULL)
|
||||
{
|
||||
shmid64_to_kshmid64 (buf, &kshmid);
|
||||
arg = &kshmid;
|
||||
/* This is a Linux extension where kernel expects either a
|
||||
'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
|
||||
if (cmd == IPC_INFO || cmd == SHM_INFO)
|
||||
arg = (struct kernel_shmid64_ds *) buf;
|
||||
else
|
||||
{
|
||||
shmid64_to_kshmid64 (buf, &kshmid);
|
||||
arg = &kshmid;
|
||||
}
|
||||
}
|
||||
# ifdef __ASSUME_SYSVIPC_BROKEN_MODE_T
|
||||
if (cmd == IPC_SET)
|
||||
@ -107,7 +114,6 @@ __shmctl64 (int shmid, int cmd, struct __shmid64_ds *buf)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case IPC_INFO:
|
||||
case IPC_STAT:
|
||||
case SHM_STAT:
|
||||
case SHM_STAT_ANY:
|
||||
@ -168,8 +174,15 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
|
||||
struct __shmid64_ds shmid64, *buf64 = NULL;
|
||||
if (buf != NULL)
|
||||
{
|
||||
shmid_to_shmid64 (&shmid64, buf);
|
||||
buf64 = &shmid64;
|
||||
/* This is a Linux extension where kernel expects either a
|
||||
'struct shminfo' (IPC_INFO) or 'struct shm_info' (SHM_INFO). */
|
||||
if (cmd == IPC_INFO || cmd == SHM_INFO)
|
||||
buf64 = (struct __shmid64_ds *) buf;
|
||||
else
|
||||
{
|
||||
shmid_to_shmid64 (&shmid64, buf);
|
||||
buf64 = &shmid64;
|
||||
}
|
||||
}
|
||||
|
||||
int ret = __shmctl64 (shmid, cmd, buf64);
|
||||
@ -178,7 +191,6 @@ __shmctl (int shmid, int cmd, struct shmid_ds *buf)
|
||||
|
||||
switch (cmd)
|
||||
{
|
||||
case IPC_INFO:
|
||||
case IPC_STAT:
|
||||
case SHM_STAT:
|
||||
case SHM_STAT_ANY:
|
||||
|
Reference in New Issue
Block a user