Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp541961imi; Thu, 21 Jul 2022 06:20:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tvDioMgghBB6H4iPbmxZUEtZe1c6sSdPfTttYwDAPcLryagXoaOnXbYrkc6mJ18PJO4Bzj X-Received: by 2002:a05:6830:3101:b0:61c:bd29:3043 with SMTP id b1-20020a056830310100b0061cbd293043mr3173947ots.125.1658409647544; Thu, 21 Jul 2022 06:20:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658409647; cv=none; d=google.com; s=arc-20160816; b=DUocWlMvBrW30fL3ln5orzD5cuur20p8pWp8tGorhZABKHo+E3r+nh+fgHw7m6glO8 KgtMIbabwHb5xVj18Izd35/tKrKm0L2npYWa5zNDevwR0+zU+OeHtBaQAws8HCixhpAz v+4OKeo/B0VXqlicUA+/B07itBC8Jnnf4fjXMH3uITO8aZd4vOHYvrmkMN39Sv3wZRcC mxyDJcCNA7kwPMF8VLd/bQBzIuP7MjD4giqI2LyGlAq+17AHTytNqFoC1XnJ/K7/aTCD 6PzuMZe5pti3Q+eWUFKUYTILjsrA/J75wr0e73mlwqzU7uLpTbxmoghQUExT/X6ZzRPw vzGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=xpjQqd2r4gzDP0xuof0S9rihi6AjCDjD3uPMU/u3IFo=; b=bx6G1bvC9PC5kL3lA7l2KclkViorCder+1+7pFyePQiBiIdzsMzk5j/uPTyONyTLNd SOZylu2+6xl53YkcGIRWy0Ejsv0rWROSIhSqzKJ3tPwXRKp/N3tfOlOFcx4pfZ2BhZ9g VDBjpivVbPRm9Q05kogNpMKo8xmXa7Ym4/80aEJOao4qxfzOd441X8fMorPQWB5nAJ+7 9cRGvW/POKHU3niQpX1meUh+X51Agn3kztQMqWbBwNl/d9TjBJzTQYl+CCQ4cgdeOJoF Y5dhOZN3UGXERW+JZ2urbqeDJpBuO3kWwS3BV+xhrXJ9gEFIypp3Nzeq6ETIzHmheNUz 9wBQ== 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:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n23-20020a056870559700b0010c1a449cefsi1625861oao.311.2022.07.21.06.20.33; Thu, 21 Jul 2022 06:20:47 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233141AbiGUNBK (ORCPT + 99 others); Thu, 21 Jul 2022 09:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231154AbiGUNBI (ORCPT ); Thu, 21 Jul 2022 09:01:08 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18DEF6A; Thu, 21 Jul 2022 06:01:06 -0700 (PDT) Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1oEVnW-0000Ad-8A; Thu, 21 Jul 2022 15:00:58 +0200 Received: from [2a01:118f:505:3400:57f9:d43a:5622:24a8] (helo=linux-3.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oEVnV-000UrP-QQ; Thu, 21 Jul 2022 15:00:57 +0200 Subject: Re: [PATCH bpf-next 0/4] destructive bpf kfuncs (was: bpf_panic) To: Artem Savkov , Alexei Starovoitov , Andrii Nakryiko , bpf@vger.kernel.org, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Andrea Arcangeli , Daniel Vacek , Jiri Olsa , Song Liu References: <20220720114652.3020467-1-asavkov@redhat.com> From: Daniel Borkmann Message-ID: Date: Thu, 21 Jul 2022 15:00:56 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20220720114652.3020467-1-asavkov@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.6/26608/Thu Jul 21 09:57:36 2022) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On 7/20/22 1:46 PM, Artem Savkov wrote: > eBPF is often used for kernel debugging, and one of the widely used and > powerful debugging techniques is post-mortem debugging with a full memory dump. > Triggering a panic at exactly the right moment allows the user to get such a > dump and thus a better view at the system's state. Right now the only way to > do this in BPF is to signal userspace to trigger kexec/panic. This is > suboptimal as going through userspace requires context changes and adds > significant delays taking system further away from "the right moment". On a > single-cpu system the situation is even worse because BPF program won't even be > able to block the thread of interest. > > This patchset tries to solve this problem by allowing properly marked tracing > bpf programs to call crash_kexec() kernel function. > > This is a continuation of bpf_panic patchset with initial feedback taken into > account. > > Changes from RFC: > - sysctl knob dropped > - using crash_kexec() instead of panic() > - using kfuncs instead of adding a new helper > > Artem Savkov (4): > bpf: add BPF_F_DESTRUCTIVE flag for BPF_PROG_LOAD > bpf: add destructive kfunc set > selftests/bpf: add destructive kfunc tests > bpf: export crash_kexec() as destructive kfunc First and second patch ccould be folded together into one. The selftest should be last in series so that if people bisect the test won't fail due to missing functionality. First one also has a stale comment wrt bpf_panic() helper. > include/linux/bpf.h | 1 + > include/linux/btf.h | 2 + > include/uapi/linux/bpf.h | 6 +++ > kernel/bpf/syscall.c | 4 +- > kernel/bpf/verifier.c | 12 ++++++ > kernel/kexec_core.c | 22 ++++++++++ > net/bpf/test_run.c | 12 +++++- > tools/include/uapi/linux/bpf.h | 6 +++ > .../selftests/bpf/prog_tests/kfunc_call.c | 41 +++++++++++++++++++ > .../bpf/progs/kfunc_call_destructive.c | 14 +++++++ > 10 files changed, 118 insertions(+), 2 deletions(-) > create mode 100644 tools/testing/selftests/bpf/progs/kfunc_call_destructive.c >