OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 "sandbox/win/src/filesystem_dispatcher.h" | 5 #include "sandbox/win/src/filesystem_dispatcher.h" |
6 | 6 |
| 7 #include <stdint.h> |
| 8 |
7 #include "sandbox/win/src/crosscall_client.h" | 9 #include "sandbox/win/src/crosscall_client.h" |
8 #include "sandbox/win/src/filesystem_interception.h" | 10 #include "sandbox/win/src/filesystem_interception.h" |
9 #include "sandbox/win/src/filesystem_policy.h" | 11 #include "sandbox/win/src/filesystem_policy.h" |
10 #include "sandbox/win/src/interception.h" | 12 #include "sandbox/win/src/interception.h" |
11 #include "sandbox/win/src/interceptors.h" | 13 #include "sandbox/win/src/interceptors.h" |
12 #include "sandbox/win/src/ipc_tags.h" | 14 #include "sandbox/win/src/ipc_tags.h" |
13 #include "sandbox/win/src/policy_broker.h" | 15 #include "sandbox/win/src/policy_broker.h" |
14 #include "sandbox/win/src/policy_params.h" | 16 #include "sandbox/win/src/policy_params.h" |
15 #include "sandbox/win/src/sandbox.h" | 17 #include "sandbox/win/src/sandbox.h" |
16 #include "sandbox/win/src/sandbox_nt_util.h" | 18 #include "sandbox/win/src/sandbox_nt_util.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 case IPC_NTSETINFO_RENAME_TAG: | 81 case IPC_NTSETINFO_RENAME_TAG: |
80 return INTERCEPT_NT(manager, NtSetInformationFile, SET_INFO_FILE_ID, 24); | 82 return INTERCEPT_NT(manager, NtSetInformationFile, SET_INFO_FILE_ID, 24); |
81 | 83 |
82 default: | 84 default: |
83 return false; | 85 return false; |
84 } | 86 } |
85 } | 87 } |
86 | 88 |
87 bool FilesystemDispatcher::NtCreateFile(IPCInfo* ipc, | 89 bool FilesystemDispatcher::NtCreateFile(IPCInfo* ipc, |
88 base::string16* name, | 90 base::string16* name, |
89 uint32 attributes, | 91 uint32_t attributes, |
90 uint32 desired_access, | 92 uint32_t desired_access, |
91 uint32 file_attributes, | 93 uint32_t file_attributes, |
92 uint32 share_access, | 94 uint32_t share_access, |
93 uint32 create_disposition, | 95 uint32_t create_disposition, |
94 uint32 create_options) { | 96 uint32_t create_options) { |
95 if (!PreProcessName(name)) { | 97 if (!PreProcessName(name)) { |
96 // The path requested might contain a reparse point. | 98 // The path requested might contain a reparse point. |
97 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 99 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
98 return true; | 100 return true; |
99 } | 101 } |
100 | 102 |
101 const wchar_t* filename = name->c_str(); | 103 const wchar_t* filename = name->c_str(); |
102 | 104 |
103 uint32 broker = TRUE; | 105 uint32_t broker = TRUE; |
104 CountedParameterSet<OpenFile> params; | 106 CountedParameterSet<OpenFile> params; |
105 params[OpenFile::NAME] = ParamPickerMake(filename); | 107 params[OpenFile::NAME] = ParamPickerMake(filename); |
106 params[OpenFile::ACCESS] = ParamPickerMake(desired_access); | 108 params[OpenFile::ACCESS] = ParamPickerMake(desired_access); |
107 params[OpenFile::DISPOSITION] = ParamPickerMake(create_disposition); | 109 params[OpenFile::DISPOSITION] = ParamPickerMake(create_disposition); |
108 params[OpenFile::OPTIONS] = ParamPickerMake(create_options); | 110 params[OpenFile::OPTIONS] = ParamPickerMake(create_options); |
109 params[OpenFile::BROKER] = ParamPickerMake(broker); | 111 params[OpenFile::BROKER] = ParamPickerMake(broker); |
110 | 112 |
111 // To evaluate the policy we need to call back to the policy object. We | 113 // To evaluate the policy we need to call back to the policy object. We |
112 // are just middlemen in the operation since is the FileSystemPolicy which | 114 // are just middlemen in the operation since is the FileSystemPolicy which |
113 // knows what to do. | 115 // knows what to do. |
(...skipping 13 matching lines...) Expand all Loading... |
127 } | 129 } |
128 // Return operation status on the IPC. | 130 // Return operation status on the IPC. |
129 ipc->return_info.extended[0].ulong_ptr = io_information; | 131 ipc->return_info.extended[0].ulong_ptr = io_information; |
130 ipc->return_info.nt_status = nt_status; | 132 ipc->return_info.nt_status = nt_status; |
131 ipc->return_info.handle = handle; | 133 ipc->return_info.handle = handle; |
132 return true; | 134 return true; |
133 } | 135 } |
134 | 136 |
135 bool FilesystemDispatcher::NtOpenFile(IPCInfo* ipc, | 137 bool FilesystemDispatcher::NtOpenFile(IPCInfo* ipc, |
136 base::string16* name, | 138 base::string16* name, |
137 uint32 attributes, | 139 uint32_t attributes, |
138 uint32 desired_access, | 140 uint32_t desired_access, |
139 uint32 share_access, | 141 uint32_t share_access, |
140 uint32 open_options) { | 142 uint32_t open_options) { |
141 if (!PreProcessName(name)) { | 143 if (!PreProcessName(name)) { |
142 // The path requested might contain a reparse point. | 144 // The path requested might contain a reparse point. |
143 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 145 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
144 return true; | 146 return true; |
145 } | 147 } |
146 | 148 |
147 const wchar_t* filename = name->c_str(); | 149 const wchar_t* filename = name->c_str(); |
148 | 150 |
149 uint32 broker = TRUE; | 151 uint32_t broker = TRUE; |
150 uint32 create_disposition = FILE_OPEN; | 152 uint32_t create_disposition = FILE_OPEN; |
151 CountedParameterSet<OpenFile> params; | 153 CountedParameterSet<OpenFile> params; |
152 params[OpenFile::NAME] = ParamPickerMake(filename); | 154 params[OpenFile::NAME] = ParamPickerMake(filename); |
153 params[OpenFile::ACCESS] = ParamPickerMake(desired_access); | 155 params[OpenFile::ACCESS] = ParamPickerMake(desired_access); |
154 params[OpenFile::DISPOSITION] = ParamPickerMake(create_disposition); | 156 params[OpenFile::DISPOSITION] = ParamPickerMake(create_disposition); |
155 params[OpenFile::OPTIONS] = ParamPickerMake(open_options); | 157 params[OpenFile::OPTIONS] = ParamPickerMake(open_options); |
156 params[OpenFile::BROKER] = ParamPickerMake(broker); | 158 params[OpenFile::BROKER] = ParamPickerMake(broker); |
157 | 159 |
158 // To evaluate the policy we need to call back to the policy object. We | 160 // To evaluate the policy we need to call back to the policy object. We |
159 // are just middlemen in the operation since is the FileSystemPolicy which | 161 // are just middlemen in the operation since is the FileSystemPolicy which |
160 // knows what to do. | 162 // knows what to do. |
(...skipping 11 matching lines...) Expand all Loading... |
172 } | 174 } |
173 // Return operation status on the IPC. | 175 // Return operation status on the IPC. |
174 ipc->return_info.extended[0].ulong_ptr = io_information; | 176 ipc->return_info.extended[0].ulong_ptr = io_information; |
175 ipc->return_info.nt_status = nt_status; | 177 ipc->return_info.nt_status = nt_status; |
176 ipc->return_info.handle = handle; | 178 ipc->return_info.handle = handle; |
177 return true; | 179 return true; |
178 } | 180 } |
179 | 181 |
180 bool FilesystemDispatcher::NtQueryAttributesFile(IPCInfo* ipc, | 182 bool FilesystemDispatcher::NtQueryAttributesFile(IPCInfo* ipc, |
181 base::string16* name, | 183 base::string16* name, |
182 uint32 attributes, | 184 uint32_t attributes, |
183 CountedBuffer* info) { | 185 CountedBuffer* info) { |
184 if (sizeof(FILE_BASIC_INFORMATION) != info->Size()) | 186 if (sizeof(FILE_BASIC_INFORMATION) != info->Size()) |
185 return false; | 187 return false; |
186 | 188 |
187 if (!PreProcessName(name)) { | 189 if (!PreProcessName(name)) { |
188 // The path requested might contain a reparse point. | 190 // The path requested might contain a reparse point. |
189 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 191 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
190 return true; | 192 return true; |
191 } | 193 } |
192 | 194 |
193 uint32 broker = TRUE; | 195 uint32_t broker = TRUE; |
194 const wchar_t* filename = name->c_str(); | 196 const wchar_t* filename = name->c_str(); |
195 CountedParameterSet<FileName> params; | 197 CountedParameterSet<FileName> params; |
196 params[FileName::NAME] = ParamPickerMake(filename); | 198 params[FileName::NAME] = ParamPickerMake(filename); |
197 params[FileName::BROKER] = ParamPickerMake(broker); | 199 params[FileName::BROKER] = ParamPickerMake(broker); |
198 | 200 |
199 // To evaluate the policy we need to call back to the policy object. We | 201 // To evaluate the policy we need to call back to the policy object. We |
200 // are just middlemen in the operation since is the FileSystemPolicy which | 202 // are just middlemen in the operation since is the FileSystemPolicy which |
201 // knows what to do. | 203 // knows what to do. |
202 EvalResult result = policy_base_->EvalPolicy(IPC_NTQUERYATTRIBUTESFILE_TAG, | 204 EvalResult result = policy_base_->EvalPolicy(IPC_NTQUERYATTRIBUTESFILE_TAG, |
203 params.GetBase()); | 205 params.GetBase()); |
204 | 206 |
205 FILE_BASIC_INFORMATION* information = | 207 FILE_BASIC_INFORMATION* information = |
206 reinterpret_cast<FILE_BASIC_INFORMATION*>(info->Buffer()); | 208 reinterpret_cast<FILE_BASIC_INFORMATION*>(info->Buffer()); |
207 NTSTATUS nt_status; | 209 NTSTATUS nt_status; |
208 if (!FileSystemPolicy::QueryAttributesFileAction(result, *ipc->client_info, | 210 if (!FileSystemPolicy::QueryAttributesFileAction(result, *ipc->client_info, |
209 *name, attributes, | 211 *name, attributes, |
210 information, &nt_status)) { | 212 information, &nt_status)) { |
211 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 213 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
212 return true; | 214 return true; |
213 } | 215 } |
214 | 216 |
215 // Return operation status on the IPC. | 217 // Return operation status on the IPC. |
216 ipc->return_info.nt_status = nt_status; | 218 ipc->return_info.nt_status = nt_status; |
217 return true; | 219 return true; |
218 } | 220 } |
219 | 221 |
220 bool FilesystemDispatcher::NtQueryFullAttributesFile(IPCInfo* ipc, | 222 bool FilesystemDispatcher::NtQueryFullAttributesFile(IPCInfo* ipc, |
221 base::string16* name, | 223 base::string16* name, |
222 uint32 attributes, | 224 uint32_t attributes, |
223 CountedBuffer* info) { | 225 CountedBuffer* info) { |
224 if (sizeof(FILE_NETWORK_OPEN_INFORMATION) != info->Size()) | 226 if (sizeof(FILE_NETWORK_OPEN_INFORMATION) != info->Size()) |
225 return false; | 227 return false; |
226 | 228 |
227 if (!PreProcessName(name)) { | 229 if (!PreProcessName(name)) { |
228 // The path requested might contain a reparse point. | 230 // The path requested might contain a reparse point. |
229 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 231 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
230 return true; | 232 return true; |
231 } | 233 } |
232 | 234 |
233 uint32 broker = TRUE; | 235 uint32_t broker = TRUE; |
234 const wchar_t* filename = name->c_str(); | 236 const wchar_t* filename = name->c_str(); |
235 CountedParameterSet<FileName> params; | 237 CountedParameterSet<FileName> params; |
236 params[FileName::NAME] = ParamPickerMake(filename); | 238 params[FileName::NAME] = ParamPickerMake(filename); |
237 params[FileName::BROKER] = ParamPickerMake(broker); | 239 params[FileName::BROKER] = ParamPickerMake(broker); |
238 | 240 |
239 // To evaluate the policy we need to call back to the policy object. We | 241 // To evaluate the policy we need to call back to the policy object. We |
240 // are just middlemen in the operation since is the FileSystemPolicy which | 242 // are just middlemen in the operation since is the FileSystemPolicy which |
241 // knows what to do. | 243 // knows what to do. |
242 EvalResult result = policy_base_->EvalPolicy( | 244 EvalResult result = policy_base_->EvalPolicy( |
243 IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase()); | 245 IPC_NTQUERYFULLATTRIBUTESFILE_TAG, params.GetBase()); |
(...skipping 12 matching lines...) Expand all Loading... |
256 | 258 |
257 // Return operation status on the IPC. | 259 // Return operation status on the IPC. |
258 ipc->return_info.nt_status = nt_status; | 260 ipc->return_info.nt_status = nt_status; |
259 return true; | 261 return true; |
260 } | 262 } |
261 | 263 |
262 bool FilesystemDispatcher::NtSetInformationFile(IPCInfo* ipc, | 264 bool FilesystemDispatcher::NtSetInformationFile(IPCInfo* ipc, |
263 HANDLE handle, | 265 HANDLE handle, |
264 CountedBuffer* status, | 266 CountedBuffer* status, |
265 CountedBuffer* info, | 267 CountedBuffer* info, |
266 uint32 length, | 268 uint32_t length, |
267 uint32 info_class) { | 269 uint32_t info_class) { |
268 if (sizeof(IO_STATUS_BLOCK) != status->Size()) | 270 if (sizeof(IO_STATUS_BLOCK) != status->Size()) |
269 return false; | 271 return false; |
270 if (length != info->Size()) | 272 if (length != info->Size()) |
271 return false; | 273 return false; |
272 | 274 |
273 FILE_RENAME_INFORMATION* rename_info = | 275 FILE_RENAME_INFORMATION* rename_info = |
274 reinterpret_cast<FILE_RENAME_INFORMATION*>(info->Buffer()); | 276 reinterpret_cast<FILE_RENAME_INFORMATION*>(info->Buffer()); |
275 | 277 |
276 if (!IsSupportedRenameCall(rename_info, length, info_class)) | 278 if (!IsSupportedRenameCall(rename_info, length, info_class)) |
277 return false; | 279 return false; |
278 | 280 |
279 base::string16 name; | 281 base::string16 name; |
280 name.assign(rename_info->FileName, rename_info->FileNameLength / | 282 name.assign(rename_info->FileName, rename_info->FileNameLength / |
281 sizeof(rename_info->FileName[0])); | 283 sizeof(rename_info->FileName[0])); |
282 if (!PreProcessName(&name)) { | 284 if (!PreProcessName(&name)) { |
283 // The path requested might contain a reparse point. | 285 // The path requested might contain a reparse point. |
284 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 286 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
285 return true; | 287 return true; |
286 } | 288 } |
287 | 289 |
288 uint32 broker = TRUE; | 290 uint32_t broker = TRUE; |
289 const wchar_t* filename = name.c_str(); | 291 const wchar_t* filename = name.c_str(); |
290 CountedParameterSet<FileName> params; | 292 CountedParameterSet<FileName> params; |
291 params[FileName::NAME] = ParamPickerMake(filename); | 293 params[FileName::NAME] = ParamPickerMake(filename); |
292 params[FileName::BROKER] = ParamPickerMake(broker); | 294 params[FileName::BROKER] = ParamPickerMake(broker); |
293 | 295 |
294 // To evaluate the policy we need to call back to the policy object. We | 296 // To evaluate the policy we need to call back to the policy object. We |
295 // are just middlemen in the operation since is the FileSystemPolicy which | 297 // are just middlemen in the operation since is the FileSystemPolicy which |
296 // knows what to do. | 298 // knows what to do. |
297 EvalResult result = policy_base_->EvalPolicy(IPC_NTSETINFO_RENAME_TAG, | 299 EvalResult result = policy_base_->EvalPolicy(IPC_NTSETINFO_RENAME_TAG, |
298 params.GetBase()); | 300 params.GetBase()); |
299 | 301 |
300 IO_STATUS_BLOCK* io_status = | 302 IO_STATUS_BLOCK* io_status = |
301 reinterpret_cast<IO_STATUS_BLOCK*>(status->Buffer()); | 303 reinterpret_cast<IO_STATUS_BLOCK*>(status->Buffer()); |
302 NTSTATUS nt_status; | 304 NTSTATUS nt_status; |
303 if (!FileSystemPolicy::SetInformationFileAction(result, *ipc->client_info, | 305 if (!FileSystemPolicy::SetInformationFileAction(result, *ipc->client_info, |
304 handle, rename_info, length, | 306 handle, rename_info, length, |
305 info_class, io_status, | 307 info_class, io_status, |
306 &nt_status)) { | 308 &nt_status)) { |
307 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; | 309 ipc->return_info.nt_status = STATUS_ACCESS_DENIED; |
308 return true; | 310 return true; |
309 } | 311 } |
310 | 312 |
311 // Return operation status on the IPC. | 313 // Return operation status on the IPC. |
312 ipc->return_info.nt_status = nt_status; | 314 ipc->return_info.nt_status = nt_status; |
313 return true; | 315 return true; |
314 } | 316 } |
315 | 317 |
316 } // namespace sandbox | 318 } // namespace sandbox |
OLD | NEW |