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

Crashfix: CFLAGS -fsanitize=address could lead to crash if pbkdf2 mod loaded #1505

Merged
merged 4 commits into from
Feb 18, 2024

Conversation

michaelortmann
Copy link
Member

@michaelortmann michaelortmann commented Nov 28, 2023

Found by: michaelortmann
Patch by: michaelortmann
Fixes:

One-line summary:
Compiling eggdrop with CFLAGS -fsanitize=address on systems that require linker flag -lresolv for b64_ntop() or b64_pton() could lead to crash if pbkdf2 mod loaded

Additional description (if needed):
gccs sanitizer will intercept calls to b64_ntop or b64_pton()
https://github.com/gcc-mirror/gcc/blob/releases/gcc-13/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc#L2512
which leads to eggdrops configure script misdetecting that eggdrop can be linked without -lresolv to call those functions.
Please run misc/runautotools after merging or for testing this PR

Test cases demonstrating functionality (if applicable):
Before:

$ CFLAGS="-fsanitize=address" ./configure
[...]
checking for b64_ntop... yes
[...]
.chpass testuser 123456
[03:15:50.%f] tcl: builtin dcc call: *dcc:chpass -HQ 1 [something]
[03:15:50.%f] * Last context: tclhash.c/726 [Tcl proc: *dcc:chpass, param:  $_dcc1 $_dcc2 $_dcc3]
[03:15:50.%f] * Please REPORT this BUG!
[03:15:50.%f] * Check doc/BUG-REPORT on how to do so.
[03:15:49.%f] * Wrote DEBUG
[03:15:49.%f] * SEGMENT VIOLATION -- CRASHING!
Segmentation fault (core dumped)
$ coredumpctl debug
[...]
#0  0x0000000000000000 in ?? ()
(gdb) bt full
#0  0x0000000000000000 in ?? ()
No symbol table info available.
#1  0x00007fe8abe81a91 in __interceptor___b64_ntop (src=0x7fe8a9003ce0 "m+r\032\036\303b\v*Y\373n\026\213\236O", 
    srclength=16, target=0x7fe8aa65573b <out+27> "", targsize=76)
    at /usr/src/debug/gcc/gcc/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:2512
        ctx = <optimized out>
        _ctx = <optimized out>
        res = <optimized out>
        v1 = <optimized out>
        v2 = <optimized out>
[...]

After:

$ CFLAGS="-fsanitize=address" ./configure
[...]
checking for b64_ntop... yes
[...]
checking for b64_ntop... no
checking for b64_ntop with -lresolv... yes
[...]
.chpass testuser 123456
[03:21:55.%f] tcl: builtin dcc call: *dcc:chpass -HQ 1 [something]
[03:21:55.%f] pbkdf2 method SHA256 rounds 1000, user 0.186ms sys 1.114ms
[03:21:55.%f] #-HQ# chpass testuser [something]
Changed password.

@thommey
Copy link
Member

thommey commented Dec 2, 2023

I'd rather see AC_RUN_IFELSE compile and run a test program that calls those functions to verify they're really available. Other flags could do the same and that'd be future-proof. We do this for ipv6 support, too.

@michaelortmann
Copy link
Member Author

michaelortmann commented Dec 3, 2023

Ty, this idea makes the patch even better. Ready for review again.

@vanosg vanosg added this to the v1.10.0 milestone Feb 18, 2024
@vanosg vanosg merged commit 36be9cd into eggheads:develop Feb 18, 2024
2 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.

3 participants