From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423432AbcFNDGd (ORCPT ); Mon, 13 Jun 2016 23:06:33 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:52566 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1422759AbcFNDGb (ORCPT ); Mon, 13 Jun 2016 23:06:31 -0400 Message-ID: <575F7497.9000000@huawei.com> Date: Tue, 14 Jun 2016 11:05:59 +0800 From: Weidong Wang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Andy Lutomirski CC: "Zhangjian (Bamvor)" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Al Viro , Arnd Bergmann , "linux-kernel@vger.kernel.org" , X86 ML , Hanjun Guo , Linux-Api Subject: Re: [RFC PATCH] sys_read: add a compat_sys_read for 64bit system References: <575775FA.1080009@huawei.com> <57577F91.5080308@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.21.100] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.575F74AB.0068,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 06f1edf214ed9e7caaa4412eed0baf88 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2016/6/10 1:08, Andy Lutomirski wrote: > On Tue, Jun 7, 2016 at 7:14 PM, Zhangjian (Bamvor) > 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. > Yep. In the progress open the '/tmp' is a directory. If we do open a file '/tmp/files' (exist file), the result would be different on x86-64bit machine. On 64-bit, we get -14 == -EFAULT. On 32-bit, we get the length of the file, the errno is 0. Regards, Weidong > . >