* [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
@ 2016-01-14 6:24 chengang
2016-01-14 8:15 ` Laurent Vivier
0 siblings, 1 reply; 7+ messages in thread
From: chengang @ 2016-01-14 6:24 UTC (permalink / raw)
To: riku.voipio, laurent; +Cc: peter.maydell, Chen Gang, Chen Gang, qemu-devel, rth
From: Chen Gang <chengang@emindsoft.com.cn>
After host_to_target_sock_type(), the length of val may be changed, so
calculate the related lv, too.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
---
linux-user/syscall.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fcdca2a..0e95f35 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -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;
--
1.9.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 6:24 [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt() chengang
@ 2016-01-14 8:15 ` Laurent Vivier
2016-01-14 9:01 ` Chen Gang
0 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2016-01-14 8:15 UTC (permalink / raw)
To: chengang, riku.voipio; +Cc: peter.maydell, Chen Gang, qemu-devel, rth
Le 14/01/2016 07:24, chengang@emindsoft.com.cn a écrit :
> From: Chen Gang <chengang@emindsoft.com.cn>
>
> After host_to_target_sock_type(), the length of val may be changed, so
> calculate the related lv, too.
>
> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
> ---
> linux-user/syscall.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index fcdca2a..0e95f35 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -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 ?
> }
> if (len > lv)
> len = lv;
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 8:15 ` Laurent Vivier
@ 2016-01-14 9:01 ` Chen Gang
2016-01-14 9:10 ` Laurent Vivier
0 siblings, 1 reply; 7+ messages in thread
From: Chen Gang @ 2016-01-14 9:01 UTC (permalink / raw)
To: Laurent Vivier, riku.voipio; +Cc: peter.maydell, qemu-devel, rth
On 2016年01月14日 16:15, Laurent Vivier wrote:
> Le 14/01/2016 07:24, chengang@emindsoft.com.cn a écrit :
>> From: Chen Gang <chengang@emindsoft.com.cn>
>>
>> After host_to_target_sock_type(), the length of val may be changed, so
>> calculate the related lv, too.
>>
>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>> ---
>> linux-user/syscall.c | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>> index fcdca2a..0e95f35 100644
>> --- a/linux-user/syscall.c
>> +++ b/linux-user/syscall.c
>> @@ -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.
--
Chen Gang (陈刚)
Open, share, and attitude like air, water, and life which God blessed
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 9:01 ` Chen Gang
@ 2016-01-14 9:10 ` Laurent Vivier
2016-01-14 9:37 ` Chen Gang
0 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2016-01-14 9:10 UTC (permalink / raw)
To: Chen Gang, riku.voipio; +Cc: peter.maydell, qemu-devel, rth
Le 14/01/2016 10:01, Chen Gang a écrit :
> On 2016年01月14日 16:15, Laurent Vivier wrote:
>> Le 14/01/2016 07:24, chengang@emindsoft.com.cn a écrit :
>>> From: Chen Gang <chengang@emindsoft.com.cn>
>>>
>>> After host_to_target_sock_type(), the length of val may be changed, so
>>> calculate the related lv, too.
>>>
>>> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
>>> ---
>>> linux-user/syscall.c | 1 +
>>> 1 file changed, 1 insertion(+)
>>>
>>> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
>>> index fcdca2a..0e95f35 100644
>>> --- a/linux-user/syscall.c
>>> +++ b/linux-user/syscall.c
>>> @@ -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).
it can be 1 only if len is 1, but this is managed below.
> For me, if you are sure, we can skip this patch.
Does it fix something ?
Laurent
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 9:10 ` Laurent Vivier
@ 2016-01-14 9:37 ` Chen Gang
2016-01-14 9:41 ` Laurent Vivier
0 siblings, 1 reply; 7+ messages in thread
From: Chen Gang @ 2016-01-14 9:37 UTC (permalink / raw)
To: Laurent Vivier, riku.voipio; +Cc: peter.maydell, qemu-devel, rth
On 2016年01月14日 17:10, Laurent Vivier wrote:
>
> Le 14/01/2016 10:01, Chen Gang a écrit :
>>
>> 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.
>> 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.
--
Chen Gang (陈刚)
Open, share, and attitude like air, water, and life which God blessed
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 9:37 ` Chen Gang
@ 2016-01-14 9:41 ` Laurent Vivier
2016-01-14 9:44 ` Chen Gang
0 siblings, 1 reply; 7+ messages in thread
From: Laurent Vivier @ 2016-01-14 9:41 UTC (permalink / raw)
To: Chen Gang, riku.voipio; +Cc: peter.maydell, qemu-devel, rth
Le 14/01/2016 10:37, Chen Gang a écrit :
>
> On 2016年01月14日 17:10, Laurent Vivier wrote:
>>
>> Le 14/01/2016 10:01, Chen Gang a écrit :
>>>
>>> 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.
>
>>> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt()
2016-01-14 9:41 ` Laurent Vivier
@ 2016-01-14 9:44 ` Chen Gang
0 siblings, 0 replies; 7+ messages in thread
From: Chen Gang @ 2016-01-14 9:44 UTC (permalink / raw)
To: Laurent Vivier, riku.voipio; +Cc: peter.maydell, qemu-devel, rth
On 2016年01月14日 17:41, Laurent Vivier wrote:
>
> Le 14/01/2016 10:37, Chen Gang a écrit :
>>
>> On 2016年01月14日 17:10, Laurent Vivier wrote:
>>>
>>> Le 14/01/2016 10:01, Chen Gang a écrit :
>>>>
>>>> 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.
>>
>>>> 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.
--
Chen Gang (陈刚)
Open, share, and attitude like air, water, and life which God blessed
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2016-01-14 9:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-14 6:24 [Qemu-devel] [PATCH] linux-user/syscall.c: Let lv always match val in do_getsockopt() chengang
2016-01-14 8:15 ` Laurent Vivier
2016-01-14 9:01 ` Chen Gang
2016-01-14 9:10 ` Laurent Vivier
2016-01-14 9:37 ` Chen Gang
2016-01-14 9:41 ` Laurent Vivier
2016-01-14 9:44 ` Chen Gang
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).