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

Side by Side Diff: sandbox/mac/launchd_interception_server.h

Issue 332523003: Attempt to fix a NULL deref in sandbox::LaunchdInterceptionServer::HandleLookUp(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | sandbox/mac/launchd_interception_server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_ 5 #ifndef SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
6 #define SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_ 6 #define SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
7 7
8 #include <dispatch/dispatch.h> 8 #include <dispatch/dispatch.h>
9 #include <mach/mach.h> 9 #include <mach/mach.h>
10 10
11 #include "base/mac/scoped_mach_port.h" 11 #include "base/mac/scoped_mach_port.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "sandbox/mac/mach_message_server.h" 13 #include "sandbox/mac/mach_message_server.h"
14 #include "sandbox/mac/os_compatibility.h" 14 #include "sandbox/mac/os_compatibility.h"
15 15
16 namespace sandbox { 16 namespace sandbox {
17 17
18 class BootstrapSandbox; 18 class BootstrapSandbox;
19 struct BootstrapSandboxPolicy;
19 20
20 // This class is used to run a Mach IPC message server. This server can 21 // This class is used to run a Mach IPC message server. This server can
21 // hold the receive right for a bootstrap_port of a process, and it filters 22 // hold the receive right for a bootstrap_port of a process, and it filters
22 // a subset of the launchd/bootstrap IPC call set for sandboxing. It permits 23 // a subset of the launchd/bootstrap IPC call set for sandboxing. It permits
23 // or rejects requests based on the per-process policy specified in the 24 // or rejects requests based on the per-process policy specified in the
24 // BootstrapSandbox. 25 // BootstrapSandbox.
25 class LaunchdInterceptionServer : public MessageDemuxer { 26 class LaunchdInterceptionServer : public MessageDemuxer {
26 public: 27 public:
27 explicit LaunchdInterceptionServer(const BootstrapSandbox* sandbox); 28 explicit LaunchdInterceptionServer(const BootstrapSandbox* sandbox);
28 virtual ~LaunchdInterceptionServer(); 29 virtual ~LaunchdInterceptionServer();
29 30
30 // Initializes the class and starts running the message server. 31 // Initializes the class and starts running the message server.
31 bool Initialize(); 32 bool Initialize();
32 33
33 // MessageDemuxer: 34 // MessageDemuxer:
34 virtual void DemuxMessage(mach_msg_header_t* request, 35 virtual void DemuxMessage(mach_msg_header_t* request,
35 mach_msg_header_t* reply) OVERRIDE; 36 mach_msg_header_t* reply) OVERRIDE;
36 37
37 mach_port_t server_port() const { return message_server_->server_port(); } 38 mach_port_t server_port() const { return message_server_->server_port(); }
38 39
39 private: 40 private:
40 // Given a look_up2 request message, this looks up the appropriate sandbox 41 // Given a look_up2 request message, this looks up the appropriate sandbox
41 // policy for the service name then formulates and sends the reply message. 42 // policy for the service name then formulates and sends the reply message.
42 void HandleLookUp(mach_msg_header_t* request, 43 void HandleLookUp(mach_msg_header_t* request,
43 mach_msg_header_t* reply, 44 mach_msg_header_t* reply,
44 pid_t sender_pid); 45 const BootstrapSandboxPolicy* policy);
45 46
46 // Given a swap_integer request message, this verifies that it is safe, and 47 // Given a swap_integer request message, this verifies that it is safe, and
47 // if so, forwards it on to launchd for servicing. If the request is unsafe, 48 // if so, forwards it on to launchd for servicing. If the request is unsafe,
48 // it replies with an error. 49 // it replies with an error.
49 void HandleSwapInteger(mach_msg_header_t* request, 50 void HandleSwapInteger(mach_msg_header_t* request,
50 mach_msg_header_t* reply, 51 mach_msg_header_t* reply);
51 pid_t sender_pid);
52 52
53 // Forwards the original |request| on to real bootstrap server for handling. 53 // Forwards the original |request| on to real bootstrap server for handling.
54 void ForwardMessage(mach_msg_header_t* request); 54 void ForwardMessage(mach_msg_header_t* request);
55 55
56 // The sandbox for which this message server is running. 56 // The sandbox for which this message server is running.
57 const BootstrapSandbox* sandbox_; 57 const BootstrapSandbox* sandbox_;
58 58
59 // The Mach IPC server. 59 // The Mach IPC server.
60 scoped_ptr<MachMessageServer> message_server_; 60 scoped_ptr<MachMessageServer> message_server_;
61 61
62 // The Mach port handed out in reply to denied look up requests. All denied 62 // The Mach port handed out in reply to denied look up requests. All denied
63 // requests share the same port, though nothing reads messages from it. 63 // requests share the same port, though nothing reads messages from it.
64 base::mac::ScopedMachReceiveRight sandbox_port_; 64 base::mac::ScopedMachReceiveRight sandbox_port_;
65 // The send right for the above |sandbox_port_|, used with 65 // The send right for the above |sandbox_port_|, used with
66 // MACH_MSG_TYPE_COPY_SEND when handing out references to the dummy port. 66 // MACH_MSG_TYPE_COPY_SEND when handing out references to the dummy port.
67 base::mac::ScopedMachSendRight sandbox_send_port_; 67 base::mac::ScopedMachSendRight sandbox_send_port_;
68 68
69 // The compatibility shim that handles differences in message header IDs and 69 // The compatibility shim that handles differences in message header IDs and
70 // request/reply structures between different OS X versions. 70 // request/reply structures between different OS X versions.
71 const LaunchdCompatibilityShim compat_shim_; 71 const LaunchdCompatibilityShim compat_shim_;
72 }; 72 };
73 73
74 } // namespace sandbox 74 } // namespace sandbox
75 75
76 #endif // SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_ 76 #endif // SANDBOX_MAC_LAUNCHD_INTERCEPTION_SERVER_H_
OLDNEW
« no previous file with comments | « no previous file | sandbox/mac/launchd_interception_server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698