Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2579680ybh; Mon, 9 Mar 2020 08:41:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vusciFARZq1tIP0P3ywWg0gDgkFmiT8EBvXHO6xGLYJqOO89h6x2jiyY6nWYDqX0+uBbc1S X-Received: by 2002:aca:2303:: with SMTP id e3mr11992537oie.74.1583768504224; Mon, 09 Mar 2020 08:41:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583768504; cv=none; d=google.com; s=arc-20160816; b=1H5ZljgPx6fNIQhzgs+sZMaXWgI9ttBkyYOi9JLQ0CKSm1zmH6hSE5XBxfS868CYS4 wrSTrSR/cO7AE0Oed2C3Rk9Qo8hjPPvNXzcrenXV2d69Oem9mCqoGJCtj346d9Gj/cgv sfm4XyB/GekukwETXEcBpkO3Suu85Aq3/zZie4We+gb1gjVnQeogQOeYubr7Qp+lH287 iktFrIakM6CyzWW6k719d4z5xmK5RA0Rwf5dISDPHm+d9bSILW6a83KNz0kIRru/y7uE pS057xyeBqBTsIgxqcUv14CX5L5d1eMZ7XZePDYpXQityHW4JpP4wKPi3NNtRZFmp155 TxOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=l3ih8WenXudTj2QHtrwbXgOU3KASpCTDfOp/Wrh8BRc=; b=nkYV/OzMQzwxHQoDqE6rTBh8s9P2HR1nZ2e0KVJkPNZNn3lQqV6yVWBcggaz16Y4jX cmnNYnZq9Xn8Aoc42rHBzbMXNrmdd0uU5cYyO15PD6oNEdH/jZ7vo8ZyK46gL1h6HPiV kA0MyMrISgxX2LAKvcjkWyYWikE1MBR+3rKnxcVYGvkWNFvs4QJhHlGxnbKkLBUhQ79l fQ5C0MFx75BKXHEd6ltlJ2OX9/3lXCsTZQ05O6iYxFEZC7+lR1eu0nC7/6l+ZoLQVEjt xwi3m2xfjZMYCu+G62+WkXoniIJk8lJsCF/mhX2mJscwbBey7wFyuUT9nXewqE6vZ1YM CM2A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v137si4020446oif.170.2020.03.09.08.41.31; Mon, 09 Mar 2020 08:41:44 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727080AbgCIPlH (ORCPT + 99 others); Mon, 9 Mar 2020 11:41:07 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:59492 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726926AbgCIPlH (ORCPT ); Mon, 9 Mar 2020 11:41:07 -0400 Received: from [5.158.153.52] (helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jBKWU-0002Bp-Kl; Mon, 09 Mar 2020 16:40:54 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 495871040A7; Mon, 9 Mar 2020 16:40:54 +0100 (CET) From: Thomas Gleixner To: Frederic Weisbecker 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 In-Reply-To: <20200309151423.GE9615@lenoir> References: <20200308222359.370649591@linutronix.de> <20200308222609.125574449@linutronix.de> <20200309151423.GE9615@lenoir> Date: Mon, 09 Mar 2020 16:40:54 +0100 Message-ID: <87pndl7czd.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Frederic Weisbecker writes: > 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. Right. The problem is that as things stand e.g. for tracepoints you need to invoke trace_foo_rcuidle() which then does the scru/rcu_irq dance around the invocation, but then the functions attached need to be fixed that they are not issuing rcu_read_lock() or such. While that is halfways doable for tracepoints when you place them, the whole function entry/exit hooks along with kprobes are even more interesting because functions can be called from arbitrary contexts... So to make this sane, you'd need to do: if (!rcu_watching()) { .... } else { .... } and the reverse when leaving the thing. So in the worst case you end up with a gazillion of scru/rcu_irq pairs which really make crap slow. So we are way better off to have well defined off limit regions and are careful about them and then switch over ONCE and be done with it. Thanks, tglx