From patchwork Tue Sep 29 22:14:15 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7291081 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A432BEEA4 for ; Tue, 29 Sep 2015 22:33:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A1CE020685 for ; Tue, 29 Sep 2015 22:33:38 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C8B832067D for ; Tue, 29 Sep 2015 22:33:37 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zh3RQ-0001Xy-Mk; Tue, 29 Sep 2015 22:32:08 +0000 Received: from mail-by2on0054.outbound.protection.outlook.com ([207.46.100.54] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zh3EN-00044c-UZ for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2015 22:18:41 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (91.78.158.8) by CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) with Microsoft SMTP Server (TLS) id 15.1.274.16; Tue, 29 Sep 2015 22:18:16 +0000 From: Yury Norov To: , , , , , Subject: [PATCH v5 18/23] ptrace: Allow compat to use the native siginfo Date: Wed, 30 Sep 2015 01:14:15 +0300 Message-ID: <1443564860-31208-19-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> References: <1443564860-31208-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [91.78.158.8] X-ClientProxiedBy: DB5PR02CA0032.eurprd02.prod.outlook.com (25.161.237.42) To CO2PR07MB617.namprd07.prod.outlook.com (10.141.228.143) X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 2:30pETCUGSQkoAzhtEFps42lniEqPiVfU74lSsFIdMJdGKHZMRhioTWm0hCL3IVPsIMwd9xkUxHd38nfY94u891j2rVlHZNIT57Lh20tT0dtAkM1mwotEzqUPaGa7nxG7VVGvvf+OHf7US8zf3l/hoY88RIOxIk8UTeHNnjCwIBI=; 3:CeK3dSB/tB59p3KXi1yE3Qo5Nzw3eI7mam5m6Zw+f0xcF+AYZ2169Mg7tU6EyMWEoOM7mvZTlfPTK9sqCNZlvETQQR/Cy9wYawcTnCFwggMh87fWnnlFQ0BxJLg5Rp1ynEFf3vmz8ioL0B37yBfR3Q==; 25:j5mLn1V3qWJBit71k/Q4gP1tWeOBx3r2d1YP3cY3y+TJFElKx1+Bl1+UanLvE5unxy68e6KA9fvR9CeEn4elJi42aWthJ6KbcS7oPG6CwskW0tQhSW96dHlCFs3Q6y1xXZ+xOOqV81fqAPmhz4SPBtJ6JU8OWM8tU2Yk9V4teF9TCM8xBYo2WDIalZze2XaAIazKjOeP5yE0OPV33RlsU7GQdJBwqM3+LjV2W6dUkjbJv7xGH8AqJ0/JXUgD6n8uRggiUitGRRHGTy6z7KzHcw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 20:uHGOvVKp7/49FtB2ckf3MuS4ssK+kvEa2deKxwIxXCEoNIY0Of9w5Qd5t+00UN/Cz6ClO6DeovSijmtwebXyD2HfG4xgrrDCgJTUyattw9YfbWrhqpK+CAIUYxXpHRWBI39pPn7r50yHVuqyJcyKRO2XBB+Vx7VJ5x1mguF8eSHWGCcniQEzvKg7FRSQzsAeCsxUUVlrVIYrxuiXjoAcXthyHfwDM3SRT1nIbAKLhZM3S+7RWAYExyMD5cfQvP1cSaXmrKcjZCSLDiLOcuZWQJU/Be8Utgd/iBDxY9Y4SdApZjAJs/X1df14I3orqdEovcJMMzPHGTjU16KH4ltMJdFYk3EIdm8IkRTEG4E4RxI5izjeGxLz3hCmcdQUk8HpsF+tBKOltkDWGXRTWu8a+dn1wQs594i3hZ1mj+ZLdTFtuUndAdaqYD0crHm1Zbr8by1OHDho3lziVQ4yw2cbvDocbY5E3zwXuXdbFJQ1QDtFJ7o6z1yzds4AiF3uVIfWIbDU4ubQnBnF1WE9zWXS9Rb7S+RMKyL9Dh+7WjeaJc7Aeh6n+SBPdqKSN1snUNTXg8d8MwHdu27x0vCpzlWTKF0+diKKY0GH4T5Fg4u7eXc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001); SRVR:CO2PR07MB617; BCL:0; PCL:0; RULEID:; SRVR:CO2PR07MB617; X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 4:rssRpPRDXL8NuW46LG0ulTb8aYrc4H1mNHxfnxkHn0p6gzMqB/ImwG2I0foogZlHOAcPcgIbWQEu1q/rP2mtsojh4D7E4xJj1f4ElVVsJu/L/kFu1t8fTkfFHi82SO2nBractvsbmyeqkfz4MUi2kemoqOdBtMjq9TwXXz8uypGNvk700aO4sUHH2fIWjHI+k9WMSpgGVMVoNjMzCBrH38FX4pBVqF8cTLlbM8p25+y+8WyoTQqSsu6mpQ1mJHWADyXw8AyRbI8bMcMM2y9ckxwMx6FRkao9UZFCHdbmQGtpGh49cxG0oigKLft1QkOU3BjzuBzhbBEQ5yn/5uvX7ETFnH11ueHfwybDQTeEops= X-Forefront-PRVS: 0714841678 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(50226001)(47776003)(64706001)(5003940100001)(19580405001)(105586002)(87976001)(62966003)(101416001)(50466002)(2950100001)(106356001)(189998001)(5008740100001)(33646002)(48376002)(66066001)(46102003)(5004730100002)(77156002)(92566002)(50986999)(36756003)(76176999)(5001960100002)(40100003)(122386002)(229853001)(97736004)(4001540100001)(42186005)(5007970100001)(77096005)(2201001)(76506005)(81156007)(107886002)(19580395003)(5001770100001)(68736005)(5001830100001)(5001860100001)(4001430100001)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CO2PR07MB617; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CO2PR07MB617; 23:m/tiq1ttrIO9Z/u/XHufRuorD5d8PUznrBRgdv1rRC?= =?us-ascii?Q?8uOAou11vcvyJZMGpa7oo5EUtQ5TZS3V0jOrIExvwkDrqNmKwzMazl4T16Pr?= =?us-ascii?Q?q/7XdPP9u5rKZLjYylQsEkFGIBfOcLCPsllHVnM7W6x88pgzOPxLL7bDb6a2?= =?us-ascii?Q?nx1Xgy7g5E6KxvB+2KMeeQ2uYr5C4BFiJuLWTMd4bhiBJWzldaBAii6a9mas?= =?us-ascii?Q?3gQ1us+aRFYLk9028Vr2Pbgk9cjWdUQ/zNPxeeG7yiNrjWUxLLI69GWHikoc?= =?us-ascii?Q?txh/m/5tAO3EbTnLUn7RLw3yu5FqDIuc3thJlRd26B0SyvpghlgLIlQP3K8x?= =?us-ascii?Q?4rfRdDUjiFpXyqXvLrM8HcHeXtpkxuoimGz7Nvy8Ci731yuOSCD50GTIGTwM?= =?us-ascii?Q?jmrYwOHRgBZAhbUBCuYligWt6eMTMiI77HfSJE4NOXEJKNJ+6cVw7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9OZjxqrO34DE=3D?= X-Microsoft-Exchange-Diagnostics: 1; CO2PR07MB617; 5:UP/3DIxZ3Yu8wzvQ/q+OU3eTuiSa24FP6Hb/1VmSIbhTGAW5Ea/QJY4YiNEMqqu+BSEavQWWCSaZSjuFv5iXiUn3Imti2EAyfHg1QTKv4Lv+L0Uh2oQWx/XnkOr7PQ4f9m7L6pQRfAQObkdk1AslTQ==; 24:okJw8SQHWcMaWOmE5qjqgXoxVjqP0qGgbTEIbIw+8GYDvJqh3QTgG3VG91k2iAcFEsh3Xb+DUwTfS5rom1llSYPX2UgHCRbGh8CM/Vm6dAk=; 20:IAyZNrDBxShOJkTYW1OMlQVfiB1UGIZQ49vMW1KxvDdFeAt/2MbwMesm7pewIcS8DpZ/SfJj/Ms6ZHNfZnezCw== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2015 22:18:16.5609 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB617 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150929_151840_199242_C5394BEC X-CRM114-Status: UNSURE ( 9.25 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yury.norov@gmail.com, klimov.linux@gmail.com, Yury Norov , apinski@cavium.com, philipp.tomsich@theobroma-systems.com, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Pinski Set COMPAT_USE_NATIVE_SIGINFO to be true for non AARCH32 tasks. With ARM64 ILP32 ABI, we want to use the non-compat siginfo as we want to simplify signal handling for this new ABI. This patch just adds a new define COMPAT_USE_NATIVE_SIGINFO and if it is true then read/write in the compat case as it was the non-compat case. Signed-off-by: Christoph Muellner Signed-off-by: Philipp Tomsich Signed-off-by: Yury Norov diff --git a/include/linux/compat.h b/include/linux/compat.h index a76c917..0a25d90 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -24,6 +24,10 @@ #define COMPAT_USE_64BIT_TIME 0 #endif +#ifndef COMPAT_USE_NATIVE_SIGINFO +#define COMPAT_USE_NATIVE_SIGINFO 0 +#endif + #ifndef __SC_DELOUSE #define __SC_DELOUSE(t,v) ((t)(unsigned long)(v)) #endif diff --git a/kernel/ptrace.c b/kernel/ptrace.c index 787320d..04799aa 100644 --- a/kernel/ptrace.c +++ b/kernel/ptrace.c @@ -652,7 +652,7 @@ static int ptrace_peek_siginfo(struct task_struct *child, break; #ifdef CONFIG_COMPAT - if (unlikely(is_compat_task())) { + if (unlikely(is_compat_task() && !COMPAT_USE_NATIVE_SIGINFO)) { compat_siginfo_t __user *uinfo = compat_ptr(data); if (copy_siginfo_to_user32(uinfo, &info) || @@ -1140,16 +1140,26 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request, case PTRACE_GETSIGINFO: ret = ptrace_getsiginfo(child, &siginfo); - if (!ret) - ret = copy_siginfo_to_user32( - (struct compat_siginfo __user *) datap, - &siginfo); + if (!ret) { + if (COMPAT_USE_NATIVE_SIGINFO) + ret = copy_siginfo_to_user( + (struct siginfo __user *) datap, + &siginfo); + else + ret = copy_siginfo_to_user32( + (struct compat_siginfo __user *) datap, + &siginfo); + } break; case PTRACE_SETSIGINFO: memset(&siginfo, 0, sizeof siginfo); - if (copy_siginfo_from_user32( - &siginfo, (struct compat_siginfo __user *) datap)) + if (COMPAT_USE_NATIVE_SIGINFO) + ret = copy_from_user(&siginfo, datap, sizeof(siginfo)); + else + ret = copy_siginfo_from_user32( + &siginfo, (struct compat_siginfo __user *) datap); + if (ret) ret = -EFAULT; else ret = ptrace_setsiginfo(child, &siginfo);