Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2426705imn; Tue, 2 Aug 2022 02:19:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6nXwhMyEwqNTNRkfcF+4b7yn+cPbveWgvNnxROEGffx5ACfdvWU8wOocPTF9s3kwbE2Q5s X-Received: by 2002:a17:902:b093:b0:16b:f20f:ee1c with SMTP id p19-20020a170902b09300b0016bf20fee1cmr20115380plr.37.1659431972636; Tue, 02 Aug 2022 02:19:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659431972; cv=none; d=google.com; s=arc-20160816; b=cQ5TztXiDb4ghhq6TySzqKo+wX8r5/g6acjJnMgdjMuS6GPgUxeeVI2fHqZv7M5PQ9 BeZebkfiqMRyaqtoaAOVxSG3KP9x5674EZOmyyd1znSiQ6nfS7bRvVm28kAk4gtZEKZN OC+gvLQcvFde6HxQ9C9bVeJWXAGRT1rMAEXfT3PcqQBM1SIJ3dX6tENenOVSEukCg01Q QcEkDh1DEEqfSd+vu6V46sox5AjdEoLkQV5gjxMyxbRN4ONwo0H71fcyDU1vCbH0DS0E Oko5R2XLLYZVTK22BdNMMOx+a9AR4xtCkZOyrRjRoKyNyEXf3cUiaUb1iC4rdPpYr4wH elqQ== 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=TwBb9lEjHn3drMZDMM/zYMhet6xNvu6dn9eorLLxNfM=; b=GGcCtAPLWDroC7MUELWZSizBXpouB/uRvpG6CdIgnwayyAFaqLYMAdJ6v7ZUkx3EZQ PF81A3dAHDPh0VhVMDWrpKiEr3tVT4Grf5sOszEUBOANTjMrqLJmuwBfODY4oCWhkqIm CU2ajd11EY4dmc0xLyQ8FXppqF8aOp1bkkKYgsUPkckepd6nMPH+BrAa3OTLBESVJsJi WYwhqpb/uWcrMGglSRUf8PP6SqgQppdVJSngYoHJrKJFv6pEma8qVd0IJOTfDn8n2T+8 9Ns2QOsqkn9ueDzdnYLAsfN6YwYMS+JiXIa4cLBQfdNv9Wmfkie9roXMoBv38JbJr7Oo x/JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=U6sRuAIE; 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 e17-20020a056a001a9100b0052893a7c620si15473385pfv.276.2022.08.02.02.19.17; Tue, 02 Aug 2022 02:19:32 -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=U6sRuAIE; 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 S236265AbiHBJKz (ORCPT + 99 others); Tue, 2 Aug 2022 05:10:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236181AbiHBJKk (ORCPT ); Tue, 2 Aug 2022 05:10:40 -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 8D79311814 for ; Tue, 2 Aug 2022 02:10:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1659431437; 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=TwBb9lEjHn3drMZDMM/zYMhet6xNvu6dn9eorLLxNfM=; b=U6sRuAIE2frv7dC4yJejAIJMIyMBI5YcF3PvW8VCboOgb099OQYO3fEd25MIH4wfubXOoy JNj/fhfYS0pUVl/T79t5w6Qh11x4Titzyn+G/KZvGknJ6ddjFgYpCt2RYrwYjzvA1o9xSw rnB36ObcnKRTxog11NSuFBIZpGf/16Q= 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-625-Glkrt58cPx6Frhho0-hlzA-1; Tue, 02 Aug 2022 05:10:33 -0400 X-MC-Unique: Glkrt58cPx6Frhho0-hlzA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C87AA3802B82; Tue, 2 Aug 2022 09:10:32 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86DD990A04; Tue, 2 Aug 2022 09:10:32 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id 8C4521C0291; Tue, 2 Aug 2022 11:10:31 +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 , Daniel Xu , Artem Savkov Subject: [PATCH bpf-next v2 2/3] bpf: export crash_kexec() as destructive kfunc Date: Tue, 2 Aug 2022 11:10:29 +0200 Message-Id: <20220802091030.3742334-3-asavkov@redhat.com> In-Reply-To: <20220802091030.3742334-1-asavkov@redhat.com> References: <20220802091030.3742334-1-asavkov@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 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 | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 4d34c78334ce..9259ea3bd693 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,22 @@ void __weak arch_kexec_protect_crashkres(void) void __weak arch_kexec_unprotect_crashkres(void) {} + +#ifdef CONFIG_DEBUG_INFO_BTF_MODULES +BTF_SET8_START(kexec_btf_ids) +BTF_ID_FLAGS(func, crash_kexec, KF_DESTRUCTIVE) +BTF_SET8_END(kexec_btf_ids) + +static const struct btf_kfunc_id_set kexec_kfunc_set = { + .owner = THIS_MODULE, + .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