Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2557449ybh; Mon, 9 Mar 2020 08:15:22 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtssZL/MgLAGPsM0fk/AszIYN3PpW59yBZB7YtsRKkJ+yr3g8FqF40La4JxOMk0oWqQ3Hwq X-Received: by 2002:a9d:6d96:: with SMTP id x22mr13479095otp.264.1583766922344; Mon, 09 Mar 2020 08:15:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583766922; cv=none; d=google.com; s=arc-20160816; b=O8aI6ZLbcLNix/5EvkySTxmc89ctWvRM0QBtQGPpiIR11+AGFfvPVkWoVL0J6GrHLY yio/+H0xVNc7gXDDT8WBhaKe8NqXhv7maVAlJK7qlV108JKMwOw+Ll//xk9J4oOfM0y3 geEOt3XsiVoc++I0vs564enT5KsIEumXQwFo2KZt000H/RIZLeM0mL9wMzAzNo7nrzkP ndl9ceMG/hq7opObg+2zpwQatyZMsokjczgSaz12nQwrUAdM+ER/DFFEdmXPf/AKa8on FLsBxx1fis1tW48oTV9VsRD5yeEE8GCm5zq+Lj1cFd9pmNmnzOVtdESf8eB6v0+n9qaV DqpQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9MDY0T8Jg+KEXJ/Tl9dbWkou+DLzeuaf41uXZma9vjA=; b=TCD2kja0VEBJxTTsJCxip8q7KRG5cNkXKoQYw2M1AyxLMycqO42UP3yay7WZ2dh6my DNkIfPl0dvUK6hSpc89UOd8j6Qr5oULC4vC/+MDp0zLa1HiX4I/ZbsGuNsIMlydtiotN q+KFHe+vFPrj8wQfuVuphbsh963jZR6x+ZdK2ELFqaAezLUKIBNCoJ7y+3jtaQmrlgdZ TU9S/jb+QVKr+hxhLUqpIVBD7Xe8SAyPzCL0217cqVYwoEUE3ZCmAeO062tgT0jGgPcK ALvFBLoY8ebTLFfkNsKYgWBcymQM5RO/VQTBZ0FZDk0POR0t5M66Lqb44hfYR4hW21wn Y7wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wEKCt7JJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g15si2076374otr.90.2020.03.09.08.14.57; Mon, 09 Mar 2020 08:15:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wEKCt7JJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726874AbgCIPO1 (ORCPT + 99 others); Mon, 9 Mar 2020 11:14:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:52894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726715AbgCIPO1 (ORCPT ); Mon, 9 Mar 2020 11:14:27 -0400 Received: from localhost (lfbn-ncy-1-985-231.w90-101.abo.wanadoo.fr [90.101.63.231]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 553ED20873; Mon, 9 Mar 2020 15:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1583766866; bh=nhUgTVaZ4dhDdGuramg5Do6V7GwUZTYyOK/UzLAFK68=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=wEKCt7JJT/RhEzhvq40PMbCwa3+6d1xAQRbxdhzbGnRBLGsBot4S2yoKzl0nEi8PQ OH7em80ZpzK45tm5LwN9L56Qw2ECv1yWc3J3DrTbKSSfBxuAmJKXqyzWsUurIQRZNh iSPQZ/YhvHdMZB8aXk+LPPFKFYxApqQdz7e7Eefg= Date: Mon, 9 Mar 2020 16:14:24 +0100 From: Frederic Weisbecker To: Thomas Gleixner Cc: LKML , x86@kernel.org, Steven Rostedt , Brian Gerst , Juergen Gross , Alexandre Chartre Subject: Re: [patch part-II V2 02/13] x86/entry: Mark enter_from_user_mode() notrace and NOKPROBE Message-ID: <20200309151423.GE9615@lenoir> References: <20200308222359.370649591@linutronix.de> <20200308222609.125574449@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200308222609.125574449@linutronix.de> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Mar 08, 2020 at 11:24:01PM +0100, Thomas Gleixner wrote: > Both the callers in the low level ASM code and __context_tracking_exit() > which is invoked from enter_from_user_mode() via user_exit_irqoff() are > marked NOKPROBE. Allowing enter_from_user_mode() to be probed is > inconsistent at best. > > Aside of that while function tracing per se is safe the function trace > entry/exit points can be used via BPF as well which is not safe to use > before context tracking has reached CONTEXT_KERNEL and adjusted RCU. > > Mark it notrace and NOKROBE. Ok for the NOKPROBE, also I remember from the inclusion of kprobes that spreading those NOKPROBE couldn't be more than some sort of best effort to mitigate the accidents and it's up to the user to keep some common sense and try to stay away from the borderline functions. The same would apply to breakpoints, steps, etc... Now for the BPF and function tracer, the latter has been made robust to deal with these fragile RCU blind spots. Probably the same requirements should be expected from the function tracer users. Perhaps we should have a specific version of __register_ftrace_function() which protects the given probes inside rcu_nmi_enter()? As it seems the BPF maintainer doesn't want the whole BPF execution path to be hammered. Thanks. > > Signed-off-by: Thomas Gleixner > --- > arch/x86/entry/common.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > --- a/arch/x86/entry/common.c > +++ b/arch/x86/entry/common.c > @@ -40,11 +40,12 @@ > > #ifdef CONFIG_CONTEXT_TRACKING > /* Called on entry from user mode with IRQs off. */ > -__visible inline void enter_from_user_mode(void) > +__visible inline notrace void enter_from_user_mode(void) > { > CT_WARN_ON(ct_state() != CONTEXT_USER); > user_exit_irqoff(); > } > +NOKPROBE_SYMBOL(enter_from_user_mode); > #else > static inline void enter_from_user_mode(void) {} > #endif >