Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1418499
| From | Andy Lutomirski <luto@amacapital.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system |
| Date | 2016-06-09 19:10 +0200 |
| Message-ID | <rIbCW-S9-23@gated-at.bofh.it> (permalink) |
| References | <rHADn-1U9-9@gated-at.bofh.it> <rHBg6-2r1-7@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, Jun 7, 2016 at 7:14 PM, Zhangjian (Bamvor)
<bamvor.zhangjian@huawei.com> wrote:
> Hi,
>
> On 2016/6/8 9:33, Weidong Wang wrote:
>>
>> Test 32 progress and 64 progress on the 64bit system with
>> this progress:
>>
>> int main(int argc, char **argv)
>> {
>> int fd = 0;
>> int i, ret = 0;
>> char buf[512];
>> unsigned long count = -1;
>>
>> fd = open("/tmp", O_RDONLY);
>> if (fd < -1) {
>> printf("Pls check the directory is exist?\n");
>> return -1;
>> }
>> errno = 0;
>> ret = read(fd, NULL, count);
>> printf("Ret is %d errno %d\n", ret, errno);
>> close(fd);
>>
>> return 0;
>> }
>>
>> we get the different errno. The 64 progress we get errno is -14 while
>> the 32 progress is -21.
On 64-bit, you get -14 == -EFAULT. Seems reasonable: you passed a bad pointer.
On 32-bit, you get -21 == -EISDIR. Also seems reasonable: fd is a directory.
>>
>> The reason is that, the user progress would use a 32bit count, while
>> the sys_read size_t in kernel is 64bit. When the uesrspace count is
>> -1(0xffffffff), it goes to the sys_read, it would be change to a positive
>> number.
That parameter is size_t, which is unsigned. It's a positive number
in both cases.
I don't think there's a bug here.
Back to linux.kernel | Previous | Next — Previous in thread | Find similar | Unroll thread
[RFC PATCH] sys_read: add a compat_sys_read for 64bit system Weidong Wang <wangweidong1@huawei.com> - 2016-06-08 03:40 +0200
Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system "Zhangjian (Bamvor)" <bamvor.zhangjian@huawei.com> - 2016-06-08 04:20 +0200
Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system "H. Peter Anvin" <hpa@zytor.com> - 2016-06-08 09:40 +0200
Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system "Zhangjian (Bamvor)" <bamvor.zhangjian@huawei.com> - 2016-06-08 13:50 +0200
Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system Andy Lutomirski <luto@amacapital.net> - 2016-06-09 19:10 +0200
csiph-web