From owner-svn-src-head@freebsd.org Tue Sep 5 00:11:07 2017 Return-Path: Delivered-To: svn-src-head@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 9DBD9E03A31; Tue, 5 Sep 2017 00:11:07 +0000 (UTC) (envelope-from markj@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 6C96B66F80; Tue, 5 Sep 2017 00:11:07 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v850B6nq045071; Tue, 5 Sep 2017 00:11:06 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v850B6Aa045070; Tue, 5 Sep 2017 00:11:06 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201709050011.v850B6Aa045070@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 5 Sep 2017 00:11:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r323166 - head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/cddl/contrib/opensolaris/lib/libdtrace/common X-SVN-Commit-Revision: 323166 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2017 00:11:07 -0000 Author: markj Date: Tue Sep 5 00:11:06 2017 New Revision: 323166 URL: https://svnweb.freebsd.org/changeset/base/323166 Log: Use O_CLOEXEC when opening persistent handles in libdtrace. PR: 199810 Submitted by: jau@iki.fi MFC after: 1 week Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Modified: head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c ============================================================================== --- head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Mon Sep 4 22:37:28 2017 (r323165) +++ head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c Tue Sep 5 00:11:06 2017 (r323166) @@ -963,7 +963,7 @@ dt_provmod_open(dt_provmod_t **provmod, dt_fdlist_t *d (void) snprintf(path, sizeof (path), "/dev/dtrace/%s", p1); - if ((fd = open(path, O_RDONLY)) == -1) + if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) continue; /* failed to open driver; just skip it */ if (((prov = malloc(sizeof (dt_provmod_t))) == NULL) || @@ -1100,7 +1100,7 @@ dt_vopen(int version, int flags, int *errp, */ dt_provmod_open(&provmod, &df); - dtfd = open("/dev/dtrace/dtrace", O_RDWR); + dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC); err = errno; /* save errno from opening dtfd */ #if defined(__FreeBSD__) /* @@ -1116,7 +1116,7 @@ dt_vopen(int version, int flags, int *errp, #ifdef illumos ftfd = open("/dev/dtrace/provider/fasttrap", O_RDWR); #else - ftfd = open("/dev/dtrace/fasttrap", O_RDWR); + ftfd = open("/dev/dtrace/fasttrap", O_RDWR | O_CLOEXEC); #endif fterr = ftfd == -1 ? errno : 0; /* save errno from open ftfd */ @@ -1145,9 +1145,6 @@ dt_vopen(int version, int flags, int *errp, } return (set_open_errno(dtp, errp, err)); } - - (void) fcntl(dtfd, F_SETFD, FD_CLOEXEC); - (void) fcntl(ftfd, F_SETFD, FD_CLOEXEC); alloc: if ((dtp = malloc(sizeof (dtrace_hdl_t))) == NULL) {