Page MenuHomeFreeBSD

truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall
ClosedPublic

Authored by nikita_elyzion.net on Aug 2 2016, 8:19 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Jan 17, 2:18 PM
Unknown Object (File)
Nov 28 2024, 3:29 AM
Unknown Object (File)
Oct 24 2024, 9:47 PM
Unknown Object (File)
Oct 18 2024, 6:48 AM
Unknown Object (File)
Oct 3 2024, 10:08 PM
Unknown Object (File)
Oct 2 2024, 6:14 AM
Unknown Object (File)
Oct 1 2024, 1:44 PM
Unknown Object (File)
Sep 30 2024, 5:30 AM

Details

Summary

trussinfo->curthread must be initialized before calling enter_syscall(),
it is used by t->proc->abi->fetch_args() .
Without that truss is segfaulting and the attached program crash also.

It can be reproduced by trying to attach a binary which is doing a
while (1) usleep(1);

Test Plan

Try to attach a few times a program which is doing a while (1) usleep(1) or any program doing a lot of short syscalls.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

nikita_elyzion.net retitled this revision from to truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall.
nikita_elyzion.net updated this object.
nikita_elyzion.net edited the test plan for this revision. (Show Details)

Hmm, you actually already know the thread (it's 't'). I think this is fallout from considering removing 'curthread' (but something I haven't done yet). I think you can just do 'info->curthread = t;' before enter_syscall() in place of find_thread().

(Long term I think I'd like to pass 't' down to the ABI callbacks and remove curthread completely. trussinfo itself is an odd duck as it's really just global variables but obfuscated)

bapt added a subscriber: bapt.
jhb edited edge metadata.
This revision is now accepted and ready to land.Aug 2 2016, 10:04 PM
This revision was automatically updated to reflect the committed changes.