All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] linux-user: Correct host errno for IP[V6]_RECVERR socket options
@ 2021-09-07 11:13 Philippe Mathieu-Daudé
  2021-09-07 11:19 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-07 11:13 UTC (permalink / raw)
  To: qemu-devel
  Cc: Helge Deller, Conrad Meyer, Laurent Vivier, Philippe Mathieu-Daudé

Target errno should be converted to host errno in IP_RECVERR
and IPV6_RECVERR socket options.

Fixes: ee1ac3a1822 ("linux-user: Add sockopts for IPv6")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/602
Reported-by: Conrad Meyer <cem@FreeBSD.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 linux-user/syscall.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ccd3892b2df..edc9d6b5ba2 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1967,7 +1967,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
                     tgt_len != sizeof(struct errhdr_t)) {
                     goto unimplemented;
                 }
-                __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
+                __put_user(get_errno(errh->ee.ee_errno),
+                           &target_errh->ee.ee_errno);
                 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
                 __put_user(errh->ee.ee_type,  &target_errh->ee.ee_type);
                 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
@@ -2011,7 +2012,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
                     tgt_len != sizeof(struct errhdr6_t)) {
                     goto unimplemented;
                 }
-                __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
+                __put_user(get_errno(errh->ee.ee_errno),
+                           &target_errh->ee.ee_errno);
                 __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
                 __put_user(errh->ee.ee_type,  &target_errh->ee.ee_type);
                 __put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
-- 
2.31.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] linux-user: Correct host errno for IP[V6]_RECVERR socket options
  2021-09-07 11:13 [PATCH] linux-user: Correct host errno for IP[V6]_RECVERR socket options Philippe Mathieu-Daudé
@ 2021-09-07 11:19 ` Philippe Mathieu-Daudé
  0 siblings, 0 replies; 2+ messages in thread
From: Philippe Mathieu-Daudé @ 2021-09-07 11:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: Helge Deller, Laurent Vivier, Conrad Meyer

On 9/7/21 1:13 PM, Philippe Mathieu-Daudé wrote:
> Target errno should be converted to host errno in IP_RECVERR
> and IPV6_RECVERR socket options.

I meant "Host errno must be converted to target errno ..."

> Fixes: ee1ac3a1822 ("linux-user: Add sockopts for IPv6")
> Resolves: https://gitlab.com/qemu-project/qemu/-/issues/602
> Reported-by: Conrad Meyer <cem@FreeBSD.org>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  linux-user/syscall.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ccd3892b2df..edc9d6b5ba2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1967,7 +1967,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
>                      tgt_len != sizeof(struct errhdr_t)) {
>                      goto unimplemented;
>                  }
> -                __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
> +                __put_user(get_errno(errh->ee.ee_errno),
> +                           &target_errh->ee.ee_errno);
>                  __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
>                  __put_user(errh->ee.ee_type,  &target_errh->ee.ee_type);
>                  __put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
> @@ -2011,7 +2012,8 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh,
>                      tgt_len != sizeof(struct errhdr6_t)) {
>                      goto unimplemented;
>                  }
> -                __put_user(errh->ee.ee_errno, &target_errh->ee.ee_errno);
> +                __put_user(get_errno(errh->ee.ee_errno),
> +                           &target_errh->ee.ee_errno);
>                  __put_user(errh->ee.ee_origin, &target_errh->ee.ee_origin);
>                  __put_user(errh->ee.ee_type,  &target_errh->ee.ee_type);
>                  __put_user(errh->ee.ee_code, &target_errh->ee.ee_code);
> 


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-07 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-07 11:13 [PATCH] linux-user: Correct host errno for IP[V6]_RECVERR socket options Philippe Mathieu-Daudé
2021-09-07 11:19 ` Philippe Mathieu-Daudé

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.