Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp1285490pxm; Thu, 3 Mar 2022 14:16:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDB7h/dz2cjce/7FMo3brxtYV3M7fYerS3RL3DFRKYbSvAbAJ3NcFLGHOWImwIkyJ2jvL+ X-Received: by 2002:a17:902:cf03:b0:14d:880d:75b5 with SMTP id i3-20020a170902cf0300b0014d880d75b5mr38045319plg.129.1646345764690; Thu, 03 Mar 2022 14:16:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646345764; cv=none; d=google.com; s=arc-20160816; b=zb7Scm49mc5rjwBIYtleHX34/dnp6aftDBMVG5vDp0qjxulASjqmGU9qB3Br7Tpciz rksUwyUrwC2cum9XQu6FzbnKOl6aCHQzEwBVYT7OQLljio0gQtYwiU6lvjoUe9tFsk3o YqQD2pM+BQ/rmJW3wCnNYvJcBtGiecHTZ3eudamRXSrMEeHNP3Ifn0YAkTnaTW7FR8TY GDtDsqMidQa/naimWu1V4qx5Xnt404PrmWWc46sH6MkqDpWfdPpO+3PqaD43azoKyDya luxwy2myuQW/77vvh9Wz9bOu+1N9Q0E3Ej9Yd73teekm/zLSFDO++FNsdhKQLdCOBGdn RWWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ZLz6jo4x58h2g9mHNukYRMIkhrbbw9vzkVWIa2i7m3Q=; b=PoImsYYhG+eH9lPVH8xXpCktHCY2Sr+2tHKWsDQR/Pwe7AhVa7GDv5caI+0rJCbw6I q8FPbTRksMhMjVov0gjGSlClaSeCYOOpir3gy19fP0MCu3gbpd1h9ydTgQPRUPrmy0Jn feixm+nyZabs4uu4DnBp9Y0W8awUbMuL48ms1rT7VamQOO/hYIPIiGjXtCsJ7jbH3Zz3 aSO31TS8/iwqzBY0bGIxHi0aEXbQoiNI+vmcXTuHPQ3Qm90YidJ/+nk/1I+tE0JXKHQn KfEOHPCVnyQY9zEKO4Tb55hRlqw5WmXrOgm1Vg3j62WnY90dpH30Dh7ZAy6KeycXhV6L WnnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=M2wy4Eeq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f29-20020a63101d000000b003658523c918si3400239pgl.781.2022.03.03.14.15.47; Thu, 03 Mar 2022 14:16:04 -0800 (PST) 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=@google.com header.s=20210112 header.b=M2wy4Eeq; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235258AbiCCTiY (ORCPT + 99 others); Thu, 3 Mar 2022 14:38:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232927AbiCCTiW (ORCPT ); Thu, 3 Mar 2022 14:38:22 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A106F64F0 for ; Thu, 3 Mar 2022 11:37:34 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 8so4955789qvf.2 for ; Thu, 03 Mar 2022 11:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZLz6jo4x58h2g9mHNukYRMIkhrbbw9vzkVWIa2i7m3Q=; b=M2wy4Eequ/VYrHh7vqbtylJTihfO5wHVfscRBSvANAAaHg6MttPacF5n578ODHmCHi raE5o+IETL5qV+2giWFnOU8WvjBnPHV4oq5mmGlnOBMa79WNfGBNMbLrEthPd5htrKT0 Jvkuhx8rCSD9MuClXK3vxXhJUNPLM2vE0sER/Li+ms27dFJHEHi1AT2ayM7SabjAiZLX JWv/Ll3w8nEXZNQAz5yfdD6lfeip7k8vaX2pUgqOu3L2YLgFoRdKz7wORrE1OuaBkCVB EulaUDUwhKUFlICPIbvoQXMTe0xcwj2fZLptvqrXiAld3zWNc+yZBfbktLlFFZ3iihFG Ar+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZLz6jo4x58h2g9mHNukYRMIkhrbbw9vzkVWIa2i7m3Q=; b=trqTHOpTYSZr+71aVPBn074YKcaXXlfMqaVtaUhMEv+uqGn12BtbSCjdgAD7yxLSbY WBAcJYlRyIy6IH9akLywolMAQNDIVbUSha/HwFhau08dOyXyEUmBaOwTcCr/e44O4Z2L kqhnWFJKWFvS3cUIldDThczJNpikoauByw3XF3zhbukAuQwhfshElCrjL743YLvGSXh2 MNAR0kvuWF2TFN4el6Gu302nBE/0GFXSBoy4EN66o8QAqpywoDjq96uZpT/4qkwHp+XN W2hFszbVu/+wqwl0TDTfbsw0KSqDk0QRimLvBVwUm/m4fWZ5Vs3rjlLa1zVAfy4p42Yk f2XQ== X-Gm-Message-State: AOAM531x5q8Rhe8B91sNy/3wFku4MKu8nehY8JUp1e9nUeWp6q65c4KX yw/NPMDAziKw9hu9cTH058Xud8sjgmgA7OKdCbxTJg== X-Received: by 2002:a05:6214:202f:b0:432:4810:1b34 with SMTP id 15-20020a056214202f00b0043248101b34mr25370584qvf.35.1646336253632; Thu, 03 Mar 2022 11:37:33 -0800 (PST) MIME-Version: 1.0 References: <20220225234339.2386398-1-haoluo@google.com> <20220225234339.2386398-5-haoluo@google.com> <20220302194141.c4gvqz5v4mmmbwsv@ast-mbp.dhcp.thefacebook.com> In-Reply-To: <20220302194141.c4gvqz5v4mmmbwsv@ast-mbp.dhcp.thefacebook.com> From: Hao Luo Date: Thu, 3 Mar 2022 11:37:21 -0800 Message-ID: Subject: Re: [PATCH bpf-next v1 4/9] bpf: Introduce sleepable tracepoints To: Alexei Starovoitov Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shakeel Butt , Joe Burton , Tejun Heo , joshdon@google.com, sdf@google.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-18.1 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Wed, Mar 2, 2022 at 11:41 AM Alexei Starovoitov wrote: > > On Fri, Feb 25, 2022 at 03:43:34PM -0800, Hao Luo wrote: > > diff --git a/include/linux/tracepoint-defs.h b/include/linux/tracepoint-defs.h > > index e7c2276be33e..c73c7ab3680e 100644 > > --- a/include/linux/tracepoint-defs.h > > +++ b/include/linux/tracepoint-defs.h > > @@ -51,6 +51,7 @@ struct bpf_raw_event_map { > > void *bpf_func; > > u32 num_args; > > u32 writable_size; > > + u32 sleepable; > > It increases the size for all tracepoints. > See BPF_RAW_TP in include/asm-generic/vmlinux.lds.h > Please switch writeable_size and sleepable to u16. No problem. > > > > -static const struct bpf_func_proto * > > -syscall_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) > > +/* Syscall helpers that are also allowed in sleepable tracing prog. */ > > +const struct bpf_func_proto * > > +tracing_prog_syscall_func_proto(enum bpf_func_id func_id, > > + const struct bpf_prog *prog) > > { > > switch (func_id) { > > case BPF_FUNC_sys_bpf: > > return &bpf_sys_bpf_proto; > > - case BPF_FUNC_btf_find_by_name_kind: > > - return &bpf_btf_find_by_name_kind_proto; > > case BPF_FUNC_sys_close: > > return &bpf_sys_close_proto; > > - case BPF_FUNC_kallsyms_lookup_name: > > - return &bpf_kallsyms_lookup_name_proto; > > case BPF_FUNC_mkdir: > > return &bpf_mkdir_proto; > > case BPF_FUNC_rmdir: > > return &bpf_rmdir_proto; > > case BPF_FUNC_unlink: > > return &bpf_unlink_proto; > > + default: > > + return NULL; > > + } > > +} > > If I read this correctly the goal is to disallow find_by_name_kind > and lookup_name from sleepable tps. Why? What's the harm? A couple of thoughts, please correct me if they don't make sense. I may think too much. 1. The very first reason is, I don't know the use case of them in tracing. So I think I can leave them right now and add them later if the maintainers want them. 2. A related question is, do we actually want all syscall helpers to be in sleepable tracing? Some helpers may cause re-entering the tracepoints. For a hypothetical example, if we call mkdir while tracing some tracepoints in vfs_mkdir. Do we have protection for this? Another potential problem is about lookup_name in particular, sleepable_tracing could be triggered by any user, will lookup_name leak kernel addresses to users in some way? The filesystem helpers have some basic perm checks, I would think it's relatively safer.