Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp821260rwr; Thu, 27 Apr 2023 08:32:17 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4pVxpEp0f+H2ouh6K9n3438hgkGJQ56GHDZ4chwWwaoYfAu5p4c4f+MtBYvpS6GaVIDXTO X-Received: by 2002:a17:90a:1da:b0:24b:efc9:44d7 with SMTP id 26-20020a17090a01da00b0024befc944d7mr2134131pjd.0.1682609537210; Thu, 27 Apr 2023 08:32:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682609537; cv=none; d=google.com; s=arc-20160816; b=fBUQSZeKBfq90JcLS6rNgSEcMAHud/z7GxiGEw7pzYjQjE0AUr41dGOQJQnyYWc4Ch hccKbnkdPK4YuvqcSuObfepl7NC6hGISTwAe5RSTxpwHentHNR2wr9u+APFq7r+5ahZB 5FiYo5fZgXvvKw6LLUMPWMHkm8Qmf7JxjjNfcJrMGvhQefu/owrR1rYAYXDSkwU9MK1a zyRSGthVK60CshDfprozy8W5/3N+XDE8IPnM13/8hWoygrEAKddLHYwn2AyOQDIwzwfM 9v24udahKo/tNcw6sC2evtGSlsqPMV4JOR7x0JNDJTescUKRJHnbdQa3r+uQ1Ei4brLh ldlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DKhnqaYrWh0VRI0RjHLFiEQEfw/PaxTNK9hFCLYl2ZQ=; b=Qh3yLokTOEuyxVUKwy9Md1R+DMnLcLi+BW4ayPeW+ocET1Y9BmN2IGqa8oFIErEzlk 1NH0CpQnzXOVzOCaYbdrQjt5IUnMB7ru88k3ifcPXApcB68OC6kv42EaKrS/Ayo6rGG5 WJL2JKDy9PftwrwbdJJgry4JfOpI2Feum8iKLI2+3rgX7XLrbXv2Z6lecE58OIJRqOnq eQAUrLJ0ixPZCcaVuEMrk0RKv/1Xby+ieDQGyrl/qA+LnThrMHvWducU6gyOLAKnZiTW utH+qCoM/SCFr78LazWbpIsJzOSabuVeC0wKmLW+O3edVkv41EYYm1Rb022LUX1MY0bp a5AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=fWGEvATY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id em14-20020a17090b014e00b00247b413f4ffsi18875378pjb.185.2023.04.27.08.32.01; Thu, 27 Apr 2023 08:32:17 -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=@gmail.com header.s=20221208 header.b=fWGEvATY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243825AbjD0PYL (ORCPT + 99 others); Thu, 27 Apr 2023 11:24:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243459AbjD0PYK (ORCPT ); Thu, 27 Apr 2023 11:24:10 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65718113; Thu, 27 Apr 2023 08:24:09 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-5ef4885bc39so38576776d6.2; Thu, 27 Apr 2023 08:24:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682609048; x=1685201048; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DKhnqaYrWh0VRI0RjHLFiEQEfw/PaxTNK9hFCLYl2ZQ=; b=fWGEvATYqJuv/ziuBu5WMvCmI6wq3pOdiYtUJ53pYvsbBAOocRF6+VmO663imzHOMO aXGEJNT0zZ+lkL+Ueht76h3sFvynFXY/SEpWmI8CM7D9xySJEjzggSoClX0MoFpmOaKW Ni8qVuhic8ZokVYdfbS9HQb3iNt0ALCpxWSqNLv3l7XiGURMAgZEIF+XpwWHLouVfOGA P6CBKsGQElJ4t2S83VVRKeclIikBarmg+dN7KoGB7ODup3LqXVUSyYJnWys1hzdygZy7 oHOB12WbypLeqYmMcIsmesfpqA4uGK+3C0gJEsrSm2eLOqj4guaUCR3XVaBN2w6ksBxa Z6AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682609048; x=1685201048; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DKhnqaYrWh0VRI0RjHLFiEQEfw/PaxTNK9hFCLYl2ZQ=; b=LtXRHvH5B+sNNexLamBr9ohjaVVxVpyh6kYo/h00gzglsNUdUIkoGk5L9feE36N0sw vTlwirNFiABQ8VKvsl3w3NAjAkdTzosOgTTOR5HxaDaXN9KE4bJcPrKq8JSJnCeQsuP3 C0zifEWKmzpew+TRj8zGAN9FWOH7roKJuP0K0csaX61P8sJx40+VqTzkSFrVH/afNPU0 I7k/7/7Km8TcLq1V2j4sfkSzx+AT9Wt1UgfT4pjdh8bYw4FcjYcReWGOX7wljWyBu5ih PMRG2AluHrt/HjcMpq1/DAfM2zHoCY4Vg9KQUh9ZigqIayIIvCQqCVH3I5btFn1dyPHv GOww== X-Gm-Message-State: AC+VfDxSxIFT6wRgyIbODqU+02Yva5Hd9mXFDTiieUZ6QTsOgTEEAuZa bPiNWDW5uJB5bfz3Iv9c1Kub/DKL8z8qBgR5a19CVbWZ4LlNbg== X-Received: by 2002:ad4:5aa2:0:b0:5e8:3496:e641 with SMTP id u2-20020ad45aa2000000b005e83496e641mr3159318qvg.13.1682609048555; Thu, 27 Apr 2023 08:24:08 -0700 (PDT) MIME-Version: 1.0 References: <20230417154737.12740-1-laoar.shao@gmail.com> <20230417154737.12740-6-laoar.shao@gmail.com> <20230427092628.21fd23e4@gandalf.local.home> <20230427111842.2e40fe3c@gandalf.local.home> In-Reply-To: <20230427111842.2e40fe3c@gandalf.local.home> From: Yafang Shao Date: Thu, 27 Apr 2023 23:23:31 +0800 Message-ID: Subject: Re: [PATCH bpf-next 5/6] bpf: Improve tracing recursion prevention mechanism To: Steven Rostedt 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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, Apr 27, 2023 at 11:18=E2=80=AFPM Steven Rostedt wrote: > > 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 allowe= d > to recurs. > Agreed. > > > > __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. > If so, we have to keep the prog->active to prevent it, then I'm not sure if it is worth adding test_recursion_*(). --=20 Regards Yafang