From patchwork Fri May 10 03:27:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 163813 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:142:0:0:0:0 with SMTP id j2csp1819536ilr; Thu, 9 May 2019 20:27:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqzOapS+eo3QKAzTDHqeymZHw98DF+8gT30D07sUfQaY7PwBnZnNmGK4/+Ft/5eNrHoku+Y2 X-Received: by 2002:adf:dc04:: with SMTP id t4mr1039768wri.126.1557458865421; Thu, 09 May 2019 20:27:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557458865; cv=none; d=google.com; s=arc-20160816; b=iR6s+z54EcPR+GlciIC3cnhtlGo9BUhcraRtFIk/rVzBvm1yNuW3XPUUf5T76JyD7q Zp9CylUxVNupahM9ktguS9avDIRyV+O3kqiV56xp1lrEzkIbqY2sZtzxLF+bE7hGDwOT ULdj8fwBPu8nE9bU/3U9YenXxbdrn4AzWxp69bb7fe1cYcmQLRp4woDV3K7+0DNIFD7u QpsHOWld5yk4JhpfMrZbrh6dGFIXjqa8OWohA0CIWbmhFdgfeLocTPkBKVuRp806Qjc6 DyGCfpZd9+nyhqNFKST9j1x2wOoVmNZtG4maGepGo1e/42osAZu2tG2EXz2zdNg8nTaI I/qA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=iKTmI9ncTuLaMcNrrSxuBO2p/7mhBstesEY49w5c0ms=; b=SUTqyC0o0hY55ARgvg2c11cqAgT8jkv870w7ZXMUOHJ5wMDsa4f3T1swv7li5m42BE gQ9PvCwoVp/yGTvqeQ2F8nvxqMnliZSE1u6e07xwyjqK0HRjnnQGhYQxtjky5cCLx5gy O5EwwNeSbdcif8L1Yi6E4Q8Q4VbPqUGMo9xaP7bPP/FoxOmbqOgV/SO9UKGuQQoedE36 IesyvylYJ9+QmH4CDjCzWiU1RTiufjn6fXG/MJgyfzF26vfEzPgwm9cAgDrrGuHp009j Me2b3AIFAX8J2R4tLBCHZCxGGHXG45wsMTZayNaRa8cu3+sbE3IhkZfXlFLRHHa4TFjJ UFag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BY1M4BJp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f1si3232343wrm.231.2019.05.09.20.27.45 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 09 May 2019 20:27:45 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=BY1M4BJp; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:36116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwCG-0002wY-Cj for patch@linaro.org; Thu, 09 May 2019 23:27:44 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48051) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hOwBo-0002w1-KS for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hOwBn-0001Nk-NW for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:16 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:45052) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hOwBn-0001LU-Hh for qemu-devel@nongnu.org; Thu, 09 May 2019 23:27:15 -0400 Received: by mail-pg1-x542.google.com with SMTP id z16so2260583pgv.11 for ; Thu, 09 May 2019 20:27:15 -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 :mime-version:content-transfer-encoding; bh=iKTmI9ncTuLaMcNrrSxuBO2p/7mhBstesEY49w5c0ms=; b=BY1M4BJpSx0iy7djdB7+Acxrx3ZaPDMy3YUEN/1ASHo7ISGkt8qU/DE73/kO33M/9v v8Y9dRwURwxElKs9/vwBHXTGhQTQLt+6XCke3p79RNWGTzHl6mNyiJyiGBCMYu7Xs7LX jJu726/gMlSOQXPO8UiJaUdoQaxTYivZX8o70ce2rfYmBo/lO6gZuoAvu6hkaFk+vg1r ulC9AePS5Lcfx/ejXbK1R5Oz1Hy0SWiJ6jRAE5PFUkxOf1qoEsnuA0Lj4Gl51gBq82vs gWxf6F5wz7qaTpFaToC0/lK3eXb1uWci8ttHbQya2wUdaLfQWqrYPSG55UKkrfiubkgu 653g== 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:mime-version:content-transfer-encoding; bh=iKTmI9ncTuLaMcNrrSxuBO2p/7mhBstesEY49w5c0ms=; b=epXI8EwVvUuaWxOObffKhd7QKSSNyYjUsWlwMDmVkk5RuxCgfPNHym+VUdMRQ6AZsO RBsmOqF69K7LHDGnsfwSst39LPQZ7k0DwBXdGWOFjexAyE+Kru/771xjxZ/2FvrhNSE9 pdlzBco8vpz0qfyODYRrnQiNBUK184V4u8EXB/lu+meP/nnD0LEVilRKEwkdZYekm7Sd R5eDbZiKUo1YGzJ1B90QDrecWdsSi5mM09JLStsTV9F1atXaNrlVHzgldK22nAd2sbSi 2BN7oqX2NPD9Zc9AKMLbmqkhEISlFsbwDljJfOXU/0gjYRXAOb3/myDF6OQM1ZWI1D7H i14Q== X-Gm-Message-State: APjAAAWISXjeBeRSk7pxKSILLuJRKmWaP5wH/rfxy11Rws/H0kaf7OMo NmKMDIXo7K0tD8My17zqKQVBxDiYHfQ= X-Received: by 2002:a63:445d:: with SMTP id t29mr10619943pgk.303.1557458834238; Thu, 09 May 2019 20:27:14 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id t26sm6259695pgk.62.2019.05.09.20.27.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 May 2019 20:27:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 9 May 2019 20:27:03 -0700 Message-Id: <20190510032710.23910-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190510032710.23910-1-richard.henderson@linaro.org> References: <20190510032710.23910-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH v2 1/8] 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- linux-user/syscall.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 96cd4bf86d..f7d0754c8d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5553,10 +5553,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) { @@ -5571,7 +5575,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