New issue
Advanced search Search tips

Issue 688362 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2017
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug

Blocking:
issue 671990



Sign in to add a comment

base::OpenFile should not allow handles to be inherited into child procs

Project Member Reported by grt@chromium.org, Feb 3 2017

Issue description

OpenFile (used by ReadFileToString, among others) inadvertently opens its handles for inheritance due to implementation details of the Microsoft CRT. There exists an undocumented "N" mode flag for opening file streams that disables allowing the opened file to be inherited into child processes. base::OpenFile should add this to the mode string if it isn't already present (it shouldn't be).
 

Comment 1 by grt@chromium.org, Feb 6 2017

Labels: OS-Linux OS-Mac
Corrections:
- 'N' is documented here: https://msdn.microsoft.com/en-us/library/yeby3zcb.aspx.
- this is probably the default on Windows for consistency with *nix.
- 'e' is the character to disable sharing for glibc (https://www.gnu.org/software/libc/manual/html_node/Opening-Streams.html).

Adding Mac and Linux to the affected platforms. This "share-by-default" policy has caused problems on Windows (see  issue 671990 ). Is there any reason not to change base::OpenFile so that this is disabled by default? We could define our own mode character to enable sharing where needed.

Comment 3 by grt@chromium.org, Feb 13 2017

Owner: grt@chromium.org
Status: Fixed (was: Available)
Project Member

Comment 4 by bugdroid1@chromium.org, Feb 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/mini_chromium/+/3a2d52d74c9af5277bf6456cc00ae728f89c4898

commit 3a2d52d74c9af5277bf6456cc00ae728f89c4898
Author: Mark Mentovai <mark@chromium.org>
Date: Tue Feb 28 21:13:52 2017

Use O_CLOEXEC (and O_NOCTTY) when calling open()

Equivalent to https://codereview.chromium.org/2725713002/.

BUG= chromium:688362 

Change-Id: I02b706af113c2ad8b0436464c2cc5abd2b5bc62e
Reviewed-on: https://chromium-review.googlesource.com/447998
Reviewed-by: Scott Graham <scottmg@chromium.org>

[modify] https://crrev.com/3a2d52d74c9af5277bf6456cc00ae728f89c4898/base/rand_util.cc

Project Member

Comment 6 by bugdroid1@chromium.org, Feb 28 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/4cec49482d07386181836bfd950a06445421471d

commit 4cec49482d07386181836bfd950a06445421471d
Author: mark <mark@chromium.org>
Date: Tue Feb 28 23:56:00 2017

Use O_CLOEXEC when calling open() in rand_util_posix

BUG= 688362 

Review-Url: https://codereview.chromium.org/2725713002
Cr-Commit-Position: refs/heads/master@{#453754}

[modify] https://crrev.com/4cec49482d07386181836bfd950a06445421471d/base/rand_util_posix.cc

Sign in to add a comment