Subject: Re: ktrace and P_SUGID
To: None <itojun@iijlab.net>
From: Simon J. Gerraty <sjg@crufty.net>
List: tech-security
Date: 06/29/2002 01:44:07
>>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.
> 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);
Hmm, wouldn't it be better to test caller->pc_ucred->cr_uid == 0
first?
Thanks
--sjg