Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759652AbcDERk5 (ORCPT ); Tue, 5 Apr 2016 13:40:57 -0400 Received: from mail-am1on0079.outbound.protection.outlook.com ([157.56.112.79]:52031 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1759477AbcDERja (ORCPT ); Tue, 5 Apr 2016 13:39:30 -0400 Authentication-Results: spf=fail (sender IP is 12.216.194.146) smtp.mailfrom=ezchip.com; mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=fail action=none header.from=mellanox.com; From: Chris Metcalf To: Gilad Ben Yossef , Steven Rostedt , Ingo Molnar , Peter Zijlstra , Andrew Morton , "Rik van Riel" , Tejun Heo , Frederic Weisbecker , Thomas Gleixner , "Paul E. McKenney" , Christoph Lameter , Viresh Kumar , Catalin Marinas , Will Deacon , Andy Lutomirski , , , CC: Chris Metcalf Subject: [PATCH v12 08/13] task_isolation: add PR_TASK_ISOLATION_ONE_SHOT flag Date: Tue, 5 Apr 2016 13:38:37 -0400 Message-ID: <1459877922-15512-9-git-send-email-cmetcalf@mellanox.com> X-Mailer: git-send-email 2.7.2 In-Reply-To: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> References: <1459877922-15512-1-git-send-email-cmetcalf@mellanox.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:12.216.194.146;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(106466001)(5008740100001)(48376002)(50226001)(47776003)(33646002)(189998001)(2201001)(50466002)(4326007)(19580395003)(586003)(19580405001)(1220700001)(1096002)(36756003)(85426001)(105606002)(86362001)(575784001)(229853001)(5001770100001)(2950100001)(960300001)(6806005)(5003940100001)(92566002)(4001430100002)(87936001)(76176999)(5001970100001)(50986999)(104016004)(2906002)(42186005)(107886002)(921003)(2101003)(1121003)(83996005);DIR:OUT;SFP:1101;SCL:1;SRVR:VI1PR05MB1534;H:ld-1.internal.tilera.com;FPR:;SPF:Fail;MLV:sfv;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;DB3FFO11FD039;1:gPv4qsBDNZgLKvqAsmSgl3+avsKVJqlA3UglERYW+kYgid+WZkStbZ/Oei1P6IMR305T9Rm+QCA6Bees6lp1Tg1QAgaunphR6OcUfRe7itbkb8V/Dn8ntJtS5Dk9VY0393Z5sZZPFmSOYhY/rUw5q43ZbEgdW+K6o6Lhw3UXwtyqjM59KULE0uRA6dYKkqow3zVFzwqFLCV2Te4E+uNahggdhEDk5IMkFNDwwyJqBFzpXfLKvClR4bU2qaCWCh1jq6Gjkkjm8Oh18F+pBG6URidO1HYqmPqhCnYZctpDXIBrxpxDqhPxCPF+vupsfLxzfY07yp3x7IfN5Zf4pr+AK6VHsP8tGXGOALc9e3zTVNZz86Zroy3L0gWs7Uybb4/0P9igp3EWyhYy4k1Y5VhTvbK2u3g3+EE3+GjroYThUqOorVJEQSCHdUJf2MeeVTy6HMB1Oy31W3TTouTznG8u/dhj5p8bO/PK92Iq4a50a2OafAKaAi5pHFs1WvCtAFUKMGywyyaIABlIFYmV5i9VA05aN8jVTJ+ZdcKmZGniSNN2uX5l+VXlnA6rGnAiNDIjQVL1qsT/V0y1QvkomivnICTN9pWLkzlxkAcStV04QJOnWoCj5BDkBz7Qkp3osiqxdSMFam1mqe7dRTMP2+ujpg== MIME-Version: 1.0 Content-Type: text/plain X-MS-Office365-Filtering-Correlation-Id: f7c0aabe-df86-4c5c-a224-08d35d793822 X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1534;2:7hcjYFq6kvuqsKlYGgE/6P91EjQT9STSJkxNZYX4DY+8v1za3CxUp8XTR7sZLWJ+3FSKv19iApHb2OB0YV+hHv8gk+yGsAEEiuEcCwFhcUCvmACvyhh6RcfQWjupjnfRo/+nEuEGUT1onq8RPJXmm/WM1OP9IJwW+agzRkJr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MB1534;20:EsGuO6cx0GUMJygpMNt9OJPAFVTA9MBPdN2NNaIetM4PJEeVMtXMA6hTKo9EZtlwcJVKcKWgLY8ywWPHBgP4/gh+PcsvHT6PLYeFS97HlVi6KaXgX8P9FHoYj/i0bH1rHeXcruTvwERTMoLUaotd01XMwkZdwsRND8saSL6esV0psONCw/DMnNX0lItLKU77tsoTX7KMF4WuGNQkWXkzEOpQlqZkTEp8U8MRRteTjeulPcTqxVdIDAxmwHE3naCmAfNMxczwwNOTt1YymUW+FQL3EwJpa+WsOukqf7LuixYoD7BpsDM8/oWvHiBiZH/+PKucyLASSvrZnMehvu4ajQv08GylB+Ov68lAy2NAkSFdohInF2IC5z11xE1d6+iJptPyO+ijEFfZKA0FcwWW3SIGhQn9sH8jvTuxHbHTuFvLhHOG9F22gdopn6/cotNuZJIbfPG/tVzYUrY4ZLdOxY5ZoajdN7wjY5JZ49dI6/Vqb1POt6UYx5TKCd+gTcWc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(13018025)(8121501046)(5005006)(13023025)(13017025)(13024025)(13015025)(3002001)(10201501046);SRVR:VI1PR05MB1534;BCL:0;PCL:0;RULEID:;SRVR:VI1PR05MB1534; X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1534;4:b0prxebZckNPHNgNYxfWAPcM1h4Hu8iKcBGJ2aur3AtivRZvKWVe0T4+bWu1yjD1GnuEG8oAORGFjo2io7ALiaxo98Rh7vO8ag0q4v9HbC3XTemeWqwV2kcBhEglsdLmsXv8+xxWrLGgkyJNE/hNGfk7UJC6hnFA6byFg6HurccIMQdUZBRB32XhA8nLrdRbhr8HRNpwCXFF2KAMtf/ksb+9sZ0/Aw/Qu1PU7u/Z2z47k2VR8kHlAVhDI1WGWe4CBRZPVT7h76LnLbbRIXzroEl8TSFZISiiYTtNBuM7vcPoAxc1FBul/4Z0dN+Zstlrh378xF4z1+CFHkFACKApVkL3aDyhKJkcBcHb7oP6xKTW0fC0qL+A4xqqPk7cotkc+Qrkwi8fsciOJVK1884ZuA+SQQ+27gsPeERcactQaCYyem71vmllJFChYjmnAfrZyubSr/MULR1ulTvfA0apZQ== X-Forefront-PRVS: 0903DD1D85 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;VI1PR05MB1534;23:POXAANd76ij0SjYdZlzWWciC5rjVqIuW+mfPC4/ER?= =?us-ascii?Q?8/qd5ADNobJ24pOywn/jLvmBOsUJ6i6bu1kq0c9xvOwB1FngNJgZWdyQ2oa4?= =?us-ascii?Q?Ds0kE9RiIHUk1P3nnMgwmWurJsA4Zksvk/2KFpLdl23oq1RbovZIU9UneYn6?= =?us-ascii?Q?0eWiP+SMXdiEm6F9DIt2jRtarySFFPNZxzUJJphHkrdCihySyI3FGrathDLV?= =?us-ascii?Q?cjKeZft5gc2Ou2mo3hdc6cDKAttlhvpJe7lpW5UZXtwCQgwl2Gd+qr/C225z?= =?us-ascii?Q?aHfxyHkRbkD3o400oi03v2i5MmBVOvskajRKKWw/2dwlhJe/zcu3rQZNqt/Q?= =?us-ascii?Q?SyTTFInWBlcNSdqEuRXmmbDlkbfPz/NJ6PXyhXF4aFFpey1Yl5nrHTYcuyxq?= =?us-ascii?Q?2F0khlauW+JN3XOvEIdHUI6mHF/tnS5w0f3qlsAZuL1RQMHThZEyCwY9clRz?= =?us-ascii?Q?5GjqBxEKXTtkGRSFOEECXwZzqzdpBCl70/ldkynvJcUB4fg+JT/Ky2QfDvCQ?= =?us-ascii?Q?hxJCLkg36vVb6keYolYDofM0tiLwmj/gDmJhqfhnuxLwqthRVPeM61ybrzrA?= =?us-ascii?Q?/qSyb4VAwCILXcEluejebsjIwxx+MnragT9qyoeulw82AEqCIsY/tpE4Yucv?= =?us-ascii?Q?Iif6hOyVjIZn4q+84MXTJt+bvHR7TvFfYqKiSdGLMTagpb1VPWFCAcvQJwrx?= =?us-ascii?Q?u20WUiEmRVCmNVk869k3P0Yu9Z6T94LgHLhPtLkh5WylIMPjOckHBP30+aEk?= =?us-ascii?Q?+6iMgt/KFYMJlgLF0U1E/rNqpWxX2XhkHwqmN3plNzGRdBTye+KZoeSDfYXs?= =?us-ascii?Q?ysyNumIwqnX0HV0VRKcQQ1OUBssAUiMcdcIVFpxAlO78XzkSbMHWWTGBn8+C?= =?us-ascii?Q?Qxlz0DNHCVY6PBVNaZIK7vnbM4Ext2ocsg65YRVEXX12UO5WzvkCDxdSAhJg?= =?us-ascii?Q?gN7d0trm8gw5c+RRP3pn9fjRX+KU9F4RzVoWxOGJDg5hOv6FyHXYVJxixgQP?= =?us-ascii?Q?vuV/pw06fgp4g4kNfc/ihKe1d5x1y0XXUxTl+5LAelsEQOwOJFhwt4h0TdBd?= =?us-ascii?Q?ziQeLBBd/zbds+BMLA4ExcfFJKJHTOSDEXBNvJX8zBiUa9tpYJjFMnuL08eY?= =?us-ascii?Q?pS78HcMTeqmLf+xllroecvb27a3rRNEukAMHdboR2gixqhrEmGyREXaYIVov?= =?us-ascii?Q?20LPPPxmOrGbYGvKAVfPY5po2glXVptrvZfLgtP4Cnz4jMbJIEts2zYgg=3D?= =?us-ascii?Q?=3D?= X-Microsoft-Exchange-Diagnostics: 1;VI1PR05MB1534;5:juKf59FmhZll2RPbbWumKcdd0LDsPcjJncPzS0OdArYekgPzQVzfm0MGVJUpgYrhQbvGwC8WsjKvORGIe5NQwddCw7LL9EVMJGRW52JT14dD5LsEBHVx6QrxMiea7mQDwrCsTAWp5WbIWICbqkDVgQ==;24:2/Jzp62vcbYZCOEcCarVfZPajSKwA24VUFX93dMtU//7Gz+o2fWH/t+YcnVrGaTd3OFKPj2PreCNP1f/H60qr7N9q29CEGAfDBsktVmFT6Y= X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 17:39:19.9379 (UTC) X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=a652971c-7d2e-4d9b-a6a4-d149256f461b;Ip=[12.216.194.146];Helo=[ld-1.internal.tilera.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB1534 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2253 Lines: 64 When this flag is set by the initial prctl(), the semantics of task isolation change to be "one-shot", i.e. as soon as the kernel is re-entered for any reason, task isolation is turned off. During application development, use of this flag is best coupled with STRICT mode, since otherwise any bug (e.g. an munmap from another thread in the same task causing an IPI TLB flush) could cause the task to fall out of task isolation mode without being aware of it. In production it is typically still best to use STRICT mode, with a signal handler that will report violations of task isolation up to the application layer. However, if you are confident the application will never fall out of task isolation mode, you may wish to use ONE_SHOT mode to allow switching from userspace task isolation mode, to using the kernel freely, without the small extra penalty of invoking prctl() explicitly to turn task isolation off before starting to use kernel services. Signed-off-by: Chris Metcalf --- include/uapi/linux/prctl.h | 1 + kernel/isolation.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/include/uapi/linux/prctl.h b/include/uapi/linux/prctl.h index a5582ace987f..1e204f1a0f4a 100644 --- a/include/uapi/linux/prctl.h +++ b/include/uapi/linux/prctl.h @@ -202,6 +202,7 @@ struct prctl_mm_map { #define PR_GET_TASK_ISOLATION 49 # define PR_TASK_ISOLATION_ENABLE (1 << 0) # define PR_TASK_ISOLATION_STRICT (1 << 1) +# define PR_TASK_ISOLATION_ONE_SHOT (1 << 2) # define PR_TASK_ISOLATION_SET_SIG(sig) (((sig) & 0x7f) << 8) # define PR_TASK_ISOLATION_GET_SIG(bits) (((bits) >> 8) & 0x7f) diff --git a/kernel/isolation.c b/kernel/isolation.c index 1c4f320a24a0..d0e94505bfac 100644 --- a/kernel/isolation.c +++ b/kernel/isolation.c @@ -205,7 +205,11 @@ void _task_isolation_exception(const char *fmt, ...) va_end(args); task_isolation_interrupt(task, buf); + return; } + + if (task->task_isolation_flags & PR_TASK_ISOLATION_ONE_SHOT) + task_isolation_set_flags(task, 0); } /* @@ -229,6 +233,9 @@ int task_isolation_syscall(int syscall) return -1; } + if (task->task_isolation_flags & PR_TASK_ISOLATION_ONE_SHOT) + task_isolation_set_flags(task, 0); + return 0; } -- 2.7.2