Subject: Re: ktrace and P_SUGID
To: Simon J. Gerraty <sjg@crufty.net>
From: None <itojun@iijlab.net>
List: tech-security
Date: 06/29/2002 15:20:57
>I trust that this restriction does not apply if the ktrace was initiated
>by root? I've not looked at the netbsd ktrace paths, but I had to
>fix the freebsd kernel to allow ktrace across exec of a setuid binary
>when the trace was initiated by root - otherwise its nearly impossible
>to debug certain classes of bug.
the following line takes care of "invoked by root" case.
itojun
if ((caller->pc_ucred->cr_uid == target->p_ruid &&
target->p_ruid == target->p_svuid &&
caller->p_rgid == target->p_rgid && /* XXX */
target->p_rgid == target->p_svgid &&
(targetp->p_traceflag & KTRFAC_ROOT) == 0 &&
(targetp->p_flag & P_SUGID) == 0) ||
caller->pc_ucred->cr_uid == 0) <----
return (1);