From patchwork Mon Nov 20 21:21:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 119316 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4392532qgn; Mon, 20 Nov 2017 13:24:36 -0800 (PST) X-Google-Smtp-Source: AGs4zMaNQQXHejaK77iZiQ15xCtwsdOQvGQ/sQ4zW4XS8M3mDZ0VZ29qxUpKcQUv2DVC15U7vjjp X-Received: by 10.129.117.197 with SMTP id q188mr9742329ywc.348.1511213076889; Mon, 20 Nov 2017 13:24:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511213076; cv=none; d=google.com; s=arc-20160816; b=QeB/jXfpB1wqgHbuK8QhRGN6hQcmWbIeirL75ZSCp4+BjXwC7cxWMvimawAPmxJ+K6 /UIeBXE16+0NMXPx7dpr66YbhlwbycGHr1xvI6Mfg/7jEIBB8swwhJx6ngUulqZv4iCv CS2XBB9K4elae+SGvMn8hPgE28e3Q1Bj40F3v6AnBY9j11cz1ffljtJpxO1w+klkRUzR z9Sgq7aJFKzfVMgoVv47Gv1lxEtp0z1tLFYkURhSJ9nRdtAyYfmkPZFvphQn4Nu5ecjw XcGN3bFHFd9M/do0DVc3zUjYW+r8TQfTN7Bh2MeSxakG9+6JCqztXGcPcsj9T3kZhECP +C2Q== 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=sxp7NkQJ0fCFMZAWQwuA4SBV3gox/kUeV3nqW9idGoY=; b=H2UOhnZPobQbbx3wTyhlN1zOp+RbbT/x2/gQlMMyVgPgsDjGL8VlU3lg36QZovAKlk gm7GHAdLU/L11Y9PwV5UFqxmiE/TUykJfLEeN1rT8PHf9u2aqQou8LGX6mStAITRRucd 7/x/TNttu7gDph3AiDC9pqIomSV2I/GP8y2levE8T2FdwvEKyJutRYdnIoCX2lsEPAHa l8bfyPmmhsB+IbkXPIqJEwO4BRyco70chPwnGMcXJkAE0tmbF2D4hhO8zUTkACm4KuXw 6YgzSWELt6qS/CWP4DX9uIv8m4+DDy7SZWUZB1S2KjMzbaCuHiCRedtBF+TmzzwelSya BLcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=T9nYiPQY; 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 n2si2217802ybh.251.2017.11.20.13.24.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Nov 2017 13:24:36 -0800 (PST) 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=T9nYiPQY; 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]:59808 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtYS-0005mY-Bj for patch@linaro.org; Mon, 20 Nov 2017 16:24:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGtVn-0004Tc-1s for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:21:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGtVk-0007dx-Bu for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:21:51 -0500 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]:36361) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eGtVk-0007ca-4L for qemu-devel@nongnu.org; Mon, 20 Nov 2017 16:21:48 -0500 Received: by mail-lf0-x244.google.com with SMTP id k66so11726548lfg.3 for ; Mon, 20 Nov 2017 13:21:48 -0800 (PST) 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=sxp7NkQJ0fCFMZAWQwuA4SBV3gox/kUeV3nqW9idGoY=; b=T9nYiPQYIxhJxPe3KxV1JcUGo2oClZAbsAAv8PH3nJaU0joWQJmbJVBN0OXxRiRYkt 00ekHuzvwcZOOrI/S8J+zAinvXE8Zt+FJr8oaqEC/9CSb5lMexbKnMVZTTP8tsGYy6jc 2XzoM9r5dKfmiFTu+lvnDSTv8juj8Ahj+by7I= 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=sxp7NkQJ0fCFMZAWQwuA4SBV3gox/kUeV3nqW9idGoY=; b=O9sdpMV90cprMjKU/CyjVJeQOXdtIW9n8jzPHFxub9fWJ7KyI84e2kaRHiEbLupCu7 MODT4ZzJWR2IiVp415+xBEgbSx7udHn4UYHerlF98bXOAMjV+FMP41QJws32K+vZUxTR yOOeUa+SaaACzU4NghnqJITBmso160Pw12EV7NzK6b9+HiyAWkDnAlO+C1kNhZooRPUA DXKf7s1Vy0L4XPl/KfBkLY9tw5ZpA6SnPA1yc3n5c3QwdW7t7o03TcnvO/TOSzZlC+pb 6TmaViaMmURxS7ldrmKCcWxuI6nUWxZt9FIXRl2fYdGqphsmeB67hi8+VS2JaHSVLNJO upRg== X-Gm-Message-State: AJaThX7CvfSdjQ34kCFNnSCAqoBoLT4NL4nmIZQ8G/3jfzD5jJdVBEPJ aUQ/huiDc36FGvQAqJ1KtIByQT6u8nA= X-Received: by 10.46.89.196 with SMTP id g65mr4643315ljf.53.1511212906573; Mon, 20 Nov 2017 13:21:46 -0800 (PST) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id v63sm1645409lje.39.2017.11.20.13.21.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 13:21:45 -0800 (PST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 20 Nov 2017 23:21:29 +0200 Message-Id: <7f047de18cf6cd51915d4fdbe1a7e66c38b45e98.1511212753.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.14.2 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::244 Subject: [Qemu-devel] [PULL 01/15] 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: 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 Signed-off-by: Riku Voipio --- linux-user/signal.c | 4 ++-- linux-user/syscall_defs.h | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) -- 2.14.2 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. */ 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