Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp5402529imw; Wed, 20 Jul 2022 05:11:26 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uzN/K0UgAJbRB+506ciLthcNPfGlFN/hFKBKaorFuVjTlH0UtlBewNs8djh7aLKdMknpql X-Received: by 2002:a05:6e02:1906:b0:2dc:7399:aa4e with SMTP id w6-20020a056e02190600b002dc7399aa4emr19463766ilu.181.1658319086531; Wed, 20 Jul 2022 05:11:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658319086; cv=none; d=google.com; s=arc-20160816; b=LkV0F5Uv624xv+JzckcNZxhfSnvvWqELgEnsUYSbwig8pB+Wn2rso9f8WUBiRMAMai Gplb1RUEQpNbzHQZTXluGT4OdD95lyxdrFrnI4QhII/gI2E2QrAroxWf2q6lj6Hz9XRA SFBV93EScfB29y4S7wauTRNElmfNuIPcJZxS5KKGa26on+L+TSa5F0+/EkE7QxrvaASV WYwN5aI2dwKuf4LLEkibjO4ZLQFlwHau9c28nKZ+iNvpSf5JAzoB2oxH1vM42TY0bNri JOqaNs/otUsT9cgkzyjZtqYeTwDAt8ZG/WgDdo3BYKMWVyeJqDcUO86yUZYdfI5xT2rE vIUw== 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:date:subject:cc:to:from :dkim-signature; bh=Xmw0qJN/J7YRsfD4NK6d4JdhY2WGiXTb+5lcFAP4Rtw=; b=bqWNl1918gppgCb0lKvSOxPdp2x+W1HEaKBoLQ+22m5Rz2yq+tMjVsFXQc7Bhj2aEI MTAW5HLSgSotTYjkzNsVJ5zsMcGRt7oa3TnKWyWSoD2/B/p4FG1hWZ3X849v9uRpFome QEviFaBn36jthj0nRHl35IoTslHRP+dG7Se8IRPpb+ocWDKYsn7LDmW7LApoXO6hkqLN mB+nZCJL4Q+vWdxcdYFpWyTgWP8Hv6SRKelG30hBCh6VV00av9IAzlCjBRi5kDPfvKDk t24Jjw9W1praU7huMlw9W0DWz7wVYWb4XSWpxDmN4Jw5mJ/MdtuVz5LuVVue9VfS7x+v 8mRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W223zgZF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a025409000000b003416830d421si9621098jaa.64.2022.07.20.05.11.13; Wed, 20 Jul 2022 05:11:26 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=W223zgZF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240813AbiGTLrF (ORCPT + 99 others); Wed, 20 Jul 2022 07:47:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240695AbiGTLrC (ORCPT ); Wed, 20 Jul 2022 07:47:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5BF9072ED0 for ; Wed, 20 Jul 2022 04:47:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1658317619; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Xmw0qJN/J7YRsfD4NK6d4JdhY2WGiXTb+5lcFAP4Rtw=; b=W223zgZFV3kQfES1DCQfmPKzeUOTguIIE2DoHG87xZC8ct+gFTujdxawM7pMsR6AqPzddj mLLWIdYJD54ZYP8Zovldk7Vi8gJVxQbRmvmrRckbTFFpHvoMCAa4KiGTRaIhtffHc/XqV4 /6ncnQF+YAkAAsTlJAQfvAnDiI58VZ0= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-379-myivAjZ3NSicRo3ogUQlrg-1; Wed, 20 Jul 2022 07:46:56 -0400 X-MC-Unique: myivAjZ3NSicRo3ogUQlrg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 694631C0514E; Wed, 20 Jul 2022 11:46:55 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFEC22166B29; Wed, 20 Jul 2022 11:46:54 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id 0B7061C03BC; Wed, 20 Jul 2022 13:46:54 +0200 (CEST) From: Artem Savkov To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andrea Arcangeli , Daniel Vacek , Jiri Olsa , Song Liu , Artem Savkov Subject: [PATCH bpf-next 4/4] bpf: export crash_kexec() as destructive kfunc Date: Wed, 20 Jul 2022 13:46:52 +0200 Message-Id: <20220720114652.3020467-5-asavkov@redhat.com> In-Reply-To: <20220720114652.3020467-1-asavkov@redhat.com> References: <20220720114652.3020467-1-asavkov@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 Allow properly marked bpf programs to call crash_kexec(). Signed-off-by: Artem Savkov --- kernel/kexec_core.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 4d34c78334ce4..a21fe8d326a8e 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -39,6 +39,8 @@ #include #include #include +#include +#include #include #include @@ -1238,3 +1240,23 @@ void __weak arch_kexec_protect_crashkres(void) void __weak arch_kexec_unprotect_crashkres(void) {} + +#ifdef CONFIG_DEBUG_INFO_BTF_MODULES +BTF_SET_START(kexec_btf_ids) +BTF_ID(func, crash_kexec) +BTF_SET_END(kexec_btf_ids) + +static const struct btf_kfunc_id_set kexec_kfunc_set = { + .owner = THIS_MODULE, + .check_set = &kexec_btf_ids, + .destructive_set = &kexec_btf_ids, +}; + +static int __init crash_kfunc_init(void) +{ + register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &kexec_kfunc_set); + return 0; +} + +subsys_initcall(crash_kfunc_init); +#endif -- 2.35.3