From owner-freebsd-hackers@FreeBSD.ORG Sat Sep 22 16:05:53 2012 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 71BDE106564A; Sat, 22 Sep 2012 16:05:53 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 77F3D8FC0A; Sat, 22 Sep 2012 16:05:52 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA07335; Sat, 22 Sep 2012 19:05:50 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1TFSDG-000NSX-Fk; Sat, 22 Sep 2012 19:05:50 +0300 Message-ID: <505DE1DD.7070506@FreeBSD.org> Date: Sat, 22 Sep 2012 19:05:49 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120913 Thunderbird/15.0.1 MIME-Version: 1.0 To: freebsd-hackers , freebsd-security@FreeBSD.org X-Enigmail-Version: 1.4.3 Content-Type: text/plain; charset=X-VIET-VPS Content-Transfer-Encoding: 7bit Cc: Subject: kern_exec: check p_tracecred instead of p_cred X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Sep 2012 16:05:53 -0000 Currently even if root ktraces an unprivileged process that execs a sguid executable, then tracing aborted at that point. I think that that happens because wrong credentials are checked at that point. What do you think about the following patch? commit 956a80783bc39162b1d64383188c5037f9767413 Author: Andriy Gapon Date: Sat Sep 22 18:17:46 2012 +0300 kern_exec: check p_tracecred instead of p_cred ... when deciding whether to continue tracing across suid/sgid exec diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 90f7311..8d62c1e 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -694,7 +694,8 @@ interpret: setsugid(p); #ifdef KTRACE - if (priv_check_cred(oldcred, PRIV_DEBUG_DIFFCRED, 0)) + if (p->p_tracecred != NULL && + priv_check_cred(p->p_tracecred, PRIV_DEBUG_DIFFCRED, 0)) ktrprocexec(p, &tracecred, &tracevp); #endif /* -- Andriy Gapon