| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "debug.h" | 5 #include "debug.h" |
| 6 #include "sandbox_impl.h" | 6 #include "sandbox_impl.h" |
| 7 | 7 |
| 8 namespace { | 8 namespace { |
| 9 | 9 |
| 10 bool AllowedSetSockOpt(const Sandbox::SetSockOpt& setsockopt_req) { | 10 bool AllowedSetSockOpt(const Sandbox::SetSockOpt& setsockopt_req) { |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 399 // Unsupported flag encountered. Deny the call. | 399 // Unsupported flag encountered. Deny the call. |
| 400 if (sendto_req.flags & | 400 if (sendto_req.flags & |
| 401 ~(MSG_CONFIRM|MSG_DONTWAIT|MSG_EOR|MSG_MORE|MSG_NOSIGNAL|MSG_OOB)) { | 401 ~(MSG_CONFIRM|MSG_DONTWAIT|MSG_EOR|MSG_MORE|MSG_NOSIGNAL|MSG_OOB)) { |
| 402 SecureMem::abandonSystemCall(*info, -EINVAL); | 402 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 403 return false; | 403 return false; |
| 404 } | 404 } |
| 405 | 405 |
| 406 // Sending data on a connected socket is similar to calling write(). | 406 // Sending data on a connected socket is similar to calling write(). |
| 407 // Allow it. | 407 // Allow it. |
| 408 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, sendto_req.sockfd, | 408 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, sendto_req.sockfd, |
| 409 sendto_req.buf, sendto_req.len, | 409 const_cast<void*>(sendto_req.buf), sendto_req.len, |
| 410 sendto_req.flags, sendto_req.to, | 410 sendto_req.flags, const_cast<void*>(sendto_req.to), |
| 411 sendto_req.tolen); | 411 sendto_req.tolen); |
| 412 return true; | 412 return true; |
| 413 } | 413 } |
| 414 | 414 |
| 415 bool Sandbox::process_setsockopt(const SyscallRequestInfo* info) { | 415 bool Sandbox::process_setsockopt(const SyscallRequestInfo* info) { |
| 416 // Read request | 416 // Read request |
| 417 SetSockOpt setsockopt_req; | 417 SetSockOpt setsockopt_req; |
| 418 SysCalls sys; | 418 SysCalls sys; |
| 419 if (read(sys, info->trustedProcessFd, &setsockopt_req, | 419 if (read(sys, info->trustedProcessFd, &setsockopt_req, |
| 420 sizeof(setsockopt_req)) != sizeof(setsockopt_req)) { | 420 sizeof(setsockopt_req)) != sizeof(setsockopt_req)) { |
| 421 die("Failed to read parameters for setsockopt() [process]"); | 421 die("Failed to read parameters for setsockopt() [process]"); |
| 422 } | 422 } |
| 423 | 423 |
| 424 if (AllowedSetSockOpt(setsockopt_req)) { | 424 if (AllowedSetSockOpt(setsockopt_req)) { |
| 425 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, | 425 SecureMem::sendSystemCall(*info, SecureMem::SEND_UNLOCKED, |
| 426 setsockopt_req.sockfd, | 426 setsockopt_req.sockfd, |
| 427 setsockopt_req.level, setsockopt_req.optname, | 427 setsockopt_req.level, setsockopt_req.optname, |
| 428 setsockopt_req.optval, setsockopt_req.optlen); | 428 const_cast<void*>(setsockopt_req.optval), |
| 429 setsockopt_req.optlen); |
| 429 return true; | 430 return true; |
| 430 } | 431 } |
| 431 SecureMem::abandonSystemCall(*info, -EINVAL); | 432 SecureMem::abandonSystemCall(*info, -EINVAL); |
| 432 return false; | 433 return false; |
| 433 } | 434 } |
| 434 | 435 |
| 435 bool Sandbox::process_getsockopt(const SyscallRequestInfo* info) { | 436 bool Sandbox::process_getsockopt(const SyscallRequestInfo* info) { |
| 436 // Read request | 437 // Read request |
| 437 GetSockOpt getsockopt_req; | 438 GetSockOpt getsockopt_req; |
| 438 SysCalls sys; | 439 SysCalls sys; |
| (...skipping 466 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 default: | 906 default: |
| 906 deny: | 907 deny: |
| 907 SecureMem::abandonSystemCall(*info, rc); | 908 SecureMem::abandonSystemCall(*info, rc); |
| 908 return false; | 909 return false; |
| 909 } | 910 } |
| 910 } | 911 } |
| 911 | 912 |
| 912 #endif | 913 #endif |
| 913 | 914 |
| 914 } // namespace | 915 } // namespace |
| OLD | NEW |