aboutsummaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorPatrick Venture <venture@google.com>2022-01-26 13:25:59 -0800
committerLaurent Vivier <laurent@vivier.eu>2022-01-27 16:58:33 +0100
commitebce1719ac0a2a71b64742ecf1c9ec2497a65a55 (patch)
treedf9607ba59dab089d241824ed7cb44f6599f0b22 /linux-user/syscall.c
parentd3ced2a59a543b3c3fc7dee2e64ee360e9a698cd (diff)
linux-user: sigprocmask check read perms first
Linux kernel now checks the read permissions before validating `how` Suggested-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Patrick Venture <venture@google.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20220126212559.1936290-3-venture@google.com> [lv: remove unneeded ")"] Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 9f8b497fa3..84cfa223df 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9435,6 +9435,13 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
int how;
if (arg2) {
+ p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1);
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ target_to_host_old_sigset(&set, p);
+ unlock_user(p, arg2, 0);
+ set_ptr = &set;
switch (arg1) {
case TARGET_SIG_BLOCK:
how = SIG_BLOCK;
@@ -9448,11 +9455,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
default:
return -TARGET_EINVAL;
}
- if (!(p = lock_user(VERIFY_READ, arg2, sizeof(target_sigset_t), 1)))
- return -TARGET_EFAULT;
- target_to_host_old_sigset(&set, p);
- unlock_user(p, arg2, 0);
- set_ptr = &set;
} else {
how = 0;
set_ptr = NULL;