From nobody Sat May 4 06:09:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547110811033554.2628685865084; Thu, 10 Jan 2019 01:00:11 -0800 (PST) Received: from localhost ([127.0.0.1]:59287 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghWCA-0007Nv-12 for importer@patchew.org; Thu, 10 Jan 2019 04:00:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55289) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghW3h-00009F-5c for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:51:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghVqk-000151-99 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:38:04 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:48513) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghVqi-00014V-En for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:38:01 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N5G1V-1hONAc4245-0119Wh; Thu, 10 Jan 2019 09:37:48 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 09:37:36 +0100 Message-Id: <20190110083737.5036-2-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110083737.5036-1-laurent@vivier.eu> References: <20190110083737.5036-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:7ixmCoFW1LjqKu0J2kXyS88BL/icgadDsfi9aAUSUCexzoKk8SS wVYI2OtpPMY3/+PmHEAV0LZ0dufKQhoUdLRldPkhZRJNQ494ybnU007wJT7zI17IkMaqLpx fzf2EKRH415M9Wez0ZDO9v+NzE2PxumPJxLDgffy80bxQB349+GJlMS9wUVFToTSDySDiN6 N0QLKjHi0wThSEUSa3RfA== X-UI-Out-Filterresults: notjunk:1;V03:K0:/8MghZ6jLbc=:2XOD5bx8zSPOUYgtf91NWj 2QoC5H2APSjpnKywrojBN1srQxlb9NDI45zYSMtYWSPk30lfZhEAnI6Ta/pjvVNAFcW0Wz+K7 gSCI+i4pACC8Hw7ig0BDyRYCso5EAavjuTEgtRvVYsQju4Cyi+Dp62NJfl6mYcdSIQkkfNDRB 0igEnN+gnFwUOpIVy6Tj6f5E4bX8f5ahPIOJiOcIDwAzgQD4KuVi3OJHlFu7hEUpPUfrVbkPi TEf06laE9b68bq6/aURMHgLZwH4A4bwN3p3UzFQMnMORGNqVp+AgbbF5ew2CboNT4aVYqxg2d Y1zm+cN0cKJKNQyz6RxoEnRYznQavb9svyjmiVhfLxb0/xsqteDW6R7gqPo6IcQpX9jN6Impl Jd+MQtfBz98uKvho6CEDJyqAuv4jAsixuOqIMeZlUKO78lFdFC84Ske/q9ynW4kTHMc63B4xF OdvQp4p0ULSL5Iu5EBrGcMr4LgVJMFcCCF2x4jJM6IUwzOZV1FfX/T+bPt8NOJ6zFB3ejd0Ly ux3z9//oNLlCBbPGeLdrEbzZ+oImTgGo4WSjeaZbyyRnJ/yPrvsYZagwXkmghYjAFpu45go1L 7q7w+OLtHNb67Rz3HX5nma/YT9qe+0SvC7gn1RyxYy0kvmD3bNrZZyB4xCScd0WI3na2eM6Vk W5fvR/OEc4xOpP8ql4PWZYc9X7Icbb97ZJXMtmfXsJ/YGcgnACyAWoEFKZNkIPaCGSCMmzzIh vKwVOyFBPfe8yi+MjRfguCJhBUYqdG+x3FzxoQ== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 Subject: [Qemu-devel] [PULL 1/2] Add getsockopt for settable SOL_IPV6 options X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tom Deseyn , Riku Voipio , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Tom Deseyn Signed-off-by: Tom Deseyn Message-Id: <20181213130611.7496-1-tom.deseyn@gmail.com> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 280137da8c..29bac79b61 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2352,6 +2352,45 @@ static abi_long do_getsockopt(int sockfd, int level,= int optname, break; } break; + case SOL_IPV6: + switch (optname) { + case IPV6_MTU_DISCOVER: + case IPV6_MTU: + case IPV6_V6ONLY: + case IPV6_RECVPKTINFO: + case IPV6_UNICAST_HOPS: + case IPV6_MULTICAST_HOPS: + case IPV6_MULTICAST_LOOP: + case IPV6_RECVERR: + case IPV6_RECVHOPLIMIT: + case IPV6_2292HOPLIMIT: + case IPV6_CHECKSUM: + if (get_user_u32(len, optlen)) + return -TARGET_EFAULT; + if (len < 0) + return -TARGET_EINVAL; + lv =3D sizeof(lv); + ret =3D get_errno(getsockopt(sockfd, level, optname, &val, &lv= )); + if (ret < 0) + return ret; + if (len < sizeof(int) && len > 0 && val >=3D 0 && val < 255) { + len =3D 1; + if (put_user_u32(len, optlen) + || put_user_u8(val, optval_addr)) + return -TARGET_EFAULT; + } else { + if (len > sizeof(int)) + len =3D sizeof(int); + if (put_user_u32(len, optlen) + || put_user_u32(val, optval_addr)) + return -TARGET_EFAULT; + } + break; + default: + ret =3D -TARGET_ENOPROTOOPT; + break; + } + break; default: unimplemented: gemu_log("getsockopt level=3D%d optname=3D%d not yet supported\n", --=20 2.20.1 From nobody Sat May 4 06:09:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1547110993835597.4692119990722; Thu, 10 Jan 2019 01:03:13 -0800 (PST) Received: from localhost ([127.0.0.1]:59928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghWF2-0000oy-Np for importer@patchew.org; Thu, 10 Jan 2019 04:03:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55290) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghW3h-00009G-5E for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:51:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghVqm-00015j-TN for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:38:06 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:46975) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghVqm-000157-44 for qemu-devel@nongnu.org; Thu, 10 Jan 2019 03:38:04 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MYNW6-1glU6w2Zve-00VPfc; Thu, 10 Jan 2019 09:37:48 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 09:37:37 +0100 Message-Id: <20190110083737.5036-3-laurent@vivier.eu> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190110083737.5036-1-laurent@vivier.eu> References: <20190110083737.5036-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:FCukf0J0R6N2vBb01LFbikhioT4mFtVg5TupSdt6YSBlr5th+bO I1h0Oh6KmtNUKKstWBr7RJY+xgdGMwUOHOUpnr0UMgob3hc3OAFoGOS51fYHt7Gk68C+h8H j/9x3AhvncRi/mxZp1+/VD5zBpJjPEppSHwDzurqZydkdDbM23aQD+LmnTwoYBx/nTxCabV 1DLI7kNMkLL2nrqGDGMHQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:iHF+0gud8BM=:G6AmtAOZVqtdvORfmoKha4 ReqGQTQTTlvYS6W8D0cFwuXsPsIP1rmzt40eXaiK7CfwTzSCGxBQ8IYHV8eCPN8vIBJXmMoUs jY5WoqIKUJ14ohDa6jgr1VGTG+8/RBt0x2sl5AGzGGHJqcCzXCMLu3FVsFllQRQFVzEE1X2Tw NT2vvS3rrZpFCEs1ypkSVdqq18wkqOuoT55eh8Yyfdz/PuMzpIEcDSK/ryWB6nan+Oh2JMv8j xcvA/Vi0Ig8t5+MsLU71fEQ2EYhTE7a7t50XdEJQOQPJlyID2WdzWNdHyZWQQjuASRxB1g7ww uoqnV26kzjHE3NJAGDNYqdyqBeFwoj6qoSnguOH696NgtjC1qR+5U1RSGJqyYjLCcJpV0Hakg ga/i5aq54kp1e8FPLhrwdDxNa+N7fTJlEZ57qKwLkT0jGqZYlshTlHqtWS16ujBdOd4Kueb0V Bgta8k9SqOnXGoZX8Q5SA71tuYDDiszQGEhxo3AIsGpad6qcw8jVT/NZYijNhdrn87iiTBKxG cRjnYV/a1z2o0prBWvGNkUlEHHIdyzDg+oZoW6J2kVuh6ppjkDNljhvsTBiWbAQeVGzEAH8R5 nZu4rgCPyfZQGFy516SUgD7Zm47OZyDiEksxyYaW1Dd7LttH3g0i3JAfz4VUSE1pk8VFBSwxJ j9m+KhaTMCYMCx3oDu1f8oxbmQBtPgvhraUxDfFDD4SeO3eLE3AnQsUZHWRRxrEm5qLp4JnAj gxH9+Gn9PfzARKl2bePK2TYhgIFNK3zsi8u2/YYmvjhTzLaXVgkqhF85Fxo= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 Subject: [Qemu-devel] [PULL 2/2] linux-user: make pwrite64/pread64(fd, NULL, 0, offset) return 0 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Riku Voipio , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell Linux returns success if pwrite64() or pread64() are called with a zero length NULL buffer, but QEMU was returning -TARGET_EFAULT. This is the same bug that we fixed in commit 58cfa6c2e6eb51b23cc9 for the write syscall, and long before that in 38d840e6790c29f59 for the read syscall. Fixes: https://bugs.launchpad.net/qemu/+bug/1810433 Signed-off-by: Peter Maydell Reviewed-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20190108184900.9654-1-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 29bac79b61..d6605b8b50 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9716,8 +9716,15 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, arg4 =3D arg5; arg5 =3D arg6; } - if (!(p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0))) - return -TARGET_EFAULT; + if (arg2 =3D=3D 0 && arg3 =3D=3D 0) { + /* Special-case NULL buffer and zero length, which should succ= eed */ + p =3D 0; + } else { + p =3D lock_user(VERIFY_WRITE, arg2, arg3, 0); + if (!p) { + return -TARGET_EFAULT; + } + } ret =3D get_errno(pread64(arg1, p, arg3, target_offset64(arg4, arg= 5))); unlock_user(p, arg2, ret); return ret; @@ -9726,8 +9733,15 @@ static abi_long do_syscall1(void *cpu_env, int num, = abi_long arg1, arg4 =3D arg5; arg5 =3D arg6; } - if (!(p =3D lock_user(VERIFY_READ, arg2, arg3, 1))) - return -TARGET_EFAULT; + if (arg2 =3D=3D 0 && arg3 =3D=3D 0) { + /* Special-case NULL buffer and zero length, which should succ= eed */ + p =3D 0; + } else { + p =3D lock_user(VERIFY_READ, arg2, arg3, 1); + if (!p) { + return -TARGET_EFAULT; + } + } ret =3D get_errno(pwrite64(arg1, p, arg3, target_offset64(arg4, ar= g5))); unlock_user(p, arg2, 0); return ret; --=20 2.20.1