Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Segfault in iperf_err(exit) #1807

Merged
merged 2 commits into from
Feb 10, 2025
Merged

Fix Segfault in iperf_err(exit) #1807

merged 2 commits into from
Feb 10, 2025

Conversation

martin-ottens
Copy link
Contributor

  • Version of iperf3 (or development branch, such as master or
    3.1-STABLE) to which this pull request applies: all

  • Issues fixed (if any): -

  • Brief description of code changes (suitable for use as a commit message): Fix Segfault in iperf_err(exit)

In some places iperf_err and iperf_errexit are called with NULL for the parameter struct iperf_test *test. In this case the pthread_mutex_lock call will Segfault. Fixed by adding a NULL-check.

Reproduce this Segfault Example of a usage of `iperf_errexit` with `NULL` (here)[https://github.com/esnet/iperf/blob/master/src/iperf_util.c#L68]. (Reproduce with a full `/tmp` filesystem, `readentropy` will fail)

Valgrind output:

==2274== Process terminating with default action of signal 11 (SIGSEGV): dumping core
==2274==  Access not within mapped region at address 0x10
==2274==    at 0x49559E4: pthread_mutex_lock@@GLIBC_2.2.5 (pthread_mutex_lock.c:80)
==2274==    by 0x48A94B8: iperf_errexit (iperf_error.c:114)
==2274==    by 0x48A95BF: readentropy (iperf_util.c:74)
==2274==    by 0x48A279D: iperf_new_stream (iperf_api.c:4487)
==2274==    by 0x48AC633: iperf_run_server (iperf_server_api.c:786)
==2274==    by 0x1092FD: run (main.c:169)
==2274==    by 0x109068: main (main.c:124)

@swlars
Copy link
Contributor

swlars commented Jan 13, 2025

Thanks for the pull request! I think we have a fix partially incorporated, but this pull request covers a few that we missed. We'll test this soon.

Copy link
Contributor

@swlars swlars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@swlars
Copy link
Contributor

swlars commented Feb 10, 2025

Thank you for the pull request!

@swlars swlars merged commit 296222d into esnet:master Feb 10, 2025
3 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