diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2016-07-12 13:02:13 +0100 |
---|---|---|
committer | Riku Voipio <riku.voipio@linaro.org> | 2016-09-21 14:26:46 +0300 |
commit | 3211215e741f6e4824ddfc4919428e8d1b82a3c2 (patch) | |
tree | 9bb45e35c26d562237e8d4f40f485e10756f51a6 /linux-user | |
parent | 68754b442b756e8cb5f143b00937fb7330a51a81 (diff) |
linux-user: Check lock_user() return value for NULL
lock_user() can return NULL, which typically means the syscall
should fail with EFAULT. Add checks in various places where
Coverity spotted that we were missing them.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user')
-rw-r--r-- | linux-user/syscall.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 7a50a57d4b..efcc17a3b0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5008,6 +5008,11 @@ static abi_long do_ioctl_dm(const IOCTLEntry *ie, uint8_t *buf_temp, int fd, host_data = (char*)host_dm + host_dm->data_start; argptr = lock_user(VERIFY_READ, guest_data, guest_data_size, 1); + if (!argptr) { + ret = -TARGET_EFAULT; + goto out; + } + switch (ie->host_cmd) { case DM_REMOVE_ALL: case DM_LIST_DEVICES: @@ -11271,6 +11276,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_mq_unlink: p = lock_user_string(arg1 - 1); + if (!p) { + ret = -TARGET_EFAULT; + break; + } ret = get_errno(mq_unlink(p)); unlock_user (p, arg1, 0); break; |