From patchwork Wed Feb 3 23:23:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 12065697 X-Patchwork-Delegate: bpf@iogearbox.net 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=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_CR_TRAILER,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 1929AC433E6 for ; Wed, 3 Feb 2021 23:24:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A96C264F55 for ; Wed, 3 Feb 2021 23:24:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232733AbhBCXYS (ORCPT ); Wed, 3 Feb 2021 18:24:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:49674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbhBCXYR (ORCPT ); Wed, 3 Feb 2021 18:24:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFA3164F43; Wed, 3 Feb 2021 23:23:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612394617; bh=PTVYv7f3q04Ewx0yYuhCee8Xadz6Jy6gdGf4sFC0JDw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sVhTck0WNMa0115fJMPy6l6yPwSfScJ6e1OWERJwx1/2DR0S/OTOl6bxs7vIX5+7z sQ+SeUXHHVhjh9l1faaNBqwTqyKTzFLMLI+Y2cFXSgtJTJlGGcI8cYnAvYXPQB23rJ fPYGFrX6sd5VqH5WItLgzpGQ+UwyVR3Ye7BefH+SgMSNQrDvrpIWfDO228pVF4Evi5 vdefPbszmh2YEOuZgH95RXnb9zyKSJlBBZgRa0qopBp4UKUJCCUhBwLeq1LMt7Y0CE 1tN9Sf2lfqqjHJZC6QyipiQWLCGKNqIwTEcFnlYdZuuQ24ytZ/r1RE9JjpmTWcyWdy yhqOkmo7s13YA== From: KP Singh To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Florent Revest , Brendan Jackman Subject: [PATCH bpf-next 1/2] bpf: Allow usage of BPF ringbuffer in sleepable programs Date: Wed, 3 Feb 2021 23:23:30 +0000 Message-Id: <20210203232331.2567162-2-kpsingh@kernel.org> X-Mailer: git-send-email 2.30.0.365.g02bc693789-goog In-Reply-To: <20210203232331.2567162-1-kpsingh@kernel.org> References: <20210203232331.2567162-1-kpsingh@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The BPF ringbuffer map is pre-allocated and the implementation logic does not rely on disabling preemption or per-cpu data structures. Using the BPF ringbuffer sleepable LSM and tracing programs does not trigger any warnings with DEBUG_ATOMIC_SLEEP, DEBUG_PREEMPT, PROVE_RCU and PROVE_LOCKING and LOCKDEP enabled. This allows helpers like bpf_copy_from_user and bpf_ima_inode_hash to write to the BPF ring buffer from sleepable BPF programs. Signed-off-by: KP Singh Acked-by: Andrii Nakryiko --- kernel/bpf/verifier.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index 5e09632efddb..4c33b4840438 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -10024,6 +10024,8 @@ static int check_map_prog_compatibility(struct bpf_verifier_env *env, return -EINVAL; } break; + case BPF_MAP_TYPE_RINGBUF: + break; default: verbose(env, "Sleepable programs can only use array and hash maps\n");