OLD | NEW |
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> |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 } | 314 } |
315 | 315 |
316 return true; | 316 return true; |
317 } | 317 } |
318 | 318 |
319 void GpuProcessPolicy::InitGpuBrokerProcess( | 319 void GpuProcessPolicy::InitGpuBrokerProcess( |
320 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), | 320 sandbox::bpf_dsl::Policy* (*broker_sandboxer_allocator)(void), |
321 const std::vector<BrokerFilePermission>& permissions_extra) { | 321 const std::vector<BrokerFilePermission>& permissions_extra) { |
322 static const char kDriRcPath[] = "/etc/drirc"; | 322 static const char kDriRcPath[] = "/etc/drirc"; |
323 static const char kDriCard0Path[] = "/dev/dri/card0"; | 323 static const char kDriCard0Path[] = "/dev/dri/card0"; |
324 static const char kDriRenderNode0Path[] = "/dev/dri/renderD128"; | |
325 static const char kDevShm[] = "/dev/shm/"; | 324 static const char kDevShm[] = "/dev/shm/"; |
326 | 325 |
327 CHECK(broker_process_ == NULL); | 326 CHECK(broker_process_ == NULL); |
328 | 327 |
329 // All GPU process policies need these files brokered out. | 328 // All GPU process policies need these files brokered out. |
330 std::vector<BrokerFilePermission> permissions; | 329 std::vector<BrokerFilePermission> permissions; |
331 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path)); | 330 permissions.push_back(BrokerFilePermission::ReadWrite(kDriCard0Path)); |
332 permissions.push_back(BrokerFilePermission::ReadWrite(kDriRenderNode0Path)); | |
333 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath)); | 331 permissions.push_back(BrokerFilePermission::ReadOnly(kDriRcPath)); |
334 if (!IsChromeOS()) { | 332 if (!IsChromeOS()) { |
335 permissions.push_back( | 333 permissions.push_back( |
336 BrokerFilePermission::ReadWriteCreateUnlinkRecursive(kDevShm)); | 334 BrokerFilePermission::ReadWriteCreateUnlinkRecursive(kDevShm)); |
337 } else if (IsArchitectureArm() || IsOzone()){ | 335 } else if (IsArchitectureArm() || IsOzone()){ |
338 AddV4L2GpuWhitelist(&permissions); | 336 AddV4L2GpuWhitelist(&permissions); |
339 if (UseLibV4L2()) { | 337 if (UseLibV4L2()) { |
340 dlopen("/usr/lib/libv4l2.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | 338 dlopen("/usr/lib/libv4l2.so", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
341 // This is a device-specific encoder plugin. | 339 // This is a device-specific encoder plugin. |
342 dlopen("/usr/lib/libv4l/plugins/libv4l-encplugin.so", | 340 dlopen("/usr/lib/libv4l/plugins/libv4l-encplugin.so", |
343 RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); | 341 RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE); |
344 } | 342 } |
345 } | 343 } |
346 | 344 |
347 // Add eventual extra files from permissions_extra. | 345 // Add eventual extra files from permissions_extra. |
348 for (const auto& perm : permissions_extra) { | 346 for (const auto& perm : permissions_extra) { |
349 permissions.push_back(perm); | 347 permissions.push_back(perm); |
350 } | 348 } |
351 | 349 |
352 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions); | 350 broker_process_ = new BrokerProcess(GetFSDeniedErrno(), permissions); |
353 // The initialization callback will perform generic initialization and then | 351 // The initialization callback will perform generic initialization and then |
354 // call broker_sandboxer_callback. | 352 // call broker_sandboxer_callback. |
355 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, | 353 CHECK(broker_process_->Init(base::Bind(&UpdateProcessTypeAndEnableSandbox, |
356 broker_sandboxer_allocator))); | 354 broker_sandboxer_allocator))); |
357 } | 355 } |
358 | 356 |
359 } // namespace content | 357 } // namespace content |
OLD | NEW |