|
2016-07-02
| ||
| 16:51 | • Ticket [d59715d0cf] Use-after-free in Tcl_DStringAppend status still Closed ... artifact: c5109fa203 user: acpime | |
|
2016-06-22
| ||
| 15:49 | • Ticket [d59715d0cf]: 4 changes artifact: ad78a7ac84 user: dgp | |
|
2016-06-21
| ||
| 11:39 | • Closed ticket [d59715d0cf]. artifact: 846baa1246 user: dgp | |
| 00:53 | • Ticket [d59715d0cf]: 4 changes artifact: ad38752eb8 user: dah | |
|
2016-06-20
| ||
| 18:36 | • Pending ticket [d59715d0cf]. artifact: 4b5497e36f user: dgp | |
|
2016-06-19
| ||
| 08:21 | • New ticket [d59715d0cf]. artifact: 4e746a2f01 user: acpime | |
Use-after-free in Tcl_DStringAppend
Closed / Invalidd59715d0cffb0b86427b164188c95f2a06d88c17Created 10 years agoUpdated 10 years ago
Descriptionplain2016-06-19 08:21:26
I get the following report when running the script (which are generally used third party TCL library) on python with ASAN enabled.
python bug:
http://bugs.python.org/issue27254
Asan report.
=================================================================
==20559==ERROR: AddressSanitizer: heap-use-after-free on address 0x7fa46bec8810 at pc 0x4665ea bp 0x7ffd34fb4060 sp 0x7ffd34fb3820
READ of size 1048575 at 0x7fa46bec8810 thread T0
==20559==WARNING: Trying to symbolize code, but external symbolizer is not initialized!
#0 0x4665e9 (/home/eminus/Downloads/Python-2.7.11/python+0x4665e9)
#1 0x7fa46f507e18 (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x116e18)
#2 0x7fa46f7eb44e (/usr/lib/x86_64-linux-gnu/libtk8.6.so+0x6244e)
#3 0x7fa46fb1ae4c (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0x19e4c)
#4 0x7fa46fb0bfc5 (/home/eminus/Downloads/Python-2.7.11/build/lib.linux-x86_64-2.7/_tkinter.so+0xafc5)
#5 0x5e1813 (/home/eminus/Downloads/Python-2.7.11/python+0x5e1813)
#6 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
#7 0x721353 (/home/eminus/Downloads/Python-2.7.11/python+0x721353)
#8 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
#9 0x4b6c62 (/home/eminus/Downloads/Python-2.7.11/python+0x4b6c62)
#10 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
#11 0x5f0823 (/home/eminus/Downloads/Python-2.7.11/python+0x5f0823)
#12 0x4b0a08 (/home/eminus/Downloads/Python-2.7.11/python+0x4b0a08)
#13 0x4acb2a (/home/eminus/Downloads/Python-2.7.11/python+0x4acb2a)
#14 0x5e2d19 (/home/eminus/Downloads/Python-2.7.11/python+0x5e2d19)
#15 0x5d319c (/home/eminus/Downloads/Python-2.7.11/python+0x5d319c)
#16 0x5d2041 (/home/eminus/Downloads/Python-2.7.11/python+0x5d2041)
#17 0x660980 (/home/eminus/Downloads/Python-2.7.11/python+0x660980)
#18 0x65fc8a (/home/eminus/Downloads/Python-2.7.11/python+0x65fc8a)
#19 0x48e46c (/home/eminus/Downloads/Python-2.7.11/python+0x48e46c)
#20 0x7fa4727edec4 (/lib/x86_64-linux-gnu/libc.so.6+0x21ec4)
#21 0x48c5bc (/home/eminus/Downloads/Python-2.7.11/python+0x48c5bc)
0x7fa46bec8810 is located 16 bytes inside of 2097166-byte region [0x7fa46bec8800,0x7fa46c0c880e)
freed by thread T0 here:
#0 0x4766d3 (/home/eminus/Downloads/Python-2.7.11/python+0x4766d3)
#1 0x7fa46f4ff52d (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e52d)
previously allocated by thread T0 here:
#0 0x4764d9 (/home/eminus/Downloads/Python-2.7.11/python+0x4764d9)
#1 0x7fa46f4ff0cc (/usr/lib/x86_64-linux-gnu/libtcl8.6.so+0x10e0cc)
SUMMARY: AddressSanitizer: heap-use-after-free ??:0 ??
Shadow bytes around the buggy address:
0x0ff50d7d10b0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff50d7d10c0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff50d7d10d0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff50d7d10e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
0x0ff50d7d10f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
=>0x0ff50d7d1100: fd fd[fd]fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0ff50d7d1110: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0ff50d7d1120: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0ff50d7d1130: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0ff50d7d1140: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0ff50d7d1150: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Heap right redzone: fb
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack partial redzone: f4
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
ASan internal: fe
==20559==ABORTING
dgpplain2016-06-20 18:36:48
This ticketing system is for Tcl. 'tkinter' is not part of Tcl; it is part of Python. If an error in Tcl is being exposed here, please include a clear demonstration of the problem in either Tcl or C code. If tkinter is simply failing to Tcl_DStringInit() where it needs to, that should be reported to the tkinter maintainers, not here. Good luck.
dahplain2016-06-21 00:53:43
Danger, Will Robinson
There's some wicked action going on in Tk.
In generic/tkwindow.c in function Initialize approx line 3193
We hit this code path:
/*
* Figure out the application's name and class.
*/
Tcl_DStringInit(&class);
if (name == NULL) {
int offset;
TkpGetAppName(interp, &class);
offset = Tcl_DStringLength(&class)+1;
Tcl_DStringSetLength(&class, offset);
Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1);
name = Tcl_DStringValue(&class) + offset;
}
What's the problem here?
If we're working with a string longer than will fit in DString's static storage then DStringAppend can ckrealloc here, but we're passing a pointer to the very memory we're reallocating!
This code doesn't make sense to me either, why is it taking a name 'foo' and appending it onto itself?
I think it can be reduced to simply this:
if (name == NULL) {
TkpGetAppName(interp, &class);
name = Tcl_DStringValue(&class);
}
I can provide a demo if necessary but I believe this evil line:
Tcl_DStringAppend(&class, Tcl_DStringValue(&class), offset-1);
speaks for itself and indeed is the culprit here.
Finally and a bit unrelated, there are limits to Window class names, On Microsoft Windows the max is 256 (OS limitation). So if you get crazy with long names, Tk will silently not display any window.
dgpplain2016-06-21 11:39:12
Holy Moly! Thanks for digging that out. Yuck! Opened in the Tk Tracker here: http://core.tcl.tk/tk/tktview/787adc5ed7
dgpplain2016-06-22 15:49:00
See also http://core.tcl.tk/tcl/tktview/16896d49fd
acpime Ticket [d59715d0cf]: 5 changes
[History diff]2016-07-02 16:51:07
Log in (anonymous is fine) to add a comment.