Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/events/ozone/evdev/scoped_input_device.h" | |
| 6 | |
| 7 #include <errno.h> | |
| 8 #include <unistd.h> | |
| 9 | |
| 10 #include "base/debug/alias.h" | |
| 11 #include "base/logging.h" | |
| 12 #include "base/posix/eintr_wrapper.h" | |
| 13 | |
| 14 namespace ui { | |
| 15 namespace internal { | |
| 16 | |
| 17 // static | |
| 18 void ScopedInputDeviceCloseTraits::Free(int fd) { | |
| 19 // It's important to crash here. | |
| 20 // There are security implications to not closing a file descriptor | |
| 21 // properly. As file descriptors are "capabilities", keeping them open | |
| 22 // would make the current process keep access to a resource. Much of | |
| 23 // Chrome relies on being able to "drop" such access. | |
| 24 // It's especially problematic on Linux with the setuid sandbox, where | |
| 25 // a single open directory would bypass the entire security model. | |
| 26 int ret = IGNORE_EINTR(close(fd)); | |
| 27 | |
| 28 // TODO(davidben): Remove this once it's been determined whether | |
| 29 // https://crbug.com/603354 is caused by EBADF or a network filesystem | |
| 30 // returning some other error. | |
| 31 int close_errno = errno; | |
| 32 base::debug::Alias(&close_errno); | |
|
davidben
2017/01/18 19:48:10
(Same comment as in the other CL that this base::d
spang
2017/01/18 20:40:35
done.
| |
| 33 | |
| 34 PCHECK(0 == ret || close_errno != EBADF); | |
| 35 } | |
| 36 | |
| 37 } // namespace internal | |
| 38 } // namespace ui | |
| OLD | NEW |