Page MenuHomeFreeBSD

Do not go into sleep in sleepq_catch_signals() when SIGSTOP from PT_ATTACH was consumed.
ClosedPublic

Authored by kib on May 23 2019, 3:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 3:16 PM
Unknown Object (File)
Dec 20 2023, 5:10 AM
Unknown Object (File)
Dec 16 2023, 5:29 PM
Unknown Object (File)
Dec 13 2023, 2:54 PM
Unknown Object (File)
Nov 16 2023, 2:32 PM
Unknown Object (File)
Nov 15 2023, 7:23 AM
Unknown Object (File)
Nov 10 2023, 2:24 AM
Unknown Object (File)
Nov 8 2023, 8:04 AM
Subscribers

Details

Summary

In particular, do not clear TDP_FSTP in ptracestop() if td_wchan is non-NULL. Leave it to sleepq_catch_signal() to clear and convert zero return code to EINTR.

Otherwise, per submitter report, if the PT_ATTACH SIGSTOP was delivered right after the thread was added to the sleepqueue but not yet really sleep, and cursig() caused debugger attach, the thread sleeps instead of returning to the userspace boundary with EINTR.

PR: 231445

Diff Detail

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

Event Timeline

sys/kern/subr_sleepqueue.c
507 ↗(On Diff #57770)

"should do that here as well"

512 ↗(On Diff #57770)

How is it possible for FSTP to be set when ret != 0? Doesn't it imply that some non-SIGSTOP signal was handled ahead of the PT_ATTACH SIGSTOP?

kib marked an inline comment as done.May 27 2019, 3:52 PM
kib added inline comments.
sys/kern/subr_sleepqueue.c
512 ↗(On Diff #57770)

I believe that debugger might choose to deliver some other signal when it continues from SIGSTOP, instead of ignoring it. Then issignal() would do one more iteration, with the entry to ptracestop() which would still not clear TDB_FSTP, and that signal causes specific error return from the cursig() to sleepq_catch_signals().

Fix language in the comment.

This revision is now accepted and ready to land.May 27 2019, 6:39 PM
This revision was automatically updated to reflect the committed changes.