From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_2 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C875C433E0 for ; Mon, 8 Feb 2021 15:05:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C9F8364E84 for ; Mon, 8 Feb 2021 15:05:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232787AbhBHPFO (ORCPT ); Mon, 8 Feb 2021 10:05:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:51776 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232212AbhBHPDC (ORCPT ); Mon, 8 Feb 2021 10:03:02 -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 D2FCB64E8C; Mon, 8 Feb 2021 15:02:08 +0000 (UTC) Date: Mon, 8 Feb 2021 10:02:06 -0500 From: Steven Rostedt To: Josh Poimboeuf Cc: Linus Torvalds , Borislav Petkov , Dave Hansen , x86-ml , lkml , Alexei Starovoitov Subject: Re: [GIT PULL] x86/urgent for v5.11-rc7 Message-ID: <20210208100206.3b74891e@gandalf.local.home> In-Reply-To: <20210207224540.ercf5657pftibyaw@treble> References: <20210207104022.GA32127@zn.tnic> <20210207175814.GF32127@zn.tnic> <20210207224540.ercf5657pftibyaw@treble> 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 Sun, 7 Feb 2021 16:45:40 -0600 Josh Poimboeuf wrote: > > I do suspect involved people should start thinking about how they want > > to deal with functions starting with > > > > endbr64 > > call __fentry__ > > > > instead of the call being at the very top of the function. > > FWIW, objtool's already fine with it (otherwise we would have discovered > the need to disable fcf-protection much sooner). And this doesn't really affect tracing (note, another user that might be affected is live kernel patching). The way this change was noticed, was that there was a report of someone that was be able to connect a bpf program to a function for one machine but not for another machine. The other machine had this CET thingy. The difference is, when you attach a probe to the start of a function, kprobes will check if the probe address (start of function) is located at a ftrace location (nop / __fentry__) and if it is, it would use the ftrace infrastructure instead of attaching an int3 breakpoint. Because of the enbr64 being at the start of the function, the check returned false (it was not a ftrace location) and it attached an int3 breakpoint instead. This uncovered another "bug". Peter Zijlstra made int3 handlers look like NMIs (in_nmi() would return true in an int3 handler). The BPF programs would not run in NMI context. But nobody noticed, because people usually attach BPF programs to the start of a function using kprobes, and since kprobes would use ftrace handlers (that don't set in_nmi() to true), everything worked. But when the "endbr64" was added at the start of the program, kprobes fell back to int3, and suddenly the BPF programs stopped working. -- Steve