Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp5867856ioo; Wed, 1 Jun 2022 14:30:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdsYtyA7qLnnkCVDCpm8FuNSjRg+4AL5O4SqCaVqfbF3CaWyo6iysbROCVHWACwD4hSWkA X-Received: by 2002:a65:6c12:0:b0:3db:a518:ff1b with SMTP id y18-20020a656c12000000b003dba518ff1bmr1135038pgu.315.1654119000724; Wed, 01 Jun 2022 14:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654119000; cv=none; d=google.com; s=arc-20160816; b=atwBCxX6p3Kckl6MezutzP7KJKnEliSaz31FmaO+pEV7tJSKtLyrRMV6NvXQU0nNgP ClGRiBu9q8Zm0GvhtYwDTB/kPoud6G/MZ0Ho0Ngz9/R9svxocjuX6q5Fe89jGDXLDalv V7i8t4S/YNpndx4knGzboq4KotABoz6muDCcQV3i72/8Ku8m3xB3aQXBLAYloZzoPol9 b8EQM7LuRTtFhqbWhuh9rh/+NfsKIH/JHdGIIBdv/DjfHwh8OlaQWdQ53j0CgjVkOMT5 Om3jta78yt1lU2NDkCsq2ex29OFPIbHmTQhOXn7T5OGt+4/bhXg+dsi0IWgBER07paBf DxZg== 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 :message-id:date:subject:cc:to:from; bh=BbI/62nfn59Y90cgh9XWiFj2KK9oxwv1blCdglRHKkw=; b=ewhitcLat5eov7YgS5iVp7eUtPDK10YKORQldoR/maODRmjDaRZA8FbtF61ZnRK/gK /UU+WXMlCtsbhIibEcVYS4gFbrI18fDklh66LlglcnxS9AY6ThqkIJCBhbdC9QdWuapQ x1NIEY0f+8e4H1rxPnokufR027o3hN8ZAL4NvBEaD6pAn2jFWaMwiOccOj5O5BNUFc2e lKf+T95H5KUDJgYPk5dF9JcTveRwx6JWLHujnGT7XgSwZa/qh3YYi3S6OoCYP6Ru7iGj np10pTcbpt0/ZIFk24zMbm8CELEna2pK5XqjNwpe8p1kO+Wprc26vDkser+qVLITk4vL DHcg== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id c4-20020a056a000ac400b0050d429bb67esi3794752pfl.82.2022.06.01.14.30.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 14:30:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0357317159; Wed, 1 Jun 2022 13:19:49 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356484AbiFAR6L convert rfc822-to-8bit (ORCPT + 99 others); Wed, 1 Jun 2022 13:58:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245473AbiFAR6J (ORCPT ); Wed, 1 Jun 2022 13:58:09 -0400 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CDF046A420 for ; Wed, 1 Jun 2022 10:58:07 -0700 (PDT) Received: from pps.filterd (m0089730.ppops.net [127.0.0.1]) by m0089730.ppops.net (8.17.1.5/8.17.1.5) with ESMTP id 2519G4Wk020913 for ; Wed, 1 Jun 2022 10:58:07 -0700 Received: from maileast.thefacebook.com ([163.114.130.16]) by m0089730.ppops.net (PPS) with ESMTPS id 3ge5atu5tj-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Wed, 01 Jun 2022 10:58:06 -0700 Received: from twshared19572.14.frc2.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:82::c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Wed, 1 Jun 2022 10:58:05 -0700 Received: by devbig932.frc1.facebook.com (Postfix, from userid 4523) id 05F078603CAF; Wed, 1 Jun 2022 10:57:56 -0700 (PDT) From: Song Liu To: , , CC: , , , , , , Song Liu Subject: [PATCH bpf-next 0/5] ftrace: host klp and bpf trampoline together Date: Wed, 1 Jun 2022 10:57:44 -0700 Message-ID: <20220601175749.3071572-1-song@kernel.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8BIT X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-GUID: Es_T9npr57JFBI5sJR4Df3TGGj3GQ72p X-Proofpoint-ORIG-GUID: Es_T9npr57JFBI5sJR4Df3TGGj3GQ72p X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-01_06,2022-06-01_01,2022-02-23_01 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 Kernel Live Patch (livepatch, or klp) and bpf trampoline are important features for modern systems. This set allows the two to work on the same kernel function as the same time. live patch uses ftrace with IPMODIFY, while bpf trampoline use direct ftrace. Existing policy does not allow the two to attach to the same kernel function. This is changed by fine tuning ftrace IPMODIFY policy, and allows one non-DIRECT IPMODIFY ftrace_ops and one non-IPMODIFY DIRECT ftrace_ops on the same kernel function at the same time. Please see 3/5 for more details on this. Note that, one of the constraint here is to let bpf trampoline use direct call when it is not working on the same function as live patch. This is achieved by allowing ftrace code to ask bpf trampoline to make changes. Jiri Olsa (1): bpf, x64: Allow to use caller address from stack Song Liu (4): ftrace: allow customized flags for ftrace_direct_multi ftrace_ops ftrace: add modify_ftrace_direct_multi_nolock ftrace: introduce FTRACE_OPS_FL_SHARE_IPMODIFY bpf: trampoline: support FTRACE_OPS_FL_SHARE_IPMODIFY arch/x86/net/bpf_jit_comp.c | 13 +- include/linux/bpf.h | 8 ++ include/linux/ftrace.h | 79 +++++++++++ kernel/bpf/trampoline.c | 100 ++++++++++++-- kernel/trace/ftrace.c | 269 +++++++++++++++++++++++++++++++----- 5 files changed, 416 insertions(+), 53 deletions(-) -- 2.30.2