]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: Check lock_user result for ip_mreq_source sockopts
authorPeter Maydell <peter.maydell@linaro.org>
Mon, 9 Aug 2021 15:54:24 +0000 (16:54 +0100)
committerLaurent Vivier <laurent@vivier.eu>
Thu, 16 Sep 2021 15:04:21 +0000 (17:04 +0200)
In do_setsockopt(), the code path for the options which take a struct
ip_mreq_source (IP_BLOCK_SOURCE, IP_UNBLOCK_SOURCE,
IP_ADD_SOURCE_MEMBERSHIP and IP_DROP_SOURCE_MEMBERSHIP) fails to
check the return value from lock_user().  Handle this in the usual
way by returning -TARGET_EFAULT.

(In practice this was probably harmless because we'd pass a NULL
pointer to setsockopt() and the kernel would then return EFAULT.)

Fixes: Coverity CID 1459987
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
Message-Id: <20210809155424.30968-1-peter.maydell@linaro.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
linux-user/syscall.c

index e4ffdec0d83c6d09be422459c955ac6ee600da0c..544f5b662ffeceb108a79836deb116a90b464374 100644 (file)
@@ -2127,6 +2127,9 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
                 return -TARGET_EINVAL;
 
             ip_mreq_source = lock_user(VERIFY_READ, optval_addr, optlen, 1);
+            if (!ip_mreq_source) {
+                return -TARGET_EFAULT;
+            }
             ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen));
             unlock_user (ip_mreq_source, optval_addr, 0);
             break;