Skip to content

Comments

Fix a crash on >=1024 watched files#230

Merged
ericcurtin merged 1 commit intoinotify-tools:masterfrom
jankratochvil:crash1024
Feb 16, 2025
Merged

Fix a crash on >=1024 watched files#230
ericcurtin merged 1 commit intoinotify-tools:masterfrom
jankratochvil:crash1024

Conversation

@jankratochvil
Copy link
Contributor

https://bugzilla.redhat.com/show_bug.cgi?id=2345921
Bugreported by Don Marti.

$ find . -xdev -type f -print0 | xargs -0 ./src/inotifywait
Setting up watches.
Couldn't watch ���*: No such file or directory
double free or corruption (out)
xargs: ./src/inotifywait: terminated by signal 6
$ make CFLAGS="-fsanitize=address -g" CXXFLAGS="-fsanitize=address -g" LDFLAGS=-fsanitize=address
$ find . -xdev -type f -print0 | xargs -0 /tmp/inotify-tools/src/inotifywait
=================================================================
==3349755==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x525000002100 at pc 0x000000406db9 bp 0x7fffff8e2570 sp 0x7fffff8e2568
WRITE of size 8 at 0x525000002100 thread T0
    #0 0x406db8 in construct_path_list(int, char**, char const*, FileList*) /tmp/inotify-tools/src/common.cpp:155
    #1 0x402e1b in main /tmp/inotify-tools/src/inotifywait.cpp:246
    #2 0x7feb9e210247 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #3 0x7feb9e21030a in __libc_start_main_impl ../csu/libc-start.c:360
    #4 0x4014d4 in _start (/tmp/inotify-tools/src/.libs/inotifywait+0x4014d4) (BuildId: da34ddfd0d04acad36a0af07acae3144311e1b7d)

0x525000002100 is located 0 bytes after 8192-byte region [0x525000000100,0x525000002100)
allocated by thread T0 here:
    #0 0x7feb9e8c2897 in malloc (/lib64/libasan.so.8+0xc2897) (BuildId: 0505b45e5a5d9a6c8ecb1d529aaaf13cd21fbe4e)
    #1 0x40678f in construct_path_list(int, char**, char const*, FileList*) /tmp/inotify-tools/src/common.cpp:118
    #2 0x402e1b in main /tmp/inotify-tools/src/inotifywait.cpp:246
    #3 0x7feb9e210247 in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58
    #4 0x7feb9e21030a in __libc_start_main_impl ../csu/libc-start.c:360
    #5 0x4014d4 in _start (/tmp/inotify-tools/src/.libs/inotifywait+0x4014d4) (BuildId: da34ddfd0d04acad36a0af07acae3144311e1b7d)

The patch is very ugly but I did not want to spend time to rewrite it all into real C++ smart memory allocators.

@ericcurtin ericcurtin merged commit 81c6c98 into inotify-tools:master Feb 16, 2025
4 of 6 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