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
..
arpa Add _FORTIFY_SOURCE support for inet_pton 2025-03-24 14:43:03 -04:00
bits Add _FORTIFY_SOURCE support for inet_ntop 2025-03-21 09:35:42 +01:00
gnu Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
net
netinet
programs Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
protocols
rpc Optimize __libc_tsd_* thread variable access 2025-05-16 19:53:09 +02:00
rpcsvc
sys Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
aio.h
aliases.h
alloc_buffer.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
alloca.h elf: early conversion of elf p_flags to mprotect flags 2025-08-27 10:45:45 -03:00
allocate_once.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
ar.h
argp-fmtstream.h
argp.h
argz.h
array_length.h include/array_length.h: add array_foreach[_const] macros 2025-06-17 09:57:40 -03:00
assert.h
atomic.h atomics: Remove unused atomics 2025-09-10 09:18:06 +00:00
atomic_wide_counter.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
byteswap.h
clone_internal.h
complex.h
cpio.h
ctype.h Use proper extern declaration for _nl_C_LC_CTYPE_{class,toupper,tolower} 2025-05-16 19:53:09 +02:00
des.h
dirent.h
dlfcn.h elf: Do not add a copy of _dl_find_object to libc.so 2025-02-01 12:37:58 +01:00
dso_handle.h
elf.h elf: Add DL_ADDRESS_WITHOUT_RELOC [BZ #33088] 2025-07-01 03:44:52 +08:00
endian.h
envz.h
err.h
errno.h
error.h
execinfo.h
fcntl.h
features-time64.h
features.h Bump version number to 2.42 2025-07-28 20:19:17 +02:00
fenv.h math: Add fetestexcept internal alias 2025-09-11 14:46:07 -03:00
file_change_detection.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
filename.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
float.h
fmtmsg.h
fnmatch.h
fpu_control.h
fstab.h
fts.h
ftw.h
gconv.h
getopt.h
getopt_int.h
glob.h
gmp.h
gnu-versions.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
grp-merge.h
grp.h
gshadow.h
iconv.h
idx.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
ifaddrs.h
ifreq.h
ifunc-impl-list.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
inline-hashtab.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
intprops.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
inttypes.h
langinfo.h
lastlog.h
libc-diag.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
libc-internal.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
libc-misc.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
libc-pointer-arith.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
libc-symbols.h Fix comment typo in libc-symbols.h 2025-05-27 11:34:14 +01:00
libgen.h
libintl.h
limits.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
link.h elf: Restore support for _r_debug interpositions and copy relocations 2025-07-05 20:15:12 +02:00
list.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
list_t.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
locale.h
loop_unroll.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
malloc.h
math-narrow-eval.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
math.h
mcheck.h
memory.h
mntent.h
monetary.h
mqueue.h
netdb.h
netgroup.h
nl_types.h
nss.h
nss_dns.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
nss_files.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
nsswitch.h
obstack.h
plural-exp.h
poll.h
printf.h
printf_buffer.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
pthread.h
pty.h
pwd.h
random-bits.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
re_comp.h
regex.h
regexp.h
register-atfork.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
resolv.h
rounding-mode.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
rtld-malloc.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
sched.h
scratch_buffer.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
search.h
set-freeres.h elf: Merge __dl_libc_freemem into __rtld_libc_freeres 2025-02-02 20:10:09 +01:00
setjmp.h support: add check_mem_access function 2025-09-15 09:47:41 +01:00
sgtty.h
shadow.h
shlib-compat.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
shm-directory.h shm-directory: Truncated struct member name length 2025-10-01 14:49:10 -03:00
signal.h
spawn.h
stab.h
stackinfo.h elf: early conversion of elf p_flags to mprotect flags 2025-08-27 10:45:45 -03:00
stap-probe.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
stdbit.h
stdc-predef.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
stdint.h Undef __INT64_C/__UINT64_C for glibc build and test 2025-08-22 18:18:38 -07:00
stdio.h assert: Refactor assert/assert_perror 2025-09-23 10:29:24 -03:00
stdio_ext.h
stdlib.h debug: Improve '%n' fortify detection (BZ 30932) 2025-03-21 15:46:48 -03:00
string.h Implement C23 memset_explicit (bug 32378) 2025-10-01 15:14:09 +00:00
strings.h
struct___timeb64.h
struct___timespec64.h
struct___timeval64.h
stubs-prologue.h
syscall.h
sysexits.h
syslog.h
tar.h
termios.h termios: add new baud_t interface, defined to be explicitly numeric 2025-06-17 09:11:38 -03:00
tgmath.h Don't use glibc <tgmath.h> when testing with Clang 2024-12-21 05:24:07 +08:00
time.h
ttyent.h
uchar.h
ucontext.h
ulimit.h
unistd.h io: replace local_isatty() with a proper function __isatty_nostatus() 2025-06-17 09:11:38 -03:00
unistd_ext.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
utime.h
utmp.h
values.h Update copyright dates with scripts/update-copyrights 2025-01-01 11:22:09 -08:00
verify.h
wait.h
wchar.h
wctype.h
wordexp.h