From owner-freebsd-hackers@freebsd.org Mon Apr 9 10:30:26 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9516BF97567 for ; Mon, 9 Apr 2018 10:30:26 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.117.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 2F896785FD for ; Mon, 9 Apr 2018 10:30:25 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from leaf.local (unknown [88.202.132.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id BB28110E71 for ; Mon, 9 Apr 2018 10:30:17 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none (p=none dis=none) header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/BB28110E71; dkim=none; dkim-atps=neutral Subject: Re: Tracing with DTrace, when custom probe provider is running as regular user To: freebsd-hackers@freebsd.org References: <1D449DD6-4D38-4561-8BD0-B6E581AB53A8@gmail.com> From: Matthew Seaman Message-ID: Date: Mon, 9 Apr 2018 11:30:10 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1D449DD6-4D38-4561-8BD0-B6E581AB53A8@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Apr 2018 10:30:26 -0000 On 09/04/2018 11:01, Daniel Dettlaff wrote: > Issue is critical for tracing Postgresql which demands to run with > NON privileged user, but in general launching any server software as root > should be considered to be "harmful" / "a bad idea" right? The issue with allowing non-privileged users access to dtrace is the risk of disclosing kernel memory. Unfortunately blocking this access means that using the UserSDT's from (for example) postgresql-server running as the postgres user is not permitted. > So question is - is there a way to work around this? I wish to be > able to trace user software as root using dtrace. Is there a way to > do it? I build whole system from source so I can even do custom patch > if I'd know where to look :) Actually, it all depends on the permissions on /dev/dtrace/* -- It's fairly easy to. say, add a 'dtrace' group, change /dev/dtrace/helper to be owned by root:dtrace and mode 0770 by tweaking /etc/devfs.rules: [userdtrace=10] add path dtrace/helper mode 0660 group dtrace and adding devfs_system_ruleset="userdtrace" to /etc/rc.conf, and then making the postgres or whatever other users your software runs as members of group dtrace Cheers, Matthew