qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt()
@ 2009-06-01 21:57 Laurent Vivier
  2009-06-10 21:42 ` Riku Voipio
  0 siblings, 1 reply; 3+ messages in thread
From: Laurent Vivier @ 2009-06-01 21:57 UTC (permalink / raw)
  To: qemu-devel; +Cc: Laurent Vivier

This issue has been detected with tests/linux-tests.c:

linux-test.c:330: getsockopt

327     len = sizeof(val);
328     chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
329     if (val != SOCK_STREAM)
330         error("getsockopt");

In linux-user/syscall.c:do_getsockopt(), we have:
...
        val = tswap32(val);
...
            if (put_user_u32(val, optval_addr))
...

whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".

So the "val = tswap32(val);" is useless and wrong.

This patch removes it.

Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 linux-user/syscall.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a0915a4..b1bba48 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
-        val = tswap32(val);
         if (len > lv)
             len = lv;
         if (len == 4) {
-- 
1.5.6.5

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

* Re: [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt()
  2009-06-01 21:57 [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt() Laurent Vivier
@ 2009-06-10 21:42 ` Riku Voipio
  2009-06-10 22:19   ` Laurent Vivier
  0 siblings, 1 reply; 3+ messages in thread
From: Riku Voipio @ 2009-06-10 21:42 UTC (permalink / raw)
  To: Laurent Vivier; +Cc: qemu-devel

On Mon, Jun 01, 2009 at 11:57:48PM +0200, Laurent Vivier wrote:
> This issue has been detected with tests/linux-tests.c:
> 
> linux-test.c:330: getsockopt
> 
> 327     len = sizeof(val);
> 328     chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
> 329     if (val != SOCK_STREAM)
> 330         error("getsockopt");
> 
> In linux-user/syscall.c:do_getsockopt(), we have:
> ...
>         val = tswap32(val);
> ...
>             if (put_user_u32(val, optval_addr))
> ...
> 
> whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".

> So the "val = tswap32(val);" is useless and wrong.

> This patch removes it.

makes sense, added to my tree. I think there might be quite a few broken
swapping going around..

> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>  linux-user/syscall.c |    1 -
>  1 files changed, 0 insertions(+), 1 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index a0915a4..b1bba48 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
>          ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
>          if (ret < 0)
>              return ret;
> -        val = tswap32(val);
>          if (len > lv)
>              len = lv;
>          if (len == 4) {
> -- 
> 1.5.6.5
> 
> 

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

* Re: [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt()
  2009-06-10 21:42 ` Riku Voipio
@ 2009-06-10 22:19   ` Laurent Vivier
  0 siblings, 0 replies; 3+ messages in thread
From: Laurent Vivier @ 2009-06-10 22:19 UTC (permalink / raw)
  To: Riku Voipio; +Cc: qemu-devel

Le jeudi 11 juin 2009 à 00:42 +0300, Riku Voipio a écrit :
> On Mon, Jun 01, 2009 at 11:57:48PM +0200, Laurent Vivier wrote:
> > This issue has been detected with tests/linux-tests.c:
> > 
> > linux-test.c:330: getsockopt
> > 
> > 327     len = sizeof(val);
> > 328     chk_error(getsockopt(server_fd, SOL_SOCKET, SO_TYPE, &val, &len));
> > 329     if (val != SOCK_STREAM)
> > 330         error("getsockopt");
> > 
> > In linux-user/syscall.c:do_getsockopt(), we have:
> > ...
> >         val = tswap32(val);
> > ...
> >             if (put_user_u32(val, optval_addr))
> > ...
> > 
> > whereas "put_user_u32" calls in the end "__put_user" which uses "tswap32".
> 
> > So the "val = tswap32(val);" is useless and wrong.
> 
> > This patch removes it.
> 
> makes sense, added to my tree. I think there might be quite a few broken
> swapping going around..

Thank you.

I'd like to see this in the qemu reference git tree, should I resend
it ?

> > Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> > ---
> >  linux-user/syscall.c |    1 -
> >  1 files changed, 0 insertions(+), 1 deletions(-)
> > 
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index a0915a4..b1bba48 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -1273,7 +1273,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
> >          ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
> >          if (ret < 0)
> >              return ret;
> > -        val = tswap32(val);
> >          if (len > lv)
> >              len = lv;
> >          if (len == 4) {
> > -- 
> > 1.5.6.5
> > 

Regards,
Laurent
-- 
--------------------- laurent@vivier.eu ----------------------
"Tout ce qui est impossible reste à accomplir"    Jules Verne
"Things are only impossible until they're not" Jean-Luc Picard

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

end of thread, other threads:[~2009-06-10 22:19 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-01 21:57 [Qemu-devel] [PATCH] linux-user: remove duplicate tswap32() from do_getsockopt() Laurent Vivier
2009-06-10 21:42 ` Riku Voipio
2009-06-10 22:19   ` Laurent Vivier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).