Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp5783577rwb; Tue, 9 Aug 2022 04:10:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR7YEQYAYAnLBjHZ7bomyXSOm+O/jHX0w0qIYp6gFaPitVk+F19cR2ClgJ+l0ZmCA5tjIcCI X-Received: by 2002:a17:902:eb8a:b0:16d:c75a:c40b with SMTP id q10-20020a170902eb8a00b0016dc75ac40bmr23372926plg.102.1660043418775; Tue, 09 Aug 2022 04:10:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660043418; cv=none; d=google.com; s=arc-20160816; b=QfQidzjB1VKYSoK1n/Ux2R2s1itqQbLg+FlhZblunyVkL1t1+pEPTLmQOF79MHenNF UcMVhfo2wAdI7w3xe3KwMzVHhN1h/aSkFKqZ4qEwFX4Cr7bEYnJ78ELmPtHTE4KC3w3g SpSpsao+eZpOMdmQghl/2O4PYEdAGu+YYWLy35HIvHZe4nONVfaziVvENI+8vLvIxgZm iuZmc0tHaYg1/LyXgGf0CBIKQhhzpJ9jSgEIvO+195BMqf82QhInnbP95XIlGvzjs+Jo OON2wFc2xXXavoK6/w0CakDKm84uLvO2wynNMVzWKGL2Tc25lDYJztksJxFbrScm/wZu bJBA== 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=4t5AWs+u5EvUjx0b8iyElLx44EEba3jEMvid4zYihvo=; b=aTJZ2ypIeLr0IxYsXaADMRm8FgHlFMLgoIiR8MHl6R8RCQnjZNtcWvzA0e3tkaJfVI xLZ3Jk/3W7eK56u0NI14GCWdiWTYh8F5DiAXJEKdvHSmcH+2CBm/CtF+Ruwa5IsZzv00 h8Nll+mub+BzP5aT+ebjZ8qslFb79unNZ9fPS7G7ELkz50mS3cJNVugQSZo8vOOD/7HA j4KY58qMP7F7YP5pYcvZH9RryNfiKBCyzCYJuYKqqpB2RbQzeO77R2phUMh1w1484oKb rP323P7MHXOBAgpWX8BC+sJrdAw/l4lEJ4xSYh8phVQhBcp6I021uW2NGJAD+RbjA8nm udqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SbqsEG5O; 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 n8-20020a63b448000000b0041be4782428si13126304pgu.122.2022.08.09.04.10.05; Tue, 09 Aug 2022 04:10:18 -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=SbqsEG5O; 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 S242732AbiHIKxm (ORCPT + 99 others); Tue, 9 Aug 2022 06:53:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241307AbiHIKx2 (ORCPT ); Tue, 9 Aug 2022 06:53:28 -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 3454E10EE for ; Tue, 9 Aug 2022 03:53:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1660042406; 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=4t5AWs+u5EvUjx0b8iyElLx44EEba3jEMvid4zYihvo=; b=SbqsEG5Ob2YmF4t13MDmwH3S9jXJ4WOCCGh3bTqT0wlz10NHneOfiLea+6r+T9vDb09fH0 rxM7HsAWfxeGpLqU2Dye90EHDXIUjBj6ppGRKohXnf+a552GGxuEpyASsuIrupbi9/D/Xe /UeFF6y1aLnITE7L60HNfEK9RC2llmI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-651-tyGxiXnyNpS4M681TYH1uA-1; Tue, 09 Aug 2022 06:53:19 -0400 X-MC-Unique: tyGxiXnyNpS4M681TYH1uA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3EC531824605; Tue, 9 Aug 2022 10:53:19 +0000 (UTC) Received: from shodan.usersys.redhat.com (unknown [10.43.17.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7A12C15BA3; Tue, 9 Aug 2022 10:53:18 +0000 (UTC) Received: by shodan.usersys.redhat.com (Postfix, from userid 1000) id F1E921C02E7; Tue, 9 Aug 2022 12:53:17 +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 , Kumar Kartikeya Dwivedi , Artem Savkov Subject: [PATCH bpf-next v4 2/3] bpf: export crash_kexec() as destructive kfunc Date: Tue, 9 Aug 2022 12:53:16 +0200 Message-Id: <20220809105317.436682-3-asavkov@redhat.com> In-Reply-To: <20220809105317.436682-1-asavkov@redhat.com> References: <20220809105317.436682-1-asavkov@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 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,T_SCC_BODY_TEXT_LINE 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/bpf/helpers.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kernel/bpf/helpers.c b/kernel/bpf/helpers.c index 1f961f9982d2..103dbddff41f 100644 --- a/kernel/bpf/helpers.c +++ b/kernel/bpf/helpers.c @@ -1711,3 +1711,24 @@ bpf_base_func_proto(enum bpf_func_id func_id) return NULL; } } + +BTF_SET8_START(tracing_btf_ids) +#ifdef CONFIG_KEXEC_CORE +BTF_ID_FLAGS(func, crash_kexec, KF_DESTRUCTIVE) +#endif +BTF_SET8_END(tracing_btf_ids) + +static const struct btf_kfunc_id_set tracing_kfunc_set = { + .owner = THIS_MODULE, + .set = &tracing_btf_ids, +}; + +static int __init kfunc_init(void) +{ + if (register_btf_kfunc_id_set(BPF_PROG_TYPE_TRACING, &tracing_kfunc_set)) + pr_warn("failed to register kfunc id set for BPF_PROG_TYPE_TRACING\n"); + + return 0; +} + +late_initcall(kfunc_init); -- 2.37.1