Artifacts Associated With Ticket 3127687fffffffff
Ticket change [66ab1f4d81] (rid 102754) by lool on 2010-12-04 23:54:57:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Hi there This affects tcl8.4 only, not tcl8.5. After a rebuild of tcl8.4 in Ubuntu, gitk and other applications were failing to start (even wish8.4 wouldn't start); these would fail with: *** buffer overflow detected ***: wish terminated followed by a backtrace. This is due to the _FORTIFY_SOURCE security feature, see: https://wiki.ubuntu.com/CompilerFlags#-D_FORTIFY_SOURCE=2 https://wiki.ubuntu.com/Security/Features#Built%20with%20Fortify%20Source The original bug has details on why this occurs and is at: https://bugs.launchpad.net/ubuntu/+source/tcl8.4/+bug/683546 As a workaround, I've changed the package to build generic/tclCmdMZ.c with -U_FORTIFY_SOURCE, but ideally the structure would declare the command[] with some define for the maximum length of variable names or commands. Cheers,
- foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "lool"
- subsystem initialized to: "18. Commands M-Z"
- title initialized to: "Triggers FORTIFY_SOURCE buffer overflow detection"
- type initialized to: "Bug"
Add attachment "fortify-source.diff" [e2bbcd1999] (rid 87681) by lool on 2010-12-05 06:54:57.
Ticket change [99207b4ff0] (rid 110732) by lool on 2010-12-05 06:54:57:
- icomment:
File Added - 395235: fortify-source.diff
- login: "lool"
- mimetype: "text/plain"
- username: "lool"
- icomment:
Ticket change [c6a29bd496] (rid 121803) by nijtmans on 2010-12-05 15:34:51:
- icomment:
>ideally the structure would declare the command[] with some define for the maximum length of variable names or commands. Tcl does not have a maximum length of variable names or commands, other than the amount of availalble memory... For Tcl 8.6, a solution would be to define buffer having size [0], that's the standard way of doing this. But I don't know if all the supported compilers handle that. So for Tcl 8.4/8.5 maybe the best is compile everything with -U_FORTIFY_SOURCE (Tcl8.5 this code moved to tclTrace.c). just my 2c
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [90169d4ee9] (rid 120385) by lool on 2010-12-05 18:41:09:
- icomment:
Oddly, I don't hit the problem with wish8.5. Maybe a different code path? I had tried changing command[4] to command[0], but that didn't work (it would still hit FORTIFY_SOURCE protection with a max size of zero). However Kees Cook wrote to me that command[1] is how this should be defined. 8.5 > As long as you don't hit FORTIFY_SOURCE protection, I guess it's best to keep it enabled, but if you do hit it then it would be nice to only disable it in the places where it's a false positive (rather than globally). Another way to avoid the issue entirely is to have a char *command and runtime allocate it, but that might have a performance hit.
- login: "lool"
- mimetype: "text/plain"
- username: "lool"
- icomment:
Ticket change [e6c49c501c] (rid 104347) by nijtmans on 2010-12-06 05:14:59:
- icomment:
changing command[4] to command[1] has the problem that the structure will be over-allocated (sizeof might add passing characters.....) better: replace the strcpy with memcpy, as we already know the length anyway. This is faster and should not trigger the FORTIFY_SOURCE. patch attached. Does this help?
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Ticket change [12a0e1b58a] (rid 124070) by nijtmans on 2010-12-06 05:15:35:
- assignee changed to: "nijtmans"
Ticket change [419b341066] (rid 116222) by nijtmans on 2010-12-06 05:16:09:
- icomment:
File Added - 395305: 3127687.patch
- login: "nijtmans"
- mimetype: "text/plain"
- username: "nijtmans"
- icomment:
Add attachment "3127687.patch" [d4948c88da] (rid 123472) by nijtmans on 2010-12-06 05:16:09.
Ticket change [5872f66e2b] (rid 117804) by dkf on 2010-12-06 05:27:34:
- icomment:
FWIW, I've been converting Tcl to use memcpy instead of strcpy whenever we know the length anyway (on the grounds that it might also be faster) but I don't think I've done any of that back in 8.4 (and I can't remember for 8.5...)
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
- icomment:
Ticket change [e37be9060b] (rid 87809) by nijtmans on 2010-12-06 05:28:11:
- closedate changed to: "2010-12-05T22:28:11"
- closer changed to: "nijtmans"
- icomment:
allow_comments - 1 This is a dup of #3048354, which was never backported to 8.4. Fix is the same. Fixed on 8.4 branch.
- login: "nijtmans"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
- username: "nijtmans"