[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/8] linux-user: Check lock_user() return value for
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [PATCH 2/8] linux-user: Check lock_user() return value for NULL |
Date: |
Tue, 12 Jul 2016 13:02:13 +0100 |
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 <address@hidden>
---
linux-user/syscall.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2e71879..b868fb9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4512,6 +4512,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:
@@ -10768,6 +10773,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;
--
1.9.1
- [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 1/8] linux-user: Pass missing MAP_ANONYMOUS to target_mmap() call, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 2/8] linux-user: Check lock_user() return value for NULL,
Peter Maydell <=
- [Qemu-devel] [PATCH 5/8] linux-user: Don't write off end of new_utsname buffer, Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 7/8] linux-user: Use glib malloc functions in load_symbols(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 6/8] linux-user: Check dump_write() return in elf_core_dump(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 4/8] linux-user: Fix error handling in flatload.c target_pread(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 3/8] linux-user: Fix incorrect use of host errno in do_ioctl_dm(), Peter Maydell, 2016/07/12
- [Qemu-devel] [PATCH 8/8] linux-user: Fix memchr() argument in open_self_cmdline(), Peter Maydell, 2016/07/12
- Re: [Qemu-devel] [PATCH 0/8] linux-user: fix various coverity nits, Paolo Bonzini, 2016/07/12