Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1184869pxb; Fri, 1 Apr 2022 06:55:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxDc+3E5glAb3O+ws4RlUuEJW2+HT7I3LXUsIB3dd9iD8WxUom2JGMvvXMP4M9tXv5RLUV9 X-Received: by 2002:a50:ec18:0:b0:419:3af:5736 with SMTP id g24-20020a50ec18000000b0041903af5736mr21198369edr.215.1648821308881; Fri, 01 Apr 2022 06:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648821308; cv=none; d=google.com; s=arc-20160816; b=q7Y0X31QZIovoeklCGKITzTzUfQT58lyhfwOmfXH4wbXCII/zNdfndVkuJQkoHiX/m 0zmZQmwfvpH+AeuG/9WJYONNuc6OijHwtcdpo5h+0/k8Y4dqu3D3n9QYp4fTb1kawl5A v9bySNir0akgN8wgdFw00WWrwmWNHGqCqe+qEeywKdblxKtfHKEsZjG7fd8lOIxxgWMW JmY3cz2TE0K/5ukV8YbpyMcHmpTzpSzbkCNSltRayj1qf/yk25u6sdE3el1H+fp96FIs HCSV+7xnO8ffWwGVSrM6UTio+xuea9Py3nmJ7MWo+srTrpaPyf3QJkd8HyhRzegcQPp0 x3Qg== 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=LF9SeaqWlSjBaJee3Ko7jij2ua+FAeyKUN6FmNkvEnA=; b=J06rNv67G48m3YDVTG85kmN5Cy+SexG9zK4Fl8lUwmU5BGGNC9vGsgLQSM6c6TQ1qU kyIdUToGH+qWnC7pYCCF9vOzxCX8CSP3MZ68+EEbVvoiCrNkkXpN3pQzD0M7kXCtg58n 8pIM9rr5FGuB3Wld62pcmHG4crKUPwckdhE9CDyg4oEToNMBVm+wIu6gpKt3OGvxre2Y uGkwJmIP1y7nZCjZ+cuNdVtHBChhZZ86zsRgpN0Nv6dbwUVzSk3kzgJFso1woGe3RtYH 6UZHXk9hgfZZq1UA7+YppTsVM9N4XCG2cR3l2+engN9I7q4kt+pV1odu3nMkA8SJkwoA YUxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qh25-20020a170906ecb900b006dfb07cee7fsi1688800ejb.11.2022.04.01.06.54.43; Fri, 01 Apr 2022 06:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243853AbiDABue (ORCPT + 99 others); Thu, 31 Mar 2022 21:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232466AbiDABud (ORCPT ); Thu, 31 Mar 2022 21:50:33 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9AE9674E8; Thu, 31 Mar 2022 18:48:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 788D86191F; Fri, 1 Apr 2022 01:48:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 35167C340ED; Fri, 1 Apr 2022 01:48:38 +0000 (UTC) Date: Thu, 31 Mar 2022 21:48:36 -0400 From: Steven Rostedt To: Song Liu Cc: open list , bpf , Ingo Molnar , Kernel Team Subject: Re: ftrace_direct (used by bpf trampoline) conflicts with live patch Message-ID: <20220331214836.663bc7cf@rorschach.local.home> In-Reply-To: <0962AC9B-2FBD-4578-8B2F-A376A6B3B83F@fb.com> References: <0962AC9B-2FBD-4578-8B2F-A376A6B3B83F@fb.com> 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 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 1 Apr 2022 01:11:01 +0000 Song Liu wrote: > Hi Steven, > > We hit an issue with bpf trampoline and kernel live patch on the > same function. > > Basically, we have tracing and live patch on the same function. > If we use kprobe (over ftrace) for tracing, it works fine with > live patch. However, fentry on the same function does not work > with live patch (the one comes later fails to attach). > > After digging into this, I found this is because bpf trampoline > uses register_ftrace_direct, which enables IPMODIFY by default. > OTOH, it seems that BPF doesn't really need IPMODIFY. As BPF > trampoline does a "goto do_fexit" in jit for BPF_TRAMP_MODIFY_RETURN. > > IIUC, we can let bpf trampoline and live patch work together with > an ipmodify-less version of register_ftrace_direct, like attached > below. > > Does this make sense to you? Did I miss something? I thought the BPF trampoline does: call bpf_trace_before_function call original_function + X86_PATCH_SIZE call bpf_trace_after_function Thus, the bpf direct trampoline calls the unpatched version of the function call making the live patch useless. Or is this not what it does? -- Steve