Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755063AbbKQVUm (ORCPT ); Tue, 17 Nov 2015 16:20:42 -0500 Received: from mail-by2on0079.outbound.protection.outlook.com ([207.46.100.79]:10899 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755046AbbKQVUi (ORCPT ); Tue, 17 Nov 2015 16:20:38 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , , , CC: , , , , , , , , , , , , , , Yury Norov Subject: [PATCH v6 12/19] ptrace: Allow compat to use the native siginfo Date: Wed, 18 Nov 2015 00:16:52 +0300 Message-ID: <1447795019-30176-13-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447795019-30176-1-git-send-email-ynorov@caviumnetworks.com> References: <1447795019-30176-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [95.143.213.120] X-ClientProxiedBy: AM3PR01CA047.eurprd01.prod.exchangelabs.com (10.141.191.37) To CO2PR07MB620.namprd07.prod.outlook.com (10.141.228.156) X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;2:Xq4e4DkF6cd6D52p4oIXzh4M2GVbuUhLMHNuV6/zrJ+RxVxKLXucz8SRsZbg1pTzVq12jyjH80pC3EvLEpT08Ql9LaHn+OGmSWX1kvq6JtmUN0Bc/ffTuNx32BusJyD80avQnZ+5xgNjbiuO9bowDzBzGk100hMz+E2zzPUidTE=;3:c3C2JXf5qdFuZIF7YYORg62lkTZSAyPCIcRAVjoKC+ALvGgQKZ+SU92abq1jne5Q9q5/36/nszzFnyHDnv1mU6K5Iw5UU6+vyXAkcwQEZsGYQlpEn/AYiYhn/keI+uVNUQsqtq4zj7oM6EE0iYdsYQ==;25:Xt7NYcQ3HPiaNzansEFWWzTYW4O56oMrQr7/hk/qmqybk+fpvLbCUW12STQdl4IT47r0BFE3Kf7KEPuUbBpoz3BALeIFneXu7XkLVD0JtW6lsuCDj28tjpE5yt6woVtGJnW3BpIPGUYbPWR5Q2D7BH9ubGLURjz1SMJpKO/FhpgK4bONkGDfOV4aRjG5rPQ6D1oRdI9EzmOoLx7r4fBxWd78nKs+zQN6LeaZGbJ4NoXepsQbpYgwHVZBguEPg0HvuH94R30Qp/QDxEEKRsOdzg== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;20:18RSkIa63MXn/lxmJ6o5nEZBCjIxFSErHamZ2O8/4MlYH39UC5IVrQpReLLoEGquHdLufC36boPXerJuBC3d2FeOKjtfggCRJe6vsaLait9CHkx8F3yFTzbf0eQb3ipvIWdWJOBYH82yM923gm/v4JxI5PF9d//Ya4/Y4/s7+Bpgbr1re33Bo/wPLWx8GNNEoDLpdGOyKZYaMDa3YAWZXItmJOWsRqqCYxsHarzRp2FXb3YC9tQAe/7nv/HFrcVeX5+rNmdumh4kF9UMbALs03x8DfWFloNB+XpAjj53bw+S9qRBl5a04MNjP3QHY9cB/5L0za3/UVpBAgG+XoNIHINrT3GPvQ7ufMPF442tvuLoJqOnMpR4N0SHLeISqZ5xC5eiCdRJPYeHTGcVI0MwUz3E6FpBHY0OAkOuY+t42o62RufrEnjb/0Gtmkph6ydFcGKhcCtEGKgBLhL/sZjFT3BWlQ3U7BeOWCuBRaFDztQWWQVB/p8iqmX20gOTSPusKGmIdWTu0IiLVVEfTXDY9IQEjr/sHV7ANPOHlyPn186BgjV1SVH6pmiW+wpoEvbeGhC+9o8ej7c+vcdwqkTMfD2RlgFZoRKV9dPdPcZx23U= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(3002001)(10201501046);SRVR:CO2PR07MB620;BCL:0;PCL:0;RULEID:;SRVR:CO2PR07MB620; X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;4:nmd/ZFY51suG2LQ/rvFmZFR+ekAVd64axTKd3jNf7NaqhOIcRJ4d1F9U6kKiVmY7jHdesCVOWInfCyr/MMjoEZjJZFCnHK4rkeqAfhxKN72zUl/qtR4FNx03JYyCRZZpa5NmzjkUguL0GkrybyNKnLQo2PBLydgLdI713YEmXaOhg6GfLASoIWprN++8P9RxqQFZzmdsnDRHmXxUG4kbS6f9Y3IzRAT0FApxetJswd3pLMcMknzPM7U4RX8hYZSac9qi1ErQ9Dh2B7oRccpZ/8OiucdjOVngtloTg6lcbESGSNGRyj0lpuZ5IEdB5UrH/02p/HmvzlwmQkf9N6DqHNNSVzy/uuNWjB0BL3aDO8/bNHb869cJ+H0YNReencBk X-Forefront-PRVS: 07630F72AD X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(199003)(189002)(586003)(5007970100001)(76176999)(5001960100002)(81156007)(48376002)(50986999)(189998001)(97736004)(92566002)(5003940100001)(106356001)(42186005)(77096005)(40100003)(36756003)(50226001)(2950100001)(4001430100002)(229853001)(66066001)(33646002)(5008740100001)(105586002)(5004730100002)(19580395003)(19580405001)(87976001)(76506005)(5001770100001)(47776003)(2201001)(101416001)(50466002)(122386002)(107886002)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR07MB620;H:localhost;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR07MB620;23:MT38YyIJoH+yKR/uYl/Sey6Kk+QRqUa+7g9yFHQv6L?= =?us-ascii?Q?mqUehvnyczys2+SME43h4KeuZCM8erGLJwrpnszZAenuDUne3BFPi6dzV8MY?= =?us-ascii?Q?oaHc1eY4krlXJtMi1/TFfea+Ma8bsFPLGsGXhtoto4pZoyANLk8Zzcsfj+S2?= =?us-ascii?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ZaZX+P+RV5KqNcHGQ80VcX1uP?= =?us-ascii?Q?CSFWXYMCmWR0ccD318MmSEjnq0e5pV+7q/8ZtlIqs/1rpsup8eOhEEklpKmF?= =?us-ascii?Q?dbQuT4S2c=3D?= X-Microsoft-Exchange-Diagnostics: 1;CO2PR07MB620;5:t8D1ZFXNRUTLIRpQtLClJqKUuGhoMw5dVBay3SLsjbg6cup4oA3xYKnDIerFhbBZgTEizUF1qV7NNsqBUJTIRGH/DI5lTmEyNHLG2+Yh6BnL1gVTJgerx5Gt0vH1pm95xrz3bB9ZQwWNLt5l4/TxOw==;24:Yp58E4VU4xnRgFMBIgHeroXyCoAxJtvXJSZ7JtJFmVGWTTPTU5MyRcfdWFi6FHKC+RtHyMVLb/0T91WYuImp68am3R0C7zihnw7QDJRG9Io=;20:F4ZmTk/lBbpeXS/2rjTN45cbI1L3DZPW+gK2p2ulIuZYWxoyZYHO94e/3hDh0NHZNmLFWwdXjfcDhSbhClsRHQ== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2015 21:20:35.6722 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR07MB620 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2888 Lines: 90 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. Reviewed-by: David Daney Signed-off-by: Christoph Muellner Signed-off-by: Philipp Tomsich Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski --- include/linux/compat.h | 4 ++++ kernel/ptrace.c | 24 +++++++++++++++++------- 2 files changed, 21 insertions(+), 7 deletions(-) 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); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/