From patchwork Fri Sep 5 22:13:53 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 4855131 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A8112C033A for ; Fri, 5 Sep 2014 22:17:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ED17620225 for ; Fri, 5 Sep 2014 22:17:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 24D712020E for ; Fri, 5 Sep 2014 22:17:10 +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 1XQ1m9-0000aM-Gn; Fri, 05 Sep 2014 22:14:37 +0000 Received: from mail-yk0-f181.google.com ([209.85.160.181]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XQ1m3-0000Py-3l for linux-arm-kernel@lists.infradead.org; Fri, 05 Sep 2014 22:14:31 +0000 Received: by mail-yk0-f181.google.com with SMTP id 131so7396800ykp.12 for ; Fri, 05 Sep 2014 15:14:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=GtN0w/F4UwQCvEEMReqhKvgZs5d/wpONl4gOxqwrvSs=; b=hyHXUckQ/kJufGg3qZQmaxLPCaq6duMWaxwIj/zV/1kdG1ggh7hogJJIdtvIRAhGCh uPiMdiOxqaYBI8/BE1H9wFUg19QX6K8dRG2ljXK4oGsynduOj3hjjIECqcCbwKYAoxg7 pYRaY7Gl2nc7E+UNdKjf/LP1Vf62JQ1A7rUpS+Smm9mPp+oXMDOYnjr3s7cFatKjOIJF KL+lmC0QwH7zDiMbHwI4HfzItjr2ZoFm6d5QeUFlfsgUmZAtbgbFM5MSzxiWpP5Jqe7a iv71RQM7i12K3yn6mCfgyVsY4ApcqSos2jvPvshentjWt/ICAx/73Se2jsQRxn/u4Env V/+A== X-Gm-Message-State: ALoCoQl5FGZql/AY8WY/QAbZlxMWcs3nY42iFmkelWIMczExrVqG73o98ilxm0hDWKVx4PriCRVr X-Received: by 10.236.26.196 with SMTP id c44mr18200485yha.15.1409955254268; Fri, 05 Sep 2014 15:14:14 -0700 (PDT) Received: from localhost ([2602:301:77d8:1800:bd9e:fe09:e642:968]) by mx.google.com with ESMTPSA id r77sm1289167yhr.28.2014.09.05.15.14.12 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Sep 2014 15:14:13 -0700 (PDT) From: Andy Lutomirski To: linux-kernel@vger.kernel.org, Kees Cook , Will Drewry , Oleg Nesterov Subject: [PATCH v5 2/5] x86,entry: Only call user_exit if TIF_NOHZ Date: Fri, 5 Sep 2014 15:13:53 -0700 Message-Id: <0b13e0e24ec0307d67ab7a23b58764f6b1270116.1409954077.git.luto@amacapital.net> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140905_151431_225956_5D8F2C0B X-CRM114-Status: GOOD ( 12.41 ) X-Spam-Score: -0.7 (/) Cc: linux-arch@vger.kernel.org, linux-mips@linux-mips.org, Frederic Weisbecker , x86@kernel.org, Andy Lutomirski , linux-security-module@vger.kernel.org, hpa@zytor.com, linux-arm-kernel@lists.infradead.org, Alexei Starovoitov X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 The RCU context tracking code requires that arch code call user_exit() on any entry into kernel code if TIF_NOHZ is set. This patch adds a check for TIF_NOHZ and a comment to the syscall entry tracing code. The main purpose of this patch is to make the code easier to follow: one can read the body of user_exit and of every function it calls without finding any explanation of why it's called for traced syscalls but not for untraced syscalls. This makes it clear when user_exit() is necessary. Cc: Frederic Weisbecker Signed-off-by: Andy Lutomirski --- arch/x86/kernel/ptrace.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 39296d25708c..bbf338a04a5d 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c @@ -1449,7 +1449,12 @@ long syscall_trace_enter(struct pt_regs *regs) { long ret = 0; - user_exit(); + /* + * If TIF_NOHZ is set, we are required to call user_exit() before + * doing anything that could touch RCU. + */ + if (test_thread_flag(TIF_NOHZ)) + user_exit(); /* * If we stepped into a sysenter/syscall insn, it trapped in