Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752162AbbLUWo7 (ORCPT ); Mon, 21 Dec 2015 17:44:59 -0500 Received: from mail-oi0-f47.google.com ([209.85.218.47]:35252 "EHLO mail-oi0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751661AbbLUWo6 (ORCPT ); Mon, 21 Dec 2015 17:44:58 -0500 MIME-Version: 1.0 In-Reply-To: <56786606.6090506@oracle.com> References: <853b42420066ec3fb856779cdc223a6dcb5d355b.1435952415.git.luto@kernel.org> <56786606.6090506@oracle.com> From: Andy Lutomirski Date: Mon, 21 Dec 2015 14:44:37 -0800 Message-ID: Subject: Re: [PATCH v5 08/17] x86/entry: Add enter_from_user_mode and use it in syscalls To: Sasha Levin Cc: Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , =?UTF-8?B?RnLDqWTDqXJpYyBXZWlzYmVja2Vy?= , Rik van Riel , Oleg Nesterov , Denys Vlasenko , Borislav Petkov , Kees Cook , Brian Gerst , Paul McKenney Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3978 Lines: 76 On Mon, Dec 21, 2015 at 12:50 PM, Sasha Levin wrote: > On 07/03/2015 03:44 PM, Andy Lutomirski wrote: >> Changing the x86 context tracking hooks is dangerous because there >> are no good checks that we track our context correctly. Add a >> helper to check that we're actually in CONTEXT_USER when we enter >> from user mode and wire it up for syscall entries. >> >> Subsequent patches will wire this up for all non-NMI entries as >> well. NMIs are their own special beast and cannot currently switch >> overall context tracking state. Instead, they have their own >> special RCU hooks. >> >> This is a tiny speedup if !CONFIG_CONTEXT_TRACKING (removes a >> branch) and a tiny slowdown if CONFIG_CONTEXT_TRACING (adds a layer >> of indirection). Eventually, we should fix up the core context >> tracking code to supply a function that does what we want (and can >> be much simpler than user_exit), which will enable us to get rid of >> the extra call. > > Hey Andy, > > I see the following warning in today's -next: Weird. I wonder if you might have hit this while switching context tracking on a runtime. (Can you even do that?) --Andy > > [ 2162.706868] ------------[ cut here ]------------ > [ 2162.708021] WARNING: CPU: 4 PID: 28801 at arch/x86/entry/common.c:44 enter_from_user_mode+0x1c/0x50() > [ 2162.709466] Modules linked in: > [ 2162.709998] CPU: 4 PID: 28801 Comm: trinity-c375 Tainted: G B 4.4.0-rc5-next-20151221-sasha-00020-g840272e-dirty #2753 > [ 2162.711847] 0000000000000000 00000000f17e6fcd ffff880292d5fe08 ffffffffa4045334 > [ 2162.713108] 0000000041b58ab3 ffffffffaf66686b ffffffffa4045289 ffff880292d5fdc0 > [ 2162.714544] 0000000000000000 00000000f17e6fcd ffffffffa23cf466 0000000000000004 > [ 2162.715793] Call Trace: > [ 2162.716229] dump_stack (lib/dump_stack.c:52) > [ 2162.719021] warn_slowpath_common (kernel/panic.c:484) > [ 2162.721014] warn_slowpath_null (kernel/panic.c:518) > [ 2162.721950] enter_from_user_mode (arch/x86/entry/common.c:44 (discriminator 7) include/linux/context_tracking_state.h:30 (discriminator 7) include/linux/context_tracking.h:30 (discriminator 7) arch/x86/entry/common.c:45 (discriminator 7)) > [ 2162.722911] syscall_trace_enter_phase1 (arch/x86/entry/common.c:94) > [ 2162.726914] tracesys (arch/x86/entry/entry_64.S:241) > [ 2162.727704] ---[ end trace 1e5b49c361cbfe8b ]--- > [ 2162.728468] BUG: scheduling while atomic: trinity-c375/28801/0x00000401 > [ 2162.729517] Modules linked in: > [ 2162.730020] Preemption disabled param_attr_store (kernel/params.c:625) > [ 2162.731304] > [ 2162.731579] CPU: 4 PID: 28801 Comm: trinity-c375 Tainted: G B W 4.4.0-rc5-next-20151221-sasha-00020-g840272e-dirty #2753 > [ 2162.733432] 0000000000000000 00000000f17e6fcd ffff880292d5fe20 ffffffffa4045334 > [ 2162.734778] 0000000041b58ab3 ffffffffaf66686b ffffffffa4045289 ffff880292d5fde0 > [ 2162.736036] fffffffface198f9 00000000f17e6fcd ffff880292d5fe50 0000000000000282 > [ 2162.737309] Call Trace: > [ 2162.737718] dump_stack (lib/dump_stack.c:52) > [ 2162.740566] __schedule_bug (kernel/sched/core.c:3102) > [ 2162.741498] __schedule (./arch/x86/include/asm/preempt.h:27 kernel/sched/core.c:3116 kernel/sched/core.c:3225) > [ 2162.742391] schedule (kernel/sched/core.c:3312 (discriminator 1)) > [ 2162.743221] exit_to_usermode_loop (arch/x86/entry/common.c:246) > [ 2162.744331] syscall_return_slowpath (arch/x86/entry/common.c:282 include/linux/context_tracking_state.h:30 include/linux/context_tracking.h:24 arch/x86/entry/common.c:284 arch/x86/entry/common.c:344) > [ 2162.745364] int_ret_from_sys_call (arch/x86/entry/entry_64.S:282) > > > Thanks, > Sasha -- Andy Lutomirski AMA Capital Management, LLC -- 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/