Bug 199810 - libdtrace should probably use O_CLOEXEC while calling open() instead of setting FD_CLOEXEC using fcntl()
Summary: libdtrace should probably use O_CLOEXEC while calling open() instead of setti...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-04-30 13:34 UTC by jau
Modified: 2017-09-12 14:38 UTC (History)
3 users (show)

See Also:


Attachments
A patch to add the appropriate O_CLOEXEC flags and to remove the fcntl() calls (1.61 KB, patch)
2015-04-30 13:34 UTC, jau
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jau 2015-04-30 13:34:08 UTC
Created attachment 156148 [details]
A patch to add the appropriate O_CLOEXEC flags and to remove the fcntl() calls

The same report applies to both 11.0-CURRENT and 10.1-STABLE.

In libdtrace there are a few calls to fcntl() to set FD_CLOEXEC for
file descriptors for which the easier and more robust approach would
be setting O_CLOEXEC already when calling open().
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2015-05-02 21:00:39 UTC
Cc: gnn in case of interest.
Comment 2 Ed Maste freebsd_committer freebsd_triage 2017-08-30 03:13:09 UTC
The patch looks good to me. Mark, as the one most likely to be affected by changes in cddl/contrib/opensolaris/lib/libdtrace on a future import, what do you think of the approach in the patch, vs #ifdef FreeBSD / #ifdef illumos guards throughout?
Comment 3 Mark Johnston freebsd_committer freebsd_triage 2017-08-30 03:36:25 UTC
(In reply to Ed Maste from comment #2)
I think the patch is fine as-is. Given the relatively slow pace of upstream development, I'm not inclined to add ifdefs around every small deviation. Also, illumos now has O_CLOEXEC, so it'd be easy to integrate this upstream at some point in the future.
Comment 4 commit-hook freebsd_committer freebsd_triage 2017-09-05 00:11:32 UTC
A commit references this bug:

Author: markj
Date: Tue Sep  5 00:11:06 UTC 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

Changes:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2017-09-12 13:49:08 UTC
MFCed to stable/11 in r323495.
Comment 6 commit-hook freebsd_committer freebsd_triage 2017-09-12 14:38:52 UTC
A commit references this bug:

Author: markj
Date: Tue Sep 12 14:38:11 UTC 2017
New revision: 323498
URL: https://svnweb.freebsd.org/changeset/base/323498

Log:
  Add a O_CLOEXEC use missed in r323166.

  PR:		199810
  Reported by:	Jukka A. Ukkonen <jau789@gmail.com>
  MFC after:	3 days

Changes:
  head/cddl/contrib/opensolaris/lib/libdtrace/common/dt_open.c