Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(548)

Side by Side Diff: content/common/sandbox_linux/bpf_gpu_policy_linux.cc

Issue 2398883002: Add support for multiple V4L2 video devices of the same type. (Closed)
Patch Set: comments addressed Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/gpu/generic_v4l2_device.h » ('j') | media/gpu/v4l2_device.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h" 5 #include "content/common/sandbox_linux/bpf_gpu_policy_linux.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
11 #include <sys/stat.h> 11 #include <sys/stat.h>
12 #include <sys/types.h> 12 #include <sys/types.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/compiler_specific.h" 21 #include "base/compiler_specific.h"
22 #include "base/files/file_enumerator.h"
22 #include "base/logging.h" 23 #include "base/logging.h"
23 #include "base/macros.h" 24 #include "base/macros.h"
24 #include "base/memory/ptr_util.h" 25 #include "base/memory/ptr_util.h"
25 #include "base/strings/stringprintf.h" 26 #include "base/strings/stringprintf.h"
26 #include "build/build_config.h" 27 #include "build/build_config.h"
27 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h" 28 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
28 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h" 29 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
29 #include "content/common/set_process_title.h" 30 #include "content/common/set_process_title.h"
30 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
31 #include "sandbox/linux/bpf_dsl/bpf_dsl.h" 32 #include "sandbox/linux/bpf_dsl/bpf_dsl.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 return -EPERM; 148 return -EPERM;
148 } 149 }
149 default: 150 default:
150 RAW_CHECK(false); 151 RAW_CHECK(false);
151 return -ENOSYS; 152 return -ENOSYS;
152 } 153 }
153 } 154 }
154 155
155 void AddV4L2GpuWhitelist(std::vector<BrokerFilePermission>* permissions) { 156 void AddV4L2GpuWhitelist(std::vector<BrokerFilePermission>* permissions) {
156 if (IsAcceleratedVideoDecodeEnabled()) { 157 if (IsAcceleratedVideoDecodeEnabled()) {
157 // Device node for V4L2 video decode accelerator drivers. 158 // Device nodes for V4L2 video decode accelerator drivers.
158 static const char kDevVideoDecPath[] = "/dev/video-dec"; 159 static const base::FilePath::CharType kDevicePath[] =
159 permissions->push_back(BrokerFilePermission::ReadWrite(kDevVideoDecPath)); 160 FILE_PATH_LITERAL("/dev/");
161 static const base::FilePath::CharType kVideoDecPattern[] = "video-dec[0-9]";
162 base::FileEnumerator enumerator(base::FilePath(kDevicePath), false,
163 base::FileEnumerator::FILES,
164 base::FilePath(kVideoDecPattern).value());
165 for (base::FilePath name = enumerator.Next(); !name.empty();
166 name = enumerator.Next())
167 permissions->push_back(BrokerFilePermission::ReadWrite(name.value()));
160 } 168 }
161 169
162 // Device node for V4L2 video encode accelerator drivers. 170 // Device node for V4L2 video encode accelerator drivers.
163 static const char kDevVideoEncPath[] = "/dev/video-enc"; 171 static const char kDevVideoEncPath[] = "/dev/video-enc";
164 permissions->push_back(BrokerFilePermission::ReadWrite(kDevVideoEncPath)); 172 permissions->push_back(BrokerFilePermission::ReadWrite(kDevVideoEncPath));
165 173
166 // Device node for V4L2 JPEG decode accelerator drivers. 174 // Device node for V4L2 JPEG decode accelerator drivers.
167 static const char kDevJpegDecPath[] = "/dev/jpeg-dec"; 175 static const char kDevJpegDecPath[] = "/dev/jpeg-dec";
168 permissions->push_back(BrokerFilePermission::ReadWrite(kDevJpegDecPath)); 176 permissions->push_back(BrokerFilePermission::ReadWrite(kDevJpegDecPath));
169 } 177 }
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 } 385 }
378 386
379 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions); 387 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions);
380 // The initialization callback will perform generic initialization and then 388 // The initialization callback will perform generic initialization and then
381 // call broker_sandboxer_callback. 389 // call broker_sandboxer_callback.
382 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, 390 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox,
383 broker_sandboxer_allocator))); 391 broker_sandboxer_allocator)));
384 } 392 }
385 393
386 } // namespace content 394 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/gpu/generic_v4l2_device.h » ('j') | media/gpu/v4l2_device.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698