Changeset 187030 in webkit
- Timestamp:
- Jul 20, 2015 1:06:27 PM (9 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r187029 r187030 1 2015-07-20 Michael Catanzaro <mcatanzaro@igalia.com> 2 3 [Seccomp] Should be easier to debug blocked syscalls 4 https://bugs.webkit.org/show_bug.cgi?id=142980 5 6 These should be printed even when not running in debug mode. There is no 7 value in hiding errors from release build users. 8 9 Reviewed by Žan Doberšek. 10 11 * Shared/linux/SeccompFilters/SeccompBroker.cpp: 12 (WebKit::SeccompBroker::runLoop): Don't close stderr et. al. in release builds. 13 * Shared/linux/SeccompFilters/Syscall.cpp: 14 (WebKit::write_uint): Added. 15 (WebKit::reportUnexpectedSyscall): Added. 16 (WebKit::Syscall::createFromContext): Call reportUnexpectedSyscall. Also, no need to crash 17 here in release builds. 18 * Shared/linux/SeccompFilters/SyscallPolicy.cpp: 19 (WebKit::SyscallPolicy::hasPermissionForPath): Print a warning when access is denied. 20 (WebKit::SyscallPolicy::permissionToString): Added. 21 * Shared/linux/SeccompFilters/SyscallPolicy.h: Add permissionToString. 22 1 23 2015-07-20 Csaba Osztrogonác <ossy@webkit.org> 2 24 -
trunk/Source/WebKit2/Shared/linux/SeccompFilters/SeccompBroker.cpp
r186839 r187030 321 321 NO_RETURN void SeccompBroker::runLoop(int socket) 322 322 { 323 #ifndef NDEBUG 324 int i = STDERR_FILENO + 1; 325 #else 326 int i = 0; 327 #endif 328 // Close all inherited file descriptors other 329 // than the socket to the sandboxed process. 330 for (; i < FD_SETSIZE; ++i) 323 // Close unnecessary inherited file descriptors. 324 for (int i = STDERR_FILENO + 1; i < FD_SETSIZE; ++i) { 331 325 if (i != socket) 332 326 close(i); 327 } 333 328 334 329 while (true) { -
trunk/Source/WebKit2/Shared/linux/SeccompFilters/Syscall.cpp
r161156 r187030 1 1 /* 2 2 * Copyright (C) 2013 Intel Corporation. All rights reserved. 3 * Copyright (C) 2015 Igalia S.L. 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 33 34 #include "SigactionSyscall.h" 34 35 #include "SigprocmaskSyscall.h" 36 #include <limits> 35 37 #include <seccomp.h> 38 #include <string.h> 39 #include <unistd.h> 36 40 37 41 namespace WebKit { 42 43 // The redundant "constexpr const" is to placate Clang's -Wwritable-strings. 44 static constexpr const char* const message = "Blocked unexpected syscall: "; 45 46 // Since "sprintf" is not signal-safe, reimplement %d here. Based on code from 47 // http://outflux.net/teach-seccomp by Will Drewry and Kees Cook, released under 48 // the Chromium BSD license. 49 static void writeUnsignedInt(char* buf, unsigned val) 50 { 51 int width = 0; 52 unsigned tens; 53 54 if (!val) { 55 strcpy(buf, "0"); 56 return; 57 } 58 for (tens = val; tens; tens /= 10) 59 ++width; 60 buf[width] = '\0'; 61 for (tens = val; tens; tens /= 10) 62 buf[--width] = '0' + (tens % 10); 63 } 64 65 static void reportUnexpectedSyscall(int syscall) 66 { 67 char buf[128]; 68 #if defined(__has_builtin) && __has_builtin(__builtin_strlen) 69 static_assert(__builtin_strlen(message) + std::numeric_limits<int>::digits10 + 1 < sizeof(buf), "Buffer too small"); 70 #endif 71 strcpy(buf, message); 72 writeUnsignedInt(buf + strlen(buf), syscall); 73 strcat(buf, "\n"); 74 write(STDERR_FILENO, buf, strlen(buf)); 75 } 38 76 39 77 std::unique_ptr<Syscall> Syscall::createFromContext(ucontext_t* ucontext) … … 55 93 return SigactionSyscall::createFromContext(mcontext); 56 94 default: 57 CRASH(); 95 reportUnexpectedSyscall(mcontext->gregs[REG_SYSCALL]); 96 ASSERT_NOT_REACHED(); 58 97 } 59 98 -
trunk/Source/WebKit2/Shared/linux/SeccompFilters/SyscallPolicy.cpp
r186810 r187030 98 98 free(canonicalPath); 99 99 100 return (permission & policy->value) == permission; 100 if ((permission & policy->value) == permission) 101 return true; 102 103 // Don't warn if the file doesn't exist at all. 104 if (!access(path, F_OK) || errno != ENOENT) 105 fprintf(stderr, "Blocked impermissible %s access to %s\n", SyscallPolicy::permissionToString(permission), path); 106 return false; 101 107 } 102 108 … … 257 263 } 258 264 265 const char* SyscallPolicy::permissionToString(Permission permission) 266 { 267 switch (permission) { 268 case Read: 269 return "read"; 270 case Write: 271 return "write"; 272 case ReadAndWrite: 273 return "read/write"; 274 case NotAllowed: 275 return "disallowed"; 276 } 277 278 ASSERT_NOT_REACHED(); 279 return "unknown action"; 280 } 281 259 282 } // namespace WebKit 260 283 -
trunk/Source/WebKit2/Shared/linux/SeccompFilters/SyscallPolicy.h
r186893 r187030 53 53 void addDefaultWebProcessPolicy(const WebProcessCreationParameters&); 54 54 55 static const char* permissionToString(Permission); 56 55 57 private: 56 58 typedef HashMap<String, int> PermissionMap;
Note: See TracChangeset
for help on using the changeset viewer.