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

Unified Diff: sandbox/linux/services/syscall_wrappers.cc

Issue 1310773006: Update sandbox/linux from upstream (Closed) Base URL: ssh://ssh.github.com/domokit/mojo.git@master
Patch Set: Update to 3909ebfa69566f7374a6900e63cd4d3c73a35378 Created 5 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sandbox/linux/services/scoped_process_unittest.cc ('k') | sandbox/linux/services/thread_helpers.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sandbox/linux/services/syscall_wrappers.cc
diff --git a/sandbox/linux/services/syscall_wrappers.cc b/sandbox/linux/services/syscall_wrappers.cc
index 264eb6842d332f450e352ae1109a284402f29787..1984288d78906d1b9e69cbcd3c2cb5c2b5e1c8e4 100644
--- a/sandbox/linux/services/syscall_wrappers.cc
+++ b/sandbox/linux/services/syscall_wrappers.cc
@@ -141,9 +141,12 @@ int sys_unshare(int flags) {
int sys_sigprocmask(int how, const sigset_t* set, decltype(nullptr) oldset) {
// In some toolchain (in particular Android and PNaCl toolchain),
- // sigset_t is 32 bits, but Linux ABI requires 64 bits.
- uint64_t linux_value = 0;
- std::memcpy(&linux_value, set, std::min(sizeof(sigset_t), sizeof(uint64_t)));
+ // sigset_t is 32 bits, but the Linux ABI uses more.
+ LinuxSigSet linux_value;
+ std::memset(&linux_value, 0, sizeof(LinuxSigSet));
+ std::memcpy(&linux_value, set, std::min(sizeof(sigset_t),
+ sizeof(LinuxSigSet)));
+
return syscall(__NR_rt_sigprocmask, how, &linux_value, nullptr,
sizeof(linux_value));
}
@@ -186,14 +189,6 @@ int sys_sigaction(int signum,
return sigaction(signum, act, oldact);
}
#else
-// struct sigaction is different ABI from the Linux's.
-struct KernelSigAction {
- void (*kernel_handler)(int);
- uint32_t sa_flags;
- void (*sa_restorer)(void);
- uint64_t sa_mask;
-};
-
// On X86_64 arch, it is necessary to set sa_restorer always.
#if defined(ARCH_CPU_X86_64)
#if !defined(SA_RESTORER)
@@ -213,30 +208,32 @@ static __attribute__((naked)) void sys_rt_sigreturn() {
int sys_sigaction(int signum,
const struct sigaction* act,
struct sigaction* oldact) {
- KernelSigAction kernel_act = {};
+ LinuxSigAction linux_act = {};
if (act) {
- kernel_act.kernel_handler = act->sa_handler;
- std::memcpy(&kernel_act.sa_mask, &act->sa_mask,
- std::min(sizeof(kernel_act.sa_mask), sizeof(act->sa_mask)));
- kernel_act.sa_flags = act->sa_flags;
+ linux_act.kernel_handler = act->sa_handler;
+ std::memcpy(&linux_act.sa_mask, &act->sa_mask,
+ std::min(sizeof(linux_act.sa_mask), sizeof(act->sa_mask)));
+ linux_act.sa_flags = act->sa_flags;
#if defined(ARCH_CPU_X86_64)
- if (!(kernel_act.sa_flags & SA_RESTORER)) {
- kernel_act.sa_flags |= SA_RESTORER;
- kernel_act.sa_restorer = sys_rt_sigreturn;
+ if (!(linux_act.sa_flags & SA_RESTORER)) {
+ linux_act.sa_flags |= SA_RESTORER;
+ linux_act.sa_restorer = sys_rt_sigreturn;
}
#endif
}
- KernelSigAction kernel_oldact = {};
- int result = syscall(__NR_rt_sigaction, signum, act ? &kernel_act : nullptr,
- oldact ? &kernel_oldact : nullptr, sizeof(uint64_t));
+ LinuxSigAction linux_oldact = {};
+ int result = syscall(__NR_rt_sigaction, signum, act ? &linux_act : nullptr,
+ oldact ? &linux_oldact : nullptr,
+ sizeof(LinuxSigSet));
+
if (result == 0 && oldact) {
- oldact->sa_handler = kernel_oldact.kernel_handler;
+ oldact->sa_handler = linux_oldact.kernel_handler;
sigemptyset(&oldact->sa_mask);
- std::memcpy(&oldact->sa_mask, &kernel_oldact.sa_mask,
- std::min(sizeof(kernel_act.sa_mask), sizeof(act->sa_mask)));
- oldact->sa_flags = kernel_oldact.sa_flags;
+ std::memcpy(&oldact->sa_mask, &linux_oldact.sa_mask,
+ std::min(sizeof(linux_act.sa_mask), sizeof(act->sa_mask)));
+ oldact->sa_flags = linux_oldact.sa_flags;
}
return result;
}
« no previous file with comments | « sandbox/linux/services/scoped_process_unittest.cc ('k') | sandbox/linux/services/thread_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698