1
0
mirror of https://sourceware.org/git/glibc.git synced 2026-10-24 01:33:52 +03:00
Files
glibc/include
Prasanna Paithankar 4ae9b66048 shm-directory: Truncated struct member name length
The struct shmdir_name in include/shm-directory.h has name field to
contains the full path of the POSIX IPC object (shm and sem).
The size was previously set to sizeof (SHMDIR) + 4 + NAME_MAX, where 4
bytes were reserved for the optional "sem." prefix.

This led to incorrect execution of the __shm_get_name function
in posix/shm-directory.c which is used accross in shm_[open/unlink] and
sem_[open/unlink] functions.

For shm_[open/unlink]:
This is because the name field was large enough to hold 268 characters
(255 + 4 + 9) instead of the maximum allowed 263 characters (255 + 9).
This caused the __shm_get_name to not throw ENAMETOOLONG error when the
name length exceeded NAME_MAX (255) upto 259 characters.

For sem_[open/unlink]:
Similarly, the __shm_get_name incorrectly returned success for names of
length 255 instead of 251 (255 - 4).

This was overlooked as finally these functions throw the correct
ENAMETOOLONG error; which was thrown by the openat syscall, which is
called later in the shm_* and sem_* functions.

This patch corrects the size of name field in struct shmdir_name to
sizeof (SHMDIR) + NAME_MAX. The __shm_get_name function return
ENAMETOOLONG if alloc_buffer_has_failed returns true (which only happens
when copy length > alloc_buffer_size (buffer)).

Relevant runtime monitoring were done in gdb to confirm the same.

Signed-off-by: Prasanna Paithankar <paithankarprasanna@gmail.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2025-10-01 14:49:10 -03:00
..
…
2025-09-10 09:18:06 +00:00
…
…
2021-06-22 12:09:52 -03:00
…
2023-05-01 19:33:21 +02:00
2025-07-28 20:19:17 +02:00
2025-09-11 14:46:07 -03:00
…
…
2021-06-15 10:42:11 -03:00
2021-06-15 10:42:11 -03:00
…
2017-04-07 07:45:53 -04:00
…
…
…
2021-07-22 18:38:04 +05:30
…
…
2021-06-30 08:43:37 +02:00
2023-10-24 12:30:59 +02:00
2023-05-01 09:08:59 -04:00
2019-05-02 11:42:51 +02:00
…
2023-10-24 12:30:59 +02:00
2019-10-09 17:48:41 -03:00
…
2024-01-03 12:07:14 +00:00
2025-09-23 10:29:24 -03:00
…
…
…
…
…
…
…
2021-06-30 08:43:37 +02:00
2019-11-06 09:20:52 -03:00
2024-02-01 11:02:01 +00:00
…