From nobody Sun Apr 28 08:47:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616947862; cv=none; d=zohomail.com; s=zohoarc; b=Yq5jwx/WbdRcApwA28tvHm//zljSJPWpzehjdPOz+09Dz/MXaA1ZlpYqb7+u9gAq1riLtsjDJm5NxDtxdnNwFZwZT74uVNrLqvgoiVrfu4mt2m6e3Ho7b8tTGfSWv2EP3XGe7/+NAO8GNiRR5pb9pKYGfMz8YBoXHyZDBivgAY0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616947862; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W+o8XxZDzZUxQngEcwD60ufE7d3fJYQDESCmgb3KFRs=; b=Jhlm5BSmoEON0saIGgF2myScK4w1DrrBsIMyF3HewN637ur9tDYajXwJanvmYIDrb1o+/YlJLRFJByWAFiYIzqVbiGRbZqU+tpHUmQzxRGsnhOjQINZAD9YTQ43YMbWHX51bC6cUgq//BitDaDADLg9s9ZM46emVYNbuB0Smdjg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.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 1616947862366686.8269983662825; Sun, 28 Mar 2021 09:11:02 -0700 (PDT) Received: from localhost ([::1]:41494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQY0D-0000B1-96 for importer@patchew.org; Sun, 28 Mar 2021 12:11:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQXvp-0004aK-N9 for qemu-devel@nongnu.org; Sun, 28 Mar 2021 12:06:29 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:41787) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQXvn-00073M-8G for qemu-devel@nongnu.org; Sun, 28 Mar 2021 12:06:29 -0400 Received: from localhost.localdomain ([82.142.14.126]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MrhDg-1lwIIc43me-00nh5B; Sun, 28 Mar 2021 18:06:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 1/2] linux-user/s390x: Use the guest pointer for the sigreturn stub Date: Sun, 28 Mar 2021 18:06:18 +0200 Message-Id: <20210328160619.4015954-2-laurent@vivier.eu> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210328160619.4015954-1-laurent@vivier.eu> References: <20210328160619.4015954-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:qnv3au0zVnYKlYwhvUYG7nMQ1drOu+qXB5MZ/eefT3Eb1I4QUqD Yrf3usLI6dnCU6xVdPrE8XhIPKRbUlStrM0IL9jP5wP7HxnNZOJbra2XyL0dxdZ/SmxrGjv wgAsIDweP2AhdLYDdk54RXwVZOZc5GCNsYeLmoFG/Vm/l6wdvv0AL9l7RRjVlvc65cJQsUC QzMNYmNB+cz8Vy4Tw5uBw== X-UI-Out-Filterresults: notjunk:1;V03:K0:ZsKBQzB4+U4=:juytdZk3Z5yiL/yqJQ8PCI eQZBYV0xC3dYuSNGNfG9w3igh1hB9TfPJ5hlmKMQz+5et2lQgIhZcoBnR/rV8vvwW6YBXVHcK 4k4UkUnYpT/l2AkI3vyjV0JDQTE0F0i7a/qIHZFUbgOBCLVXYz+xR7Do0SqF7oPyX9x7aPHBB RRwMIxxeOIgq1ogCjbV+PzEO1nzg5Od9U0RaVyPjRyD/CnJw6I3BTKo2Lt8NIk9qKIky5+hR4 qLlr24pw6xZNLt6PZyE0MPOXFAoUZ7IHW6Ll/sJ1UDvu3Egn31n164OAotIr9+1A0fMAMUUBk 5jDg/fjJCNeuU82DLjlvNRIkJanb+AYNCnqkiuKojeqkCyR1rvF4fTASX1Mm5URwIEf/JktYm RSEtsWY1JSavOltl5dw+nQGIpuk/o46/UGC31XFCYu/PQRNIklbCfI2ciwIozuKRyUr44z8Ka ZHKTyMFheXuFsZag++HYua/VOApCfuW/+coWov+a1x86yDr0RbgV Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=212.227.126.135; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , Laurent Vivier , Andreas Krebbel Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Andreas Krebbel When setting up the pointer for the sigreturn stub in the return address register (r14) we currently use the host frame address instead of the guest frame address. Note: This only caused problems if Qemu has been built with --disable-pie (as it is in distros nowadays). Otherwise guest_base defaults to 0 hiding the actual problem. Signed-off-by: Andreas Krebbel Reviewed-by: Laurent Vivier Reviewed-by: Richard Henderson Message-Id: <20210324185128.63971-1-krebbel@linux.ibm.com> Signed-off-by: Laurent Vivier --- linux-user/s390x/signal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index ecfa2a14a982..7107c5fb5335 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -211,9 +211,10 @@ void setup_rt_frame(int sig, struct target_sigaction *= ka, /* Set up to return from userspace. If provided, use a stub already in userspace. */ if (ka->sa_flags & TARGET_SA_RESTORER) { - env->regs[14] =3D (unsigned long) ka->sa_restorer | PSW_ADDR_AMODE; + env->regs[14] =3D ka->sa_restorer | PSW_ADDR_AMODE; } else { - env->regs[14] =3D (unsigned long) frame->retcode | PSW_ADDR_AMODE; + env->regs[14] =3D (frame_addr + offsetof(typeof(*frame), retcode)) + | PSW_ADDR_AMODE; __put_user(S390_SYSCALL_OPCODE | TARGET_NR_rt_sigreturn, (uint16_t *)(frame->retcode)); } --=20 2.30.2 From nobody Sun Apr 28 08:47:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1616947739; cv=none; d=zohomail.com; s=zohoarc; b=B0572EVf4fIBSSkgzfuvrtNRj/eudqbltTQ14UI1SDlagJx+o5pItXKIbAQzMq6gZXoN44o1jZlTG7KFF1zBuNi/gmnZ5zgw8Rj630Nasti3xddLPn6OouvseN2cBo3cEodittBjSnpjQO36HQt+SnGdyDruEgBmVyj5t6fL64k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1616947739; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=bNSOYhlFaHev2zGSv8apGTtJ0VLIXY6ftOOG/6d6tcw=; b=nbIpYb6xjjaPTX0RbLayRERpRmRh/Vd+9GGikhUYRSwKAK6SL9NK30mHCZ9H/Mh+Tt+94o2cYCt9jhjycrgV97SMHByOQ1zljiuDpzGbpjktQrd4hMPtlJiWteP5Rf0xNVoaFN9C7dSv/X+BdXvC5fbcQhz5lXhcKMrodDY4tUk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.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 1616947739227997.5253072821113; Sun, 28 Mar 2021 09:08:59 -0700 (PDT) Received: from localhost ([::1]:35204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQXyE-00062P-1s for importer@patchew.org; Sun, 28 Mar 2021 12:08:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQXvp-0004aU-Oo for qemu-devel@nongnu.org; Sun, 28 Mar 2021 12:06:29 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:47627) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQXvn-00072f-NR for qemu-devel@nongnu.org; Sun, 28 Mar 2021 12:06:29 -0400 Received: from localhost.localdomain ([82.142.14.126]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MBll6-1lL0Xj1lhE-00C8Ld; Sun, 28 Mar 2021 18:06:23 +0200 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 2/2] linux-user: allow NULL msg in recvfrom Date: Sun, 28 Mar 2021 18:06:19 +0200 Message-Id: <20210328160619.4015954-3-laurent@vivier.eu> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210328160619.4015954-1-laurent@vivier.eu> References: <20210328160619.4015954-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:nSU7qInET3MOjEoGbPYr93QEizEe1B+PKXVRNxN47fQ6VoazWOm /V6yTUSTHcWhxwDZLLdD9UfCHqUb0B+ZupFDnY3tqJ42325Ds/6zP37/Plae9vbqEDK49gs 5I1YRef+B7Et9YFbS6b27PS6b2y17P+d/ZZJ8/AOGdfoYpDY7zvjvvBJ73+j6h2VNcZPrT6 cETGd+fXc+xEEMkGCFbKA== X-UI-Out-Filterresults: notjunk:1;V03:K0:nHqJWvHFz6U=:gEC++wB7dAZzNWtTRHEiKc 6RFVySPSo2HkBWw+vs2fqR0pjs6BDTrGMvxrPDyWemmeKO7HWB8C03UvXX09fVJ26bL0DTGjH 9CKVyIlBoM2W/esfJ5RfcYp70uj+ZU8yBX+BYSR/7zw7KHT84iZxIXgL7uswG3hsKXA6YyU6c +KgVlgGyq4HtSY8cxMMK8pPpEYvZXzuA9i+0Xz7EEUgG+8shwmS6wGE7fvcE+N60zRE4gOR1a vyC0RtdQAa9yfu6pOY9beOEvalOTULhZKsx+t779Pt63WiMxw6Cck2Os921x80ZAzrr9XXzTd zhIydTgFOZpza9KhuKXJUok0xiHSu4em+dJGe9eZ3YvV3C6J+bwSJ8pX2+i2xexxII1t+AHZs l6nhgsv9c0t75o7w7eB+z9k/t3TA6iX3v5Cl86sfUzC40QuQOAOgZlhSIHrIV5YoWAYnxWrQ8 0Uk1DjXDcwAe8M2rRm2PJngs6bPCb5RVQXC2LWk0rk3Y0Dy5F3sA Received-SPF: pass (zohomail.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; Received-SPF: none client-ip=212.227.126.187; envelope-from=laurent@vivier.eu; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Zach Reizner , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Zach Reizner The kernel allows a NULL msg in recvfrom so that he size of the next message may be queried before allocating a correctly sized buffer. This change allows the syscall translator to pass along the NULL msg pointer instead of returning early with EFAULT. Signed-off-by: Zach Reizner Reviewed-by: Laurent Vivier Message-Id: Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1e508576c73e..294779c86f4d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3679,9 +3679,14 @@ static abi_long do_recvfrom(int fd, abi_ulong msg, s= ize_t len, int flags, void *host_msg; abi_long ret; =20 - host_msg =3D lock_user(VERIFY_WRITE, msg, len, 0); - if (!host_msg) - return -TARGET_EFAULT; + if (!msg) { + host_msg =3D NULL; + } else { + host_msg =3D lock_user(VERIFY_WRITE, msg, len, 0); + if (!host_msg) { + return -TARGET_EFAULT; + } + } if (target_addr) { if (get_user_u32(addrlen, target_addrlen)) { ret =3D -TARGET_EFAULT; --=20 2.30.2