* [PATCH v2] linux-user: allow NULL msg in recvfrom
@ 2021-03-27 2:11 Zach Reizner
2021-03-27 9:11 ` Laurent Vivier
0 siblings, 1 reply; 2+ messages in thread
From: Zach Reizner @ 2021-03-27 2:11 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier, peter.maydell
The kernel allows a NULL msg in recvfrom so that he size of the next
message may be queried before allocating a correctly sized buffer. This
change allows the syscall translator to pass along the NULL msg pointer
instead of returning early with EFAULT.
Signed-off-by: Zach Reizner <zachr@google.com>
---
v2:
- return -TARGET_EFAULT on non-null invalid msg pointer
linux-user/syscall.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1e508576c7..294779c86f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3679,9 +3679,14 @@ static abi_long do_recvfrom(int fd, abi_ulong
msg, size_t len, int flags,
void *host_msg;
abi_long ret;
- host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
- if (!host_msg)
- return -TARGET_EFAULT;
+ if (!msg) {
+ host_msg = NULL;
+ } else {
+ host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
+ if (!host_msg) {
+ return -TARGET_EFAULT;
+ }
+ }
if (target_addr) {
if (get_user_u32(addrlen, target_addrlen)) {
ret = -TARGET_EFAULT;
--
2.31.0.291.g576ba9dcdaf-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] linux-user: allow NULL msg in recvfrom
2021-03-27 2:11 [PATCH v2] linux-user: allow NULL msg in recvfrom Zach Reizner
@ 2021-03-27 9:11 ` Laurent Vivier
0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2021-03-27 9:11 UTC (permalink / raw)
To: Zach Reizner, qemu-devel; +Cc: peter.maydell
Le 27/03/2021 à 03:11, Zach Reizner a écrit :
> The kernel allows a NULL msg in recvfrom so that he size of the next
> message may be queried before allocating a correctly sized buffer. This
> change allows the syscall translator to pass along the NULL msg pointer
> instead of returning early with EFAULT.
>
> Signed-off-by: Zach Reizner <zachr@google.com>
> ---
> v2:
> - return -TARGET_EFAULT on non-null invalid msg pointer
>
> linux-user/syscall.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 1e508576c7..294779c86f 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3679,9 +3679,14 @@ static abi_long do_recvfrom(int fd, abi_ulong
> msg, size_t len, int flags,
> void *host_msg;
> abi_long ret;
>
> - host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
> - if (!host_msg)
> - return -TARGET_EFAULT;
> + if (!msg) {
> + host_msg = NULL;
> + } else {
> + host_msg = lock_user(VERIFY_WRITE, msg, len, 0);
> + if (!host_msg) {
> + return -TARGET_EFAULT;
> + }
> + }
> if (target_addr) {
> if (get_user_u32(addrlen, target_addrlen)) {
> ret = -TARGET_EFAULT;
>
Reviewed-by: Laurent Vivier <laurent@vivier.eu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-27 9:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 2:11 [PATCH v2] linux-user: allow NULL msg in recvfrom Zach Reizner
2021-03-27 9:11 ` Laurent Vivier
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.