From: Helge Deller <deller@kernel.org>
To: laurent@vivier.eu, qemu-devel@nongnu.org
Cc: deller@gmx.de
Subject: [PATCH 4/4] linux-user: Add getsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW
Date: Fri, 24 Apr 2026 11:08:50 +0200 [thread overview]
Message-ID: <20260424091024.23495-5-deller@kernel.org> (raw)
In-Reply-To: <20260424091024.23495-1-deller@kernel.org>
From: Helge Deller <deller@gmx.de>
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>
---
linux-user/syscall.c | 20 ++++++++++++++------
1 file changed, 14 insertions(+), 6 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7bd5ad548b..a75dbceb5c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2621,7 +2621,8 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
/* These don't just return a single integer */
case TARGET_SO_PEERNAME:
goto unimplemented;
- case TARGET_SO_RCVTIMEO: {
+ case TARGET_SO_RCVTIMEO:
+ case TARGET_SO_RCVTIMEO_NEW: {
struct timeval tv;
socklen_t tvlen;
@@ -2641,11 +2642,17 @@ get_timeout:
if (ret < 0) {
return ret;
}
- if (len > sizeof(struct target_timeval)) {
- len = sizeof(struct target_timeval);
- }
- if (copy_to_user_timeval(optval_addr, &tv)) {
- return -TARGET_EFAULT;
+ if (len == sizeof(struct target__kernel_sock_timeval)) {
+ if (copy_to_user_timeval64(optval_addr, &tv)) {
+ return -TARGET_EFAULT;
+ }
+ } else {
+ if (len >= sizeof(struct target_timeval)) {
+ len = sizeof(struct target_timeval);
+ if (copy_to_user_timeval(optval_addr, &tv)) {
+ return -TARGET_EFAULT;
+ }
+ }
}
if (put_user_u32(len, optlen)) {
return -TARGET_EFAULT;
@@ -2653,6 +2660,7 @@ get_timeout:
break;
}
case TARGET_SO_SNDTIMEO:
+ case TARGET_SO_SNDTIMEO_NEW:
optname = SO_SNDTIMEO;
goto get_timeout;
case TARGET_SO_PEERCRED: {
--
2.53.0
next prev parent reply other threads:[~2026-04-24 9:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 9:08 linux-user: Add sockopts for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW Helge Deller
2026-04-24 9:08 ` [PATCH 1/4] linux-user: Use int64_t in target__kernel_sock_timeval Helge Deller
2026-04-24 22:14 ` Richard Henderson
2026-04-24 22:37 ` Helge Deller
2026-04-24 9:08 ` [PATCH 2/4] linux-user: Define SO_TIMESTAMP*_NEW and SO_RCVTIMEIO_NEW Helge Deller
2026-04-24 9:08 ` [PATCH 3/4] linux-user: Add setsockopt() for SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW Helge Deller
2026-04-24 9:08 ` Helge Deller [this message]
2026-04-30 16:34 ` linux-user: Add sockopts " Michael Tokarev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260424091024.23495-5-deller@kernel.org \
--to=deller@kernel.org \
--cc=deller@gmx.de \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.