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)
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)
Thu, May 30, 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
Unknown Object (File)
Dec 9 2023, 1:07 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.