Repository navigation
iostat: Fix stack-use-after-return with options -N and -j - #463
Merged
sysstat merged 1 commit intoNov 14, 2026
Merged
Conversation
get_dm_name_from_registered_name() (option -N) and get_pretty_name_from_persistent() (option -j) read a symlink into a local array and return basename() of it, which is a pointer into that array. add_list_device() then reads the device name from the stack frame of a function that has already returned. The simulation tests pass with a normal build, but with -fsanitize=address tests 02644, 02650, 02660 and 02665 abort with "stack-use-after-return". Make both arrays static, as get_devname_from_sysfs() already does for the same readlink()/basename() sequence. add_list_device() copies the name into the device list before either function is called again. Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_dm_name_from_registered_name()(option-N) andget_pretty_name_from_persistent()(option-j) returnbasename()of a local array. Soadd_list_device()reads the device name from the stack frame of a function that has already returned.A normal build still passes the simulation tests, but an ASan build fails tests 02644, 02650, 02660 and 02665 on master (663071d):
Test 02644 (
iostat -dN virtualhd sdr):The three
-jtests report the same error fortargetinget_pretty_name_from_persistent().This change makes both arrays
static, asget_devname_from_sysfs()already does for the samereadlink()/basename()sequence.add_list_device()copies the name before either function is called again.Tested on Debian 13 with gcc 14.2.0. With ASan, the four tests now pass, and test 01705 fails before and after because it uses
LD_PRELOAD, which is unrelated. A normal build passes all 531 tests andmake extratestbefore and after the change. Not tested with real device mapper or persistent names, only with thetests/root1tree.🤖 This change was written with Droid.