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
F87121973: D7399.diff
Sat, Jun 29, 4:01 PM
Unknown Object (File)
Sat, Jun 22, 3:17 AM
Unknown Object (File)
Fri, Jun 21, 8:57 PM
Unknown Object (File)
Sat, Jun 1, 6:45 AM
Unknown Object (File)
May 30 2024, 4:15 AM
Unknown Object (File)
Feb 23 2024, 12:16 AM
Unknown Object (File)
Dec 23 2023, 11:31 AM
Unknown Object (File)
Dec 18 2023, 9:46 PM

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 Passed
Unit
No Test Coverage
Build Status
Buildable 4686
Build 4740: arc lint + arc unit

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.