Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2107874pxb; Fri, 29 Jan 2021 13:28:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+zy7RJVol4bDYkBS34GWMjnkoICyMu5xdc9ySOAgqA4KYRjHEz51u4Tr8QiiqTE8KP3jE X-Received: by 2002:a17:907:20a7:: with SMTP id pw7mr6478401ejb.283.1611955703812; Fri, 29 Jan 2021 13:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611955703; cv=none; d=google.com; s=arc-20160816; b=F73dIX3miD1WCmffy9D2/EEnBKGTi/mai4+uP7n/9gHordm161TY/b7xwHBE1URplx F+9MLtyVoSCZJETlWTkBlDOUE+z/NsXIgiWbDPQPGAbwFKuPzpjUUri6Fm5wl/hGLzed UVd1LE8cc1LCn9TSefyR3ljrT13G1bCX4ZvN2o9zQDHc33j9RLV1p958Zve/lVmRcPSM UcVpkg+YWe566m0bGHNvEbohqu5ef8tfPYUBgMPVl/Tzt06Wwcr7nidoQydMnpnlUwTw 8qe5XeCN4USZICxMHFiHNU4Kv+c92PJQ9vIcP+6A7GHqHHb1hIOuhAns71PKhD3gZnun t1kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=NTpmCbe1L6Ar4ZyKtMNOQdOBk9Z1juV8qmLsASxAE3U=; b=XqCU8nYpkhj2uzNX+GX0UZbAQMDOZjJv3ruZpVX7PK+Ep7ywWKelUm3PGoOi6dfBbw RRGhpYSOGTPh4/MM1eIdoiAAOvRNo3GVuLE3Yo7fk8bWByn/5B6aIDUFaipciuFWblnn BgOkS3cGcJzL+a5DWSmAgwVN5bu1+7vlZC9HotkqjlEx3R/OiyNvCLzecZE2L9GDKFS6 tGVenYy9mmfI4xLqfNvJLvZx4Ey2GCCKd6slRvWDG0rNLAcpoOuthBjkGBKfuzzfrQaR IHydjhRp7wdZJ0K5pdHixEWrYHgnbM7z9ppoflPxmLGjNJELLcOGQL8UxiX9lcXVAert RYhw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f21si5248708ejr.692.2021.01.29.13.27.59; Fri, 29 Jan 2021 13:28:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233302AbhA2VZn (ORCPT + 99 others); Fri, 29 Jan 2021 16:25:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:52816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232776AbhA2VZj (ORCPT ); Fri, 29 Jan 2021 16:25:39 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 4F39964E00; Fri, 29 Jan 2021 21:24:56 +0000 (UTC) Date: Fri, 29 Jan 2021 16:24:54 -0500 From: Steven Rostedt To: Peter Zijlstra Cc: Alexei Starovoitov , Masami Hiramatsu , Nikolay Borisov , LKML , Alexei Starovoitov , bpf , Josh Poimboeuf Subject: Re: kprobes broken since 0d00449c7a28 ("x86: Replace ist_enter() with nmi_enter()") Message-ID: <20210129162454.293523c6@gandalf.local.home> In-Reply-To: <20210129140103.3ce971b7@gandalf.local.home> References: <20210128123842.c9e33949e62f504b84bfadf5@gmail.com> <20210129013452.njuh3fomws62m4rc@ast-mbp.dhcp.thefacebook.com> <20210129224011.81bcdb3eba1227c414e69e1f@kernel.org> <20210129105952.74dc8464@gandalf.local.home> <20210129162438.GC8912@worktop.programming.kicks-ass.net> <20210129175943.GH8912@worktop.programming.kicks-ass.net> <20210129140103.3ce971b7@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 29 Jan 2021 14:01:03 -0500 Steven Rostedt wrote: > On Fri, 29 Jan 2021 18:59:43 +0100 > Peter Zijlstra wrote: > > > On Fri, Jan 29, 2021 at 09:45:48AM -0800, Alexei Starovoitov wrote: > > > Same things apply to bpf side. We can statically prove safety for > > > ftrace and kprobe attaching whereas to deal with NMI situation we > > > have to use run-time checks for recursion prevention, etc. > > > > I have no idea what you're saying. You can attach to functions that are > > called with random locks held, you can create kprobes in some very > > sensitive places. > > > > What can you staticlly prove about that? > > I think the main difference is, if you attach a kprobe or ftrace function, > you can theoretically analyze the location before you do the attachment. > > Does, the NMI context mean "in_nmi()" returns true? Because there's cases > in ftrace callbacks where that is checked (like the stack tracer). And > having ftrace return true for "in_nmi()" will break a lot of existing > utilities. Specifically, kprobe and ftrace callbacks may have this: if (in_nmi()) return; raw_spin_lock_irqsave(&lock, flags); [..] raw_spin_unlock_irqrestore(&lock, flags); Which is totally fine to have, but the above only works if "in_nmi()" returns true only if you are in a real NMI. The stack tracer code does exactly the above. -- Steve