Skip to content

func_tests: disable FORTIFY_SOURCE for test_1_to_1_recvfrom#67

Open
kraj wants to merge 1 commit intosctp:masterfrom
kraj:kraj/unfortify-test
Open

func_tests: disable FORTIFY_SOURCE for test_1_to_1_recvfrom#67
kraj wants to merge 1 commit intosctp:masterfrom
kraj:kraj/unfortify-test

Conversation

@kraj
Copy link
Copy Markdown

@kraj kraj commented Nov 19, 2025

When built with glibc hardening (_FORTIFY_SOURCE), recvfrom() is wrapped by __recvfrom_chk(). The test_1_to_1_recvfrom test deliberately calls recvfrom() with an invalid buffer pointer ((char *)-1) to verify that EFAULT is returned.

On fortified builds, __recvfrom_chk() sees a buffer size of 0 and a non-zero length, treats this as a buffer overflow, and aborts with:

*** buffer overflow detected ***: terminated

This causes the test to fail with SIGABRT instead of exercising the kernel’s EFAULT path as intended.

Compile test_1_to_1_recvfrom without _FORTIFY_SOURCE so that the test can run to completion and correctly validate the EFAULT behavior, while keeping fortify enabled for the rest of code

When built with glibc hardening (_FORTIFY_SOURCE), recvfrom() is wrapped by
__recvfrom_chk(). The test_1_to_1_recvfrom test deliberately calls
recvfrom() with an invalid buffer pointer ((char *)-1) to verify that
EFAULT is returned.

On fortified builds, __recvfrom_chk() sees a buffer size of 0 and a
non-zero length, treats this as a buffer overflow, and aborts with:

  *** buffer overflow detected ***: terminated

This causes the test to fail with SIGABRT instead of exercising the
kernel’s EFAULT path as intended.

Compile test_1_to_1_recvfrom without _FORTIFY_SOURCE
so that the test can run to completion and correctly validate the
EFAULT behavior, while keeping fortify enabled for the rest of code

Signed-off-by: Khem Raj <raj.khem@gmail.com>
@lxin
Copy link
Copy Markdown
Contributor

lxin commented Nov 24, 2025

@kraj,

I couldn't trigger it with:

# gcc --version
gcc (GCC) 15.2.1 20251022 (Red Hat 15.2.1-3)
# cd lksctp-tools
# ./bootstrap 
# CFLAGS="-O2 -D_FORTIFY_SOURCE=2" ./configure
# make

Can you show how the error '*** buffer overflow detected ***: terminated' was triggered on your env?

Thanks.

@kraj
Copy link
Copy Markdown
Author

kraj commented Nov 24, 2025

@kraj,

I couldn't trigger it with:

# gcc --version
gcc (GCC) 15.2.1 20251022 (Red Hat 15.2.1-3)
# cd lksctp-tools
# ./bootstrap 
# CFLAGS="-O2 -D_FORTIFY_SOURCE=2" ./configure
# make

Can you show how the error '*** buffer overflow detected ***: terminated' was triggered on your env?

Thanks.

I think you need glibc to be compiled with hardening options as well like what yocto does. Configure glibc build with --enable-fortify-source might give you a reproducer.

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