linux-user/syscall.c: Let lv always match val in do_getsockopt()
PATCH 1/1 linux-user/syscall.c: Let lv always match val in do_getsockopt()
From: Chen Gang <[email protected]>
After host_to_target_sock_type(), the length of val may be changed, so calculate the related lv, too.
--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)
linux-user/syscall.c +1 -0
@@ -1841,6 +1841,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,return ret;if (optname ==SO_TYPE ) { val =host_to_target_sock_type (val); + lv = (val >>8 ) ?4 :1 ; }if (len > lv) len = lv;
Signature · 1 line
1.9.1
Quoted 15 lines · Le 14/01/2016 07:24, [email protected] a écrit :
From: Chen Gang <[email protected]>
After
host_to_target_sock_type(), the length of val may be changed, so calculate the related lv, too.Signed-off-by Chen Gang <[email protected]>--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)linux-user/syscall.c +0
-0
linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 1844
Quoted 4 lines
linux-user/syscall.c +1
-0@@ -1841,6 +1841,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,return ret;if (optname ==SO_TYPE ) { val =host_to_target_sock_type (val); + lv = (val >>8 ) ?4 :1 ;
It seems the kernel always returns sizeof(int) (for all archs), what is the aim of reducing the size ?
Quoted 4 lines
linux-user/syscall.c +0
-0}if (len > lv) len = lv;
Quoted 11 lines · Laurent Vivier
Quoted 10 lines · Le 14/01/2016 07:24, [email protected] a écrit :
From: Chen Gang <[email protected]>
After
host_to_target_sock_type(), the length of val may be changed, so calculate the related lv, too.Signed-off-by Chen Gang <[email protected]>--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)
Quoted 13 lines
linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 1844
Quoted 9 lines
linux-user/syscall.c +1
-0@@ -1841,6 +1841,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,return ret;if (optname ==SO_TYPE ) { val =host_to_target_sock_type (val); + lv = (val >>8 ) ?4 :1 ;It seems the kernel always returns sizeof(int) (for all archs), what is the aim of reducing the size ?
I am not quite sure whether kernel always returns sizeof(int) (I guess, it should be).
For me, if you are sure, we can skip this patch.
Thanks.
Signature · 3 lines
Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed
Quoted 26 lines · Chen Gang
Quoted 11 lines · Laurent Vivier
Quoted 10 lines · Le 14/01/2016 07:24, [email protected] a écrit :
From: Chen Gang <[email protected]>
After
host_to_target_sock_type(), the length of val may be changed, so calculate the related lv, too.Signed-off-by Chen Gang <[email protected]>--- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+)Quoted 13 lines
linux-user/syscall.c static abi_long do_getsockopt(int sockfd, int level, int optname, · line 1844
Quoted 9 lines
linux-user/syscall.c +1
-0@@ -1841,6 +1841,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,return ret;if (optname ==SO_TYPE ) { val =host_to_target_sock_type (val); + lv = (val >>8 ) ?4 :1 ;It seems the kernel always returns sizeof(int) (for all archs), what is the aim of reducing the size ?
Quoted 2 lines
I am not quite sure whether kernel always returns sizeof(int) (I guess, it should be).
it can be 1 only if len is 1, but this is managed below.
Quoted 1 line
For me, if you are sure, we can skip this patch.
Does it fix something ?
Laurent
Quoted 8 lines · Laurent Vivier
Quoted 3 lines · Chen Gang
I am not quite sure whether kernel always returns sizeof(int) (I guess, it should be).
it can be 1 only if len is 1, but this is managed below.
Excuse me, I do not quite understand your meaning.
For me, if we are sure lv is always 4 for SO_TYPE, we don't need this patch.
If lv may be 1 for SO_TYPE (it means val >> 8 may be zero), after call host_to_target_sock_type, val >> 8 may be non-zero, theoretically. In this case, we need modify lv to 4.
Quoted 4 lines
Quoted 1 line
For me, if you are sure, we can skip this patch.
Does it fix something ?
It is only theoretical, not real world, at present.
Thanks.
Signature · 3 lines
Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed
Quoted 20 lines · Chen Gang
Quoted 8 lines · Laurent Vivier
Quoted 3 lines · Chen Gang
I am not quite sure whether kernel always returns sizeof(int) (I guess, it should be).
it can be 1 only if len is 1, but this is managed below.
Excuse me, I do not quite understand your meaning.
For me, if we are sure lv is always 4 for
SO_TYPE, we don't need this patch.If lv may be 1 for
SO_TYPE(it means val >> 8 may be zero), after callhost_to_target_sock_type, val >> 8 may be non-zero, theoretically. In this case, we need modify lv to 4.
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
For me, if you are sure, we can skip this patch.
Does it fix something ?
It is only theoretical, not real world, at present.
So I think we can skip it.
Laurent
Quoted 22 lines · Laurent Vivier
Quoted 20 lines · Chen Gang
Quoted 8 lines · Laurent Vivier
Quoted 3 lines · Chen Gang
I am not quite sure whether kernel always returns sizeof(int) (I guess, it should be).
it can be 1 only if len is 1, but this is managed below.
Excuse me, I do not quite understand your meaning.
For me, if we are sure lv is always 4 for
SO_TYPE, we don't need this patch.If lv may be 1 for
SO_TYPE(it means val >> 8 may be zero), after callhost_to_target_sock_type, val >> 8 may be non-zero, theoretically. In this case, we need modify lv to 4.
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
For me, if you are sure, we can skip this patch.
Does it fix something ?
It is only theoretical, not real world, at present.
So I think we can skip it.
It is OK to me.
Thanks.
Signature · 3 lines
Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed