From owner-svn-src-all@freebsd.org Tue Oct 20 20:22:59 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 039D4A0A3E9; Tue, 20 Oct 2015 20:22:59 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C2DB66A2; Tue, 20 Oct 2015 20:22:58 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9KKMvVm060297; Tue, 20 Oct 2015 20:22:57 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9KKMvxO060296; Tue, 20 Oct 2015 20:22:57 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201510202022.t9KKMvxO060296@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Tue, 20 Oct 2015 20:22:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289660 - head/sys/kern X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Oct 2015 20:22:59 -0000 Author: kib Date: Tue Oct 20 20:22:57 2015 New Revision: 289660 URL: https://svnweb.freebsd.org/changeset/base/289660 Log: Reviewed by: jhb, pho Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D3908 Modified: head/sys/kern/sys_process.c Modified: head/sys/kern/sys_process.c ============================================================================== --- head/sys/kern/sys_process.c Tue Oct 20 20:15:25 2015 (r289659) +++ head/sys/kern/sys_process.c Tue Oct 20 20:22:57 2015 (r289660) @@ -744,7 +744,18 @@ kern_ptrace(struct thread *td, int req, */ switch (req) { case PT_TRACE_ME: - /* Always legal. */ + /* + * Always legal, when there is a parent process which + * could trace us. Otherwise, reject. + */ + if ((p->p_flag & P_TRACED) != 0) { + error = EBUSY; + goto fail; + } + if (p->p_pptr == initproc) { + error = EPERM; + goto fail; + } break; case PT_ATTACH: