Page MenuHomeFreeBSD

ktrace: Avoid recursion in namei()
ClosedPublic

Authored by markj on May 18 2021, 8:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Oct 8, 6:21 PM
Unknown Object (File)
Thu, Oct 8, 5:43 PM
Unknown Object (File)
Thu, Oct 8, 5:37 AM
Unknown Object (File)
Thu, Oct 1, 5:17 PM
Unknown Object (File)
Tue, Sep 29, 12:19 AM
Unknown Object (File)
Sun, Sep 27, 2:16 PM
Unknown Object (File)
Wed, Sep 16, 11:57 PM
Unknown Object (File)
Sep 10 2026, 9:17 AM
Subscribers

Details

Summary

I tried fuzzing ktrace(2) with syzkaller and it found the following bug:
sys_ktrace() calls namei(), which may call ktrnamei(). But sys_ktrace()
also calls ktrace_enter() first, so if the caller is itself being
traced, the assertion in ktrace_enter() is triggered. And, ktrnamei()
does not check for recursion like most other ktrace ops do.

Fix the bug by simply deferring the ktrace_enter() call. I believe it
is safe to perform name resolution from sys_ktrace() even when traced.
Also make the parameter to ktrnamei() const and convert to ANSI.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable