linux-user: Add getsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
Add handlers for both sockopts which use 64-bit time_t from userspace. Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/885 Signed-off-by: Helge Deller <deller@gmx.de>
Helge Deller committed
Apr 24, 2026 at 10:51 UTC
07c7decaa54a83bd1656b2645074380714b83374
1 file changed
+14
-6
linux-user/syscall.c
+14
-6
@@ -2621,7 +2621,8 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
2621
/* These don't just return a single integer */
2622
case TARGET_SO_PEERNAME:
2623
goto unimplemented;
2624
- case TARGET_SO_RCVTIMEO: {
2624
+ case TARGET_SO_RCVTIMEO:
2625
+ case TARGET_SO_RCVTIMEO_NEW: {
2626
struct timeval tv;
2627
socklen_t tvlen;
2628
@@ -2641,11 +2642,17 @@ get_timeout:
2642
if (ret < 0) {
2643
return ret;
2644
}
2644
- if (len > sizeof(struct target_timeval)) {
2645
- len = sizeof(struct target_timeval);
2646
- }
2647
- if (copy_to_user_timeval(optval_addr, &tv)) {
2648
- return -TARGET_EFAULT;
2645
+ if (len == sizeof(struct target__kernel_sock_timeval)) {
2646
+ if (copy_to_user_timeval64(optval_addr, &tv)) {
2647
+ return -TARGET_EFAULT;
2648
+ }
2649
+ } else {
2650
+ if (len >= sizeof(struct target_timeval)) {
2651
+ len = sizeof(struct target_timeval);
2652
+ if (copy_to_user_timeval(optval_addr, &tv)) {
2653
+ return -TARGET_EFAULT;
2654
+ }
2655
+ }
2656
}
2657
if (put_user_u32(len, optlen)) {
2658
return -TARGET_EFAULT;
@@ -2653,6 +2660,7 @@ get_timeout:
2660
break;
2661
}
2662
case TARGET_SO_SNDTIMEO:
2663
+ case TARGET_SO_SNDTIMEO_NEW:
2664
optname = SO_SNDTIMEO;
2665
goto get_timeout;
2666
case TARGET_SO_PEERCRED: {