From patchwork Thu Sep 9 13:31:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 12483171 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=-11.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 7A1CBC433F5 for ; Thu, 9 Sep 2021 13:36:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65F2361059 for ; Thu, 9 Sep 2021 13:36:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351107AbhIINhL (ORCPT ); Thu, 9 Sep 2021 09:37:11 -0400 Received: from mail-ed1-f54.google.com ([209.85.208.54]:47028 "EHLO mail-ed1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355892AbhIINdJ (ORCPT ); Thu, 9 Sep 2021 09:33:09 -0400 Received: by mail-ed1-f54.google.com with SMTP id j13so2656932edv.13 for ; Thu, 09 Sep 2021 06:31:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=I5+aT377LpweaJxo8y40u82o1xDS2ZChVCugghsh6kg=; b=fcURRixg1R2nvWpz6f9jf0A332EfLinka23PMnCvzQGsOljgmzx89gOEiNFnKmtFuX 7MnkWpdAwHOrjRsJV42uNqipaWfTfWbE4ANINd0yZO3re9SlBztcd1HJpZBo0h0ZJyeY WBdG9/8b+xK2zyEULsRkKA7R+pOOHJ15Fvf8/lUmgc7TfpbbPeAOnhiB8QKjF4L9fr6R HTsF3ZiJeNheh+tgaUS7bPyAumKLOsAuvqVRV+YzzRTRYk4q6gtnZFKKke5rvq+LFt4H cH+URhS899KkXWxV6nPkecehLFrtwmb4J3k59ops0gq5TPoSyDi0+L5kuamgz9AmhOH4 zlUA== X-Gm-Message-State: AOAM533bG0fgBXT4JEmcmFSZIqmxZMHWsTdpgrYSPdvJqfd6S6gbpTQm 7h0NicJyouJ0uTVazy+Z2c35gb/oc1Q= X-Google-Smtp-Source: ABdhPJwUWbaupzU3iiFXPS9499hkNzPXQ9/FuOr7ufOOpiIYbKJjCjJqzAKjCX5nGwLQSs/HK03JsA== X-Received: by 2002:aa7:cb55:: with SMTP id w21mr3089427edt.378.1631194318781; Thu, 09 Sep 2021 06:31:58 -0700 (PDT) Received: from msft-t490s.. (mob-83-225-149-177.net.vodafone.it. [83.225.149.177]) by smtp.gmail.com with ESMTPSA id am3sm959030ejc.74.2021.09.09.06.31.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 06:31:58 -0700 (PDT) From: Matteo Croce To: bpf@vger.kernel.org, Alexei Starovoitov Cc: Arnaldo Carvalho de Melo , Daniel Borkmann , Andrii Nakryiko Subject: [RFC bpf 0/2] bpf: kernel CO-RE relocation Date: Thu, 9 Sep 2021 15:31:51 +0200 Message-Id: <20210909133153.48994-1-mcroce@linux.microsoft.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net X-Patchwork-State: RFC From: Matteo Croce This series is a preliminary work to move the CO-RE relocations in the kernel. This is the first step to have signed BPF files, since userspace instruction patching makes any verification ineffective. The first patch just copies the relocation code from tools/lib/bpf/, the second one refactors the whole code so to build it in kernel. It builds with a single warning, which can be suppressed by switching to dynamic allocation: kernel/bpf/relo_core.c: In function 'bpf_core_apply_relo_insn': kernel/bpf/relo_core.c:1457:1: warning: the frame size of 2776 bytes is larger than 1024 bytes [-Wframe-larger-than=] To really use this code and do the the relocations done in kernel, we will need an API to pass the relocation informations along the BPF file, so don't consider this patches for inclusion, but just as a first step toward the full work. Matteo Croce (2): btf: copy relo_core from tools to kernel btf: adapt relo_core for kernel compilation include/linux/btf.h | 65 ++ kernel/bpf/Makefile | 1 + kernel/bpf/btf.c | 45 +- kernel/bpf/relo_core.c | 1457 ++++++++++++++++++++++++++++++++++++++++ kernel/bpf/relo_core.h | 100 +++ 5 files changed, 1630 insertions(+), 38 deletions(-) create mode 100644 kernel/bpf/relo_core.c create mode 100644 kernel/bpf/relo_core.h