mirror of
https://github.com/openwall/john.git
synced 2026-12-03 18:45:21 +07:00
[GH-ISSUE #1230] Loader memory leak #774
Labels
No labels
bug
core branch
documentation
enhancement
enhancement
fixed - pending verify
fuzz bug
good first issue
invalid
invalid
maintenance/cleanup
new cracking mode
new format
new tool
non-trivial
notes/external issues
portability
question
RFC / discussion
testing
WONTFIX
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openwall/john#774
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @loverszhaokai on GitHub (Apr 27, 2015).
Original GitHub issue: https://github.com/openwall/john/issues/1230
Originally assigned to: @loverszhaokai on GitHub.
Maybe this is not a bug. If it does not a bug, do you have any idea to avoid this bug?
#1. Prepare
1.1 content of 7z_fmt
$7z$0$19$0$1122$8$d1f50227759415890000000000000000$1412385885$112$112$5e5b8b734adf52a64c541a5a5369023d7cccb78bd910c0092535dfb013a5df84ac692c5311d2e7bbdc580f5b867f7b5dd43830f7b4f37e41c7277e228fb92a6dd854a31646ad117654182253706dae0c069d3f4ce46121d52b6f20741a0bb39fc61113ce14d22f9184adafd6b5333133
1.2 compile with asan
$ export ASAN_OPTIONS='abort_on_error=1'
$ CC=clang AFL_USE_ASAN=1 AFL_HARDEN=1 ./configure --enable-asan && make -sj8
#2. Reproduce
$ echo garbage > test.pw
$ ./john 7z_fmt --loopback=test.pw --max-run-time=1
Warning: detected hash type "7z", but the string is also recognized as "7z-opencl"
Use the "--format=7z-opencl" option to force loading these as that type instead
Loaded 1 password hash (7z, 7-Zip [SHA256 AES 32/64])
Note: This format may emit false positives, so it will keep trying even after
finding a possible candidate.
Press 'q' or Ctrl-C to abort, almost any other key for status
0g 0:00:00:00 0g/s 8.433p/s 8.433c/s 8.433C/s GARbage
Session stopped (max run-time reached)
==8582==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 524288 byte(s) in 1 object(s) allocated from:
#0 0x4b5530 in __interceptor_malloc /home/kai/workspace/llvm-3.6.0.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:40
#1 0x8fa6e8 in mem_alloc_func /home/kai/workspace/john_jumbo/JohnTheRipper_fuzz_options/src/memory.c:89:8
#2 0x8d0f4f in ldr_init_database /home/kai/workspace/john_jumbo/JohnTheRipper_fuzz_options/src/loader.c:161:22
#3 0x8cb90e in john_load /home/kai/workspace/john_jumbo/JohnTheRipper_fuzz_options/src/john.c:1074:3
#4 0x8c1e9c in john_init /home/kai/workspace/john_jumbo/JohnTheRipper_fuzz_options/src/john.c:1249:2
#5 0x8c0d17 in main /home/kai/workspace/john_jumbo/JohnTheRipper_fuzz_options/src/john.c:1682:2
#6 0x7fd2b7d22d1c in __libc_start_main (/lib64/libc.so.6+0x1ed1c)
SUMMARY: AddressSanitizer: 524288 byte(s) leaked in 1 allocation(s).
@frank-dittrich commented on GitHub (Apr 27, 2015):
Looks like for some reason the
MEM_FREE(database.cracked_hash);in john.c, line 1512 is not processed when the --max-tun-time limit is reached.Did you disable john_done() for your fuzzing?
@loverszhaokai commented on GitHub (Apr 27, 2015):
@frank-dittrich
$ ./john 7z_fmt --loopback=test.pw
This command can also reproduce this bug, but you should press 'q' or Ctrl-C to abort.
No
@frank-dittrich commented on GitHub (Apr 27, 2015):
Yes, I can see the memory leek with memdbg as well:
I used
x:garbageinstad ofgarbage, because --loopback is supposed to process a .pot file and split the lines into hashes and passwords, just using the passwords.But that apparently didn't help either.
@frank-dittrich commented on GitHub (Apr 27, 2015):
With other salted formats, the error can be reproduced, with saltless formars, it can't.
@frank-dittrich commented on GitHub (Apr 27, 2015):
BTW, with --enable-memdbg, I see the leaks even if I don't press
<ctrl>-cto abort, see theSession completedoutput.@magnumripper commented on GitHub (Apr 28, 2015):
I think Solar doesn't consider it a memory leak since it's only allocated once. He said on john-dev at some time (long ago, and regarding some other but similar case) that it's freed by the OS at program exit, so why bother?
But we have fixed some other similar cases in Jumbo, simply to make it easier finding real leaks (that actually grow).
In this case, I think we'd need to introduce a
ldr_done()to address it.@loverszhaokai commented on GitHub (May 3, 2015):
@frank-dittrich @magnumripper
There is really a memory leak, with the command
./john 7z_fmt --loopback=test.pw --max-run-time=1, theldr_init_database()function is called twice. And we only free the database but not the loop_db.