From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51708) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIW1T-0007HE-Gw for qemu-devel@nongnu.org; Mon, 11 Jan 2016 01:32:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIW1O-0005kK-Gs for qemu-devel@nongnu.org; Mon, 11 Jan 2016 01:32:11 -0500 Received: from out1134-186.mail.aliyun.com ([42.120.134.186]:32633) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIW1O-0005jy-4Y for qemu-devel@nongnu.org; Mon, 11 Jan 2016 01:32:06 -0500 References: <1452218349-3793-1-git-send-email-chengang@emindsoft.com.cn> <568F7270.5000506@vivier.eu> <568F8412.4000507@emindsoft.com.cn> From: Chen Gang Message-ID: <56934C5F.4000200@emindsoft.com.cn> Date: Mon, 11 Jan 2016 14:31:59 +0800 MIME-Version: 1.0 In-Reply-To: <568F8412.4000507@emindsoft.com.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Laurent Vivier , riku.voipio@iki.fi Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, rth@twiddle.net Oh, sorry, after check again, I guess, we need continue to discuss. On 2016年01月08日 17:40, Chen Gang wrote: > > On 2016年01月08日 16:25, Laurent Vivier wrote: >> >>> + if (optlen < sizeof(struct target_timeval)) { >>> + return -TARGET_EINVAL; >>> + } >> >> You don't have to check the len (kernel doesn't), EINVAL is not listed >> in the getsockopt() error cases, it should be an EFAULT, and this will >> be managed by copy_to_user_timeval(). >> After "man getsockopt", there is EINVAL in its error cases. > OK. > >>> + lv = sizeof(tv); >>> + ret = get_errno(getsockopt(sockfd, level, optname, &tv, &lv)); >>> + if (ret < 0) { >>> + return ret; >>> + } >> >> if (len > lv) >> len = lv; >> For me, len is for target, lv is for host, they cann't be compared with each other. > > OK. > >>> + if (copy_to_user_timeval(optval_addr, &tv)) { >>> + return -TARGET_EFAULT; >>> + } >>> + if (put_user_u32(sizeof(struct target_timeval), optlen)) { >>> + return -TARGET_EFAULT; >>> + } >> >> if (put_user_u32(len, optlen)) >> return -TARGET_EFAULT; >> For me, we still need put sizeof(struct target_timeval) to optlen, since the host lengh should be sizeof(struct timeval). > > OK. I shall send patch v2 for it, in the next week. > > Thanks. -- Chen Gang (陈刚) Open, share, and attitude like air, water, and life which God blessed