summaryrefslogtreecommitdiff
path: root/chromium/content/common/child_process_sandbox_support_impl_shm_linux.cc
blob: 0c634c109a9c66ed77ad865bf8e6fe8713c2f461 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "content/common/child_process_sandbox_support_impl_linux.h"

#include "base/pickle.h"
#include "base/posix/unix_domain_socket_linux.h"
#include "content/common/sandbox_linux/sandbox_linux.h"

namespace content {

int MakeSharedMemorySegmentViaIPC(size_t length, bool executable) {
  Pickle request;
  request.WriteInt(LinuxSandbox::METHOD_MAKE_SHARED_MEMORY_SEGMENT);
  request.WriteUInt32(length);
  request.WriteBool(executable);
  uint8_t reply_buf[10];
  int result_fd;
  ssize_t result = UnixDomainSocket::SendRecvMsg(GetSandboxFD(),
                                                 reply_buf, sizeof(reply_buf),
                                                 &result_fd, request);
  if (result == -1)
    return -1;
  return result_fd;
}

}  // namespace content