Trac issueshttps://gitlab.torproject.org/legacy/trac/-/issues2020-06-13T13:58:26Zhttps://gitlab.torproject.org/legacy/trac/-/issues/455tor segfaults on 64k-aligned cached-routers file2020-06-13T13:58:26ZTractor segfaults on 64k-aligned cached-routers fileThis bug is for svn and the 0.1.2.x tree, which are both affected.
When Tor gets to the end of an 4k-aligned file (page size?), it segfaults in eat_whitespace()
The problem is imminent at routerparse.c:899 when both end and eos are out...This bug is for svn and the 0.1.2.x tree, which are both affected.
When Tor gets to the end of an 4k-aligned file (page size?), it segfaults in eat_whitespace()
The problem is imminent at routerparse.c:899 when both end and eos are out of bounds. (eos is (always?) out of bounds when the mmap is page-aligned.)
Execution then enters router_parse_entry_from_string(), which calls tokenize_string(s, end...) with end out of bounds. That calls eat_whitespace, which is not safe for non-null-terminated strings (as it has no end pointer or length specifier).
Steps to reproduce:
1. minimal torrc with RunAsDaemon 0, DataDirectory /some/path/ which points to...
2. A valid 4096-byte (I've only tested with 2!^x * 4096-byte files) cached-routers file (below, or take an existing cached-routers file and chop it, then duplicate/remove/modify exit policy entries until you get to an appropriate size)
I've collected sample cached-routers files of the obvious sizes that seems to trigger the bug on both my x86 and x86-64 machines.
http://70.242.110.86/svn/cr/
The crashes I get are in eat_whitespace(), but the original reporter on IRC was seeing segfaults in 0.1.2.14, routerparse.c:679 -- on PPC.
A representative backtrace from his PPC is at http://www.pastebin.ca/608408
One with a segfault in eat_whitespace (on x86-64) is at http://www.pastebin.ca/608454
[Automatically added by flyspray2trac: Operating System: All]
**Trac**:
**Username**: croup