From patchwork Mon Jul 30 20:15:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 951275 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Qm86FIay"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fWBc0slHz9s1x for ; Tue, 31 Jul 2018 06:19:35 +1000 (AEST) Received: from localhost ([::1]:55695 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEdh-0002Ez-79 for incoming@patchwork.ozlabs.org; Mon, 30 Jul 2018 16:19:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55803) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fkEaL-0000Ro-QA for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fkEaH-00021J-Ql for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:05 -0400 Received: from mail-ua0-x243.google.com ([2607:f8b0:400c:c08::243]:42124) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fkEaH-00020y-M0 for qemu-devel@nongnu.org; Mon, 30 Jul 2018 16:16:01 -0400 Received: by mail-ua0-x243.google.com with SMTP id w7-v6so8734497uan.9 for ; Mon, 30 Jul 2018 13:16:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Zk60bfvUd4Qid25+I+xIHckBd4rdjjMbx8r3J4vKn+A=; b=Qm86FIayvxLSSqjP+nf6EeaEK0yU1l5Md/wSsuX9Qxj2/1lALVUoXL3GJc9SwXNEkG Ll1C2nF01xg5S7UVknwtjoyCDP324FPAzESvC0JbPjyJtzzel5xWXAttxfH5mCwS/M+c ndN27Rxdbevxjeh1z0eGN9dWNAbnGzI3G6LtY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Zk60bfvUd4Qid25+I+xIHckBd4rdjjMbx8r3J4vKn+A=; b=aYoQZO2aqFsZ+lDdA3ct3POyizzUG+FRYBttYrSX1iEPnTp8VoKSNW9RsqhbcCNVgq 63bAyWbp6R8T7Zh6bKSopd6lapncxhNC2tFsApr/x/Wm0yqy6bJh9p+tGcdYtv+kx51f JseNErV0FmgULePG5/KEeGJL+RGrNedFVUjumG20mtWcFctPfftDXGvseBVNxgvke63P 0PZilrLWlP/KSIxriOgUBlcJevtZrNvIV78ISYNlIjZMiBbO4wg1bUuNio8NkwBU8jVu sprhjsSSONsb0mO3LjgldosOcyO7+4sOqW/ffD/6Nwo+EmkZyQchC4C7fC/RyBQF9Sdq CEkA== X-Gm-Message-State: AOUpUlFij8eB4KoZTaN8QqoO/7a2syiEq7j332YrZcqledkXkK2Vso6e l1v4jp9hLuBr974McIpjg7wAPh8T5KA= X-Google-Smtp-Source: AAOMgpfRDMlCrg1uQKS6DO0aNsQJQ9CAreUF2nbHckc5HOtn+5k46q6y19rudI7TeneyuJ06vOGtsg== X-Received: by 2002:ab0:2783:: with SMTP id t3-v6mr13123994uap.181.1532981760866; Mon, 30 Jul 2018 13:16:00 -0700 (PDT) Received: from cloudburst.twiddle.net ([190.166.236.188]) by smtp.gmail.com with ESMTPSA id x12-v6sm2542448uaj.48.2018.07.30.13.15.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 30 Jul 2018 13:16:00 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 30 Jul 2018 16:15:50 -0400 Message-Id: <20180730201553.32423-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180730201553.32423-1-richard.henderson@linaro.org> References: <20180730201553.32423-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400c:c08::243 Subject: [Qemu-devel] [PATCH 1/4] linux-user: Disallow setting newsp for fork 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: mark.cave-ayland@ilande.co.uk, alex.bennee@linaro.org, laurent@vivier.eu, atar4qemu@gmail.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Or really, just clone devolving into fork. This should not ever happen in practice. We do want to reserve calling cpu_clone_regs for the case in which we are actually performing a clone. Signed-off-by: Richard Henderson Reviewed-by: Alex Bennée --- linux-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dfc851cc35..5bf8d13de7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6502,10 +6502,14 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, pthread_mutex_destroy(&info.mutex); pthread_mutex_unlock(&clone_lock); } else { - /* if no CLONE_VM, we consider it is a fork */ + /* If no CLONE_VM, we consider it is a fork. */ if (flags & CLONE_INVALID_FORK_FLAGS) { return -TARGET_EINVAL; } + /* As a fork, setting a new sp does not make sense. */ + if (newsp) { + return -TARGET_EINVAL; + } /* We can't support custom termination signals */ if ((flags & CSIGNAL) != TARGET_SIGCHLD) { @@ -6520,7 +6524,6 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, ret = fork(); if (ret == 0) { /* Child Process. */ - cpu_clone_regs(env, newsp); fork_end(1); /* There is a race condition here. The parent process could theoretically read the TID in the child process before the child