Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp815214rwr; Thu, 27 Apr 2023 08:28:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7B4CPoFPe9Sr1iKBELmXnMnlTHXGk60gGTICo8ot3xfECMbuqLocyPeaECFuLTyxb1jsa4 X-Received: by 2002:a17:90a:1912:b0:247:9c7d:523a with SMTP id 18-20020a17090a191200b002479c7d523amr1933433pjg.4.1682609288724; Thu, 27 Apr 2023 08:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682609288; cv=none; d=google.com; s=arc-20160816; b=VJ5/f+CM+UHYBQrZtn88cSaE8p6a4z3j2Xlh+/Wndcw/oYYbv3F6kBrMhFckLkoexc 5Sg358Ujx0IK39Jzkq5YoOq1IeCvqcWkPFnrZ/3JwTmcbYwu1GTaLeIhlY9n9KycfOk9 vEg9JIG85t33XtVfZ0UUGlRH8GrQMzMub2oL5YUrzPPZXJhu/LkA8KpMqceWbWJxV1Qu OYSzvxJP8KQAzR/wF2Wu5vcVlUkx/zM1gCejYZ++9SR2bxmrqTUzddUR4caN6oTovHjT VaS85LB6pYs5hrrssFxlkZXViLAb0MsfCnKkNNgPEhyeZ2hAOd9n26KrTnRC/YaJIyQe izUQ== 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:subject:cc:to:from:date; bh=GOwKo5ratsmJ5ctYvOi4Z0kSMreEdcS7Z9Nr5nOgMio=; b=J2E6WKv8ERIXy5LutlZVxwWe/Zv5MfYvMkl68YqaVFLOAa/Zfp52NjcXB5VCIQ/FRe JrLvQu9cF2SwsN0eLSHpe9bmiByoarPXOL+ux9cdiJmKYAIBiB/0I/1yoePg0BNB9/2l xbqQtNf+36yjUQYPszWRYe93qxcK+SaWtVfZeDTENx6Ar9Ay8rXnKVllMZhAl/hrQsJv XJmqY3nvz8sH2AYohwAUKPX55rjF9NAv/3YhB80w9xXVygaJ2EQdszwRbh1rF0BQnU1S Km/A5nB336EYhCdQbA9j8grA6E4mw8QOKNa7MS+pPRaTN7uOBKVJPmm/MW4g2KO2ZZ4W AowA== 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 ob8-20020a17090b390800b002474ddc6a90si16565268pjb.125.2023.04.27.08.27.54; Thu, 27 Apr 2023 08:28:08 -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 S244148AbjD0PSt (ORCPT + 99 others); Thu, 27 Apr 2023 11:18:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243404AbjD0PSr (ORCPT ); Thu, 27 Apr 2023 11:18:47 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEBF24224; Thu, 27 Apr 2023 08:18:46 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 292AF63DF1; Thu, 27 Apr 2023 15:18:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7954C433EF; Thu, 27 Apr 2023 15:18:43 +0000 (UTC) Date: Thu, 27 Apr 2023 11:18:42 -0400 From: Steven Rostedt To: Yafang Shao Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, mhiramat@kernel.org, bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next 5/6] bpf: Improve tracing recursion prevention mechanism Message-ID: <20230427111842.2e40fe3c@gandalf.local.home> In-Reply-To: References: <20230417154737.12740-1-laoar.shao@gmail.com> <20230417154737.12740-6-laoar.shao@gmail.com> <20230427092628.21fd23e4@gandalf.local.home> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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 Thu, 27 Apr 2023 22:22:22 +0800 Yafang Shao wrote: > IIUC, the acquire/release pair works as follows, > > test_recursion_try_acquire > [ protection area ] > test_recursion_release > > After release, there will be no protection, and thus it will fail the > tools/testing/selftests/bpf/progs/recursion.c[1] test case, because > the recursion occurs in the bpf_prog_run() itself, But bpf programs are allowed to recurs. Hence, you need separate logic to detect that. The test_recursion_*() code is for cases that are not allowed to recurs. > > __bpf_prog_enter > test_recursion_try_acquire > [...] > test_recursion_release > // no protection after the release > bpf_prog_run() > bpf_prog_run() // the recursion can't be prevented. But I thought you can run a bpf_prog from another bpf_prog. So you don't want to prevent it. You need other logic to detect if it was not suppose to recurs. -- Steve > __bpf_prog_enter > test_recursion_try_acquire > [...] > test_recursion_release > bpf_prog_run() > bpf_prog_run() > __bpf_prog_enter > test_recursion_try_acquire > [...] > test_recursion_release > bpf_prog_run() > [ And so on ... ] > > [1]. https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/progs/recursion.c#n38