Skip to content

Commit 74e43b0

Browse files
pm215vivier
authored andcommitted
linux-user: Check lock_user result for ip_mreq_source sockopts
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 <[email protected]> Reviewed-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Laurent Vivier <[email protected]> Message-Id: <[email protected]> Signed-off-by: Laurent Vivier <[email protected]>
1 parent d0a7920 commit 74e43b0

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

linux-user/syscall.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,6 +2127,9 @@ static abi_long do_setsockopt(int sockfd, int level, int optname,
21272127
return -TARGET_EINVAL;
21282128

21292129
ip_mreq_source = lock_user(VERIFY_READ, optval_addr, optlen, 1);
2130+
if (!ip_mreq_source) {
2131+
return -TARGET_EFAULT;
2132+
}
21302133
ret = get_errno(setsockopt(sockfd, level, optname, ip_mreq_source, optlen));
21312134
unlock_user (ip_mreq_source, optval_addr, 0);
21322135
break;

0 commit comments

Comments
 (0)