Skip to content

Conversation

@nmorey
Copy link
Contributor

@nmorey nmorey commented Oct 23, 2025

Even though there can not be a buffer overflow as the string is properly sized, noncontig_coll2 fails when built with -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 : ----
FAIL: noncontig_coll2

Thread 1 "noncontig_coll2" received signal SIGABRT, Aborted. 0x00007ffff709c5fc in __pthread_kill_implementation () from /lib64/libc.so.6 (gdb) bt
#0 0x00007ffff709c5fc in __pthread_kill_implementation ()
from /lib64/libc.so.6
#1 0x00007ffff7042106 in raise () from /lib64/libc.so.6
#2 0x00007ffff702938b in abort () from /lib64/libc.so.6
#3 0x00007ffff702a3ab in __libc_message_impl.cold () from /lib64/libc.so.6
#4 0x00007ffff712b4fb in __fortify_fail () from /lib64/libc.so.6
#5 0x00007ffff712adc6 in __chk_fail () from /lib64/libc.so.6
#6 0x00007ffff712c8f5 in __snprintf_chk () from /lib64/libc.so.6
#7 0x000000000040275e in snprintf (__s=0x4aafee "", __n=,
__fmt=0x404077 "%s,") at /usr/include/bits/stdio2.h:68
#8 default_str (mynod=, len=61, array=0x59fca0,
dest=0x4aafd0 "hostname,")
at src/mpi/romio/test/noncontig_coll2.c:189
#9 main (argc=, argv=)
at src/mpi/romio/test/noncontig_coll2.c:330

This is due to the len parameter of snprintf not being updated as we advance in the string.
Fix this issue by introducing a remaining len var that contains the exact amount of bytes left.

Patch is already applied in main. Backporting to 4.3.x as discussed in #7596

Even though there can not be a buffer overflow as the string is properly
sized, noncontig_coll2 fails when built with -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 :
----
FAIL: noncontig_coll2
=====================
Thread 1 "noncontig_coll2" received signal SIGABRT, Aborted.
0x00007ffff709c5fc in __pthread_kill_implementation () from /lib64/libc.so.6
(gdb) bt
 #0  0x00007ffff709c5fc in __pthread_kill_implementation ()
    from /lib64/libc.so.6
 pmodels#1  0x00007ffff7042106 in raise () from /lib64/libc.so.6
 pmodels#2  0x00007ffff702938b in abort () from /lib64/libc.so.6
 pmodels#3  0x00007ffff702a3ab in __libc_message_impl.cold () from /lib64/libc.so.6
 pmodels#4  0x00007ffff712b4fb in __fortify_fail () from /lib64/libc.so.6
 pmodels#5  0x00007ffff712adc6 in __chk_fail () from /lib64/libc.so.6
 pmodels#6  0x00007ffff712c8f5 in __snprintf_chk () from /lib64/libc.so.6
 pmodels#7  0x000000000040275e in snprintf (__s=0x4aafee "", __n=<optimized out>,
     __fmt=0x404077 "%s,") at /usr/include/bits/stdio2.h:68
 pmodels#8  default_str (mynod=<optimized out>, len=61, array=0x59fca0,
     dest=0x4aafd0 "hostname,")
     at src/mpi/romio/test/noncontig_coll2.c:189
 pmodels#9  main (argc=<optimized out>, argv=<optimized out>)
     at src/mpi/romio/test/noncontig_coll2.c:330
----
This is due to the len parameter of snprintf not being updated as we
advance in the string.
Fix this issue by introducing a remaining len var that contains the exact amount
of bytes left.

Signed-off-by: Nicolas Morey <[email protected]>
@raffenet raffenet changed the title romio: test: fix bad snprintf arguments [4.3.x] romio: test: fix bad snprintf arguments Oct 27, 2025
@raffenet raffenet merged commit 3352c9f into pmodels:4.3.x Oct 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants