From patchwork Tue Jul 29 03:38:29 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Lutomirski X-Patchwork-Id: 4638341 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 48EF3C0338 for ; Tue, 29 Jul 2014 03:42:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8994D20158 for ; Tue, 29 Jul 2014 03:42:19 +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 D9D7120173 for ; Tue, 29 Jul 2014 03:42:17 +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 1XByG2-00035T-Kg; Tue, 29 Jul 2014 03:39:22 +0000 Received: from mail-pd0-f173.google.com ([209.85.192.173]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XByFr-0002yK-K7 for linux-arm-kernel@lists.infradead.org; Tue, 29 Jul 2014 03:39:11 +0000 Received: by mail-pd0-f173.google.com with SMTP id w10so10978785pde.32 for ; Mon, 28 Jul 2014 20:38:50 -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=MEjsYcAIRskgqLe2fb8RNMBo1NP3NoMu1cUcegL3r9E=; b=LtojnBrNpbYCoB2oqWUmDtpm+YRv8iJHhC+FVGi2O+yzjTr+WBUjMOuEa8/kOWpPCu WzfWrovLQOxuwD7dw88kEDz+QlKQikWiZ3gBofbA3WJrH/emxvMv8xrnlLONwrQsG01b r1ekP+jkpdgPFOjluMFQnQelxPKrgjsR/cpZfefYEyWf0dTj2CCgQVBY1MniVDtBlDxt 3XHMiBBWoWPQ/7W5fev74Qz1IWWIrV0IFZbAM/O/fIDLl2P+g41fuwnYIHUIKULEiLVR BbrK9z3a1j8P42Tophe8UeUO0SrSBqUDP7e4NBmi2ykUYhnDx9mc9/WNN2yrmJbz6JLd CyEw== X-Gm-Message-State: ALoCoQmz8Trood0hmL8Pd5Qbkue4MVCj838vsU0bzSBUKcDkJEcax79zr7DDUReKhIdKNrLsAcAh X-Received: by 10.67.23.165 with SMTP id ib5mr42712837pad.60.1406605130332; Mon, 28 Jul 2014 20:38:50 -0700 (PDT) Received: from localhost ([2001:5a8:4:83c0:fd15:6cb4:fa7d:1e89]) by mx.google.com with ESMTPSA id nt15sm26759892pdb.63.2014.07.28.20.38.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Jul 2014 20:38:49 -0700 (PDT) From: Andy Lutomirski To: linux-kernel@vger.kernel.org, Kees Cook , Will Drewry Subject: [PATCH v4 2/5] x86,entry: Only call user_exit if TIF_NOHZ Date: Mon, 28 Jul 2014 20:38:29 -0700 Message-Id: <7123b2489cc5d1d5abb7bcf1364ca729cab3e6ca.1406604806.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-20140728_203911_675930_A592E476 X-CRM114-Status: GOOD ( 12.74 ) X-Spam-Score: -1.4 (-) Cc: linux-arch@vger.kernel.org, linux-mips@linux-mips.org, Frederic Weisbecker , x86@kernel.org, Oleg Nesterov , 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=-2.6 required=5.0 tests=BAYES_00,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 39296d2..bbf338a 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