From patchwork Tue Oct 31 12:53:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 117607 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3919718edm; Tue, 31 Oct 2017 05:54:38 -0700 (PDT) X-Google-Smtp-Source: ABhQp+Ru/ZU/p+HyYlcqfsfiflqAt4g38ERNdkEoRyMn6uXwbic2btsO6tFxnmxLNLG78KkV6A4C X-Received: by 10.129.155.22 with SMTP id s22mr1081746ywg.491.1509454478687; Tue, 31 Oct 2017 05:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509454478; cv=none; d=google.com; s=arc-20160816; b=v3dR5ns5i5mXhKyCPxEAeYo/JtDmsyoQf+UFBhFliBiLufSGfaatFPq44gDwFVtE0I DPs/2rX9Fmng7GkeiSI5wQZspTqVoT6e6ChfyS+43Naf3maQIvpS8PHU+YgjuWFAbzby T49SweMLPlmywZ1PcD1tiUK56TdZQeiB0Nv0R6GkRYPLMpdYoiYxYSke9go2CWVicZy+ B8CA5ncydZDAsNIoskUZA6aJ+ppEsKl070REakuQPq2MF2cjzPAdC5tyCek16SEPdLNk TmJUY+pceg4NEnscQ0U4JpzCOwmfzRKIMP1gGBmUC9kqMalRBF4419lAA91lh2GSa/d+ YltQ== 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:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=SNsX0Nnv6Gi+dUFh7/FhZJAC8ikPuC2y0mY46JXBado=; b=mSmfNTZp2Cc6NrS6/7tFysVjf/8LXIW5eaK71qZXZI0EZ8jlj6p/lQfpYHAXIJUkTa 4RFVN5DoIo4nhUNIExIrxgcYTJhbXoLqWXekQgVaGYKnjYt46fuzTrhzqXQUq//St2cg qUzVKcMkoX6foGmDYPvAuQnE+Oh+9QmqIzhcQh7qge8pBYgZt7xCcboC2cQ0g8BMBkAZ k5p+V7nWZkGKh00EmOFoJ/03pLYFTV2GeIAGqcnuBIBB8KlYmuxSTic1vNhFGEq/ttlq wgzBO/56nFKFwyXgC8prllWzfskLteUeZ6Lqzzj3ABuIo8YuimBgeEy2d4vyysvZT9fj UEdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y/Vjhh8K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id s11si368692ywg.624.2017.10.31.05.54.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 31 Oct 2017 05:54:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Y/Vjhh8K; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:45497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9W3y-0002La-3b for patch@linaro.org; Tue, 31 Oct 2017 08:54:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54087) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e9W3d-0002LU-Si for qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:54:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e9W3c-00058B-U0 for qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:54:17 -0400 Received: from mail-wm0-x241.google.com ([2a00:1450:400c:c09::241]:45902) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e9W3c-000581-NY for qemu-devel@nongnu.org; Tue, 31 Oct 2017 08:54:16 -0400 Received: by mail-wm0-x241.google.com with SMTP id y80so15474218wmd.0 for ; Tue, 31 Oct 2017 05:54:16 -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=SNsX0Nnv6Gi+dUFh7/FhZJAC8ikPuC2y0mY46JXBado=; b=Y/Vjhh8KH38306biMZDqbIViO9edtAXmLGHcumJkOfZlgheidkvcpy2jSnJC3iFW8q AuYkKT2hdA5UFYyQAtloNREXrdqffrb8TCAMEjMOrrZNwtP8HwE46YXms9EAomfmrqEI dOrXl6HHmFLJAzErzypKSMj8yI13IF7ygeRrI= 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=SNsX0Nnv6Gi+dUFh7/FhZJAC8ikPuC2y0mY46JXBado=; b=Uioouyboxh/9C1ylLkkvYM5befIhKj0B0L57rtWuaEPJGv9zDUGbpZHx2nfk/Fb3px hyQQxUUdZtOWxbzq4NmQzmZQN5YqYFm4I4bu03ZKCBuUl98oWGQPLZb7Ghk/EI5/Wtlj FOofOf96NOxO+M8koLgXg+qAfc9h4ZTF/1+hYxcSaAH7KOA1kB5T9jRIQDPnesbbhMjn pENz4lMNxMey+sJLOo/VcaiNpwjPs5eG4tsNjKOC+uVUxu34T4hKEughNN9PrgMuqYEB 8S1wQ9NVseW3A7IHnwoFije+CCMsPpORofUAysTEWn7QGNmuYX7nRNqFc8U+7MRjCPRd APJg== X-Gm-Message-State: AMCzsaWglVWG/+gnhQoeG7O/K7eI0+F4fpK1jn6+UeX39qXRJAC2EXRM LCL/aP9jBJZ+qQcEirMqCBBdgQ+HDyY= X-Received: by 10.28.93.200 with SMTP id r191mr1258815wmb.141.1509454455279; Tue, 31 Oct 2017 05:54:15 -0700 (PDT) Received: from cloudburst.twiddle.net.ASUS (p57A4515F.dip0.t-ipconnect.de. [87.164.81.95]) by smtp.gmail.com with ESMTPSA id e131sm999011wmg.15.2017.10.31.05.54.10 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 31 Oct 2017 05:54:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 31 Oct 2017 13:53:52 +0100 Message-Id: <20171031125358.23377-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171031125358.23377-1-richard.henderson@linaro.org> References: <20171031125358.23377-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::241 Subject: [Qemu-devel] [PATCH 1/7] linux-user: Restrict usage of sa_restorer 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: riku.voipio@iki.fi, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Reading and writing to an sa_restorer member that isn't supposed to exist corrupts user memory. Introduce TARGET_ARCH_HAS_SA_RESTORER, similar to the kernel's __ARCH_HAS_SA_RESTORER. Reported-by: Helge Deller Signed-off-by: Richard Henderson --- linux-user/syscall_defs.h | 13 +++++++++++++ linux-user/signal.c | 4 ++-- 2 files changed, 15 insertions(+), 2 deletions(-) -- 2.13.6 diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 450960bb54..e366183419 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -445,6 +445,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, #define TARGET_SA_RESTART 2u #define TARGET_SA_NODEFER 0x20u #define TARGET_SA_RESETHAND 4u +#define TARGET_ARCH_HAS_SA_RESTORER 1 #elif defined(TARGET_MIPS) #define TARGET_SA_NOCLDSTOP 0x00000001 #define TARGET_SA_NOCLDWAIT 0x00010000 @@ -483,6 +484,10 @@ int do_sigaction(int sig, const struct target_sigaction *act, #define TARGET_SA_RESTORER 0x04000000 #endif +#ifdef TARGET_SA_RESTORER +#define TARGET_ARCH_HAS_SA_RESTORER 1 +#endif + #if defined(TARGET_ALPHA) #define TARGET_SIGHUP 1 @@ -718,19 +723,27 @@ struct target_sigaction { abi_ulong _sa_handler; #endif target_sigset_t sa_mask; +#ifdef TARGET_ARCH_HAS_SA_RESTORER + /* ??? This is always present, but ignored unless O32. */ + abi_ulong sa_restorer; +#endif }; #else struct target_old_sigaction { abi_ulong _sa_handler; abi_ulong sa_mask; abi_ulong sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; +#endif }; struct target_sigaction { abi_ulong _sa_handler; abi_ulong sa_flags; +#ifdef TARGET_ARCH_HAS_SA_RESTORER abi_ulong sa_restorer; +#endif target_sigset_t sa_mask; }; #endif diff --git a/linux-user/signal.c b/linux-user/signal.c index 7a238aaea1..cf35473671 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -777,7 +777,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, if (oact) { __put_user(k->_sa_handler, &oact->_sa_handler); __put_user(k->sa_flags, &oact->sa_flags); -#if !defined(TARGET_MIPS) +#ifdef TARGET_ARCH_HAS_SA_RESTORER __put_user(k->sa_restorer, &oact->sa_restorer); #endif /* Not swapped. */ @@ -787,7 +787,7 @@ int do_sigaction(int sig, const struct target_sigaction *act, /* FIXME: This is not threadsafe. */ __get_user(k->_sa_handler, &act->_sa_handler); __get_user(k->sa_flags, &act->sa_flags); -#if !defined(TARGET_MIPS) +#ifdef TARGET_ARCH_HAS_SA_RESTORER __get_user(k->sa_restorer, &act->sa_restorer); #endif /* To be swapped in target_to_host_sigset. */