From mboxrd@z Thu Jan 1 00:00:00 1970 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=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS 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 222ACC43381 for ; Fri, 22 Mar 2019 22:43:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF6912190A for ; Fri, 22 Mar 2019 22:43:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="TyqhUKNk"; dkim=pass (1024-bit key) header.d=fb.onmicrosoft.com header.i=@fb.onmicrosoft.com header.b="DjznR0Yf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728361AbfCVWnY (ORCPT ); Fri, 22 Mar 2019 18:43:24 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:39052 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728006AbfCVWnY (ORCPT ); Fri, 22 Mar 2019 18:43:24 -0400 Received: from pps.filterd (m0044010.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2MMeZ4T001793; Fri, 22 Mar 2019 15:43:04 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=+Ztqw6pTWs6617Vzn+ZNydb3Yw08TpP93s5jdRHETYs=; b=TyqhUKNkuBLBpDDJEzPPDqzDNwxl28Jhe/zRhIKtUK4drtxpNlZzfXjbSJ+aKzcsohkn 9bsJN/X6w4EQIby0IvkLrQqyckfy3f9v7sTf2PalGfNL1c5TcwSSP+QqX0TCby+4Uf98 EUzrlC0C5G63be1VHJvK9VPzjzjUSGVffiM= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2rd45hh3gr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Fri, 22 Mar 2019 15:43:04 -0700 Received: from frc-mbx04.TheFacebook.com (192.168.155.19) by frc-hub02.TheFacebook.com (192.168.177.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 22 Mar 2019 15:42:06 -0700 Received: from frc-hub02.TheFacebook.com (192.168.177.72) by frc-mbx04.TheFacebook.com (192.168.155.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5; Fri, 22 Mar 2019 15:42:06 -0700 Received: from NAM01-BN3-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.1.1713.5 via Frontend Transport; Fri, 22 Mar 2019 15:42:05 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+Ztqw6pTWs6617Vzn+ZNydb3Yw08TpP93s5jdRHETYs=; b=DjznR0Yfcd0bQvIny03J4S78gAGzd+/kCPIdWRQQ9ZEaMqDudOpAksPQM3+0LnHLsa04EsrTB/kqI48b8rRmfQIXKrMLGeIwX6FKqBjoXpPrI0bZGfxBJ1BtuRSHVgpqfykwqqG25co9S3qxKtZNTl3j7WhCsKejVmQOtKXQtZk= Received: from MN2PR15MB2656.namprd15.prod.outlook.com (20.179.146.26) by MN2PR15MB2528.namprd15.prod.outlook.com (20.179.146.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1730.18; Fri, 22 Mar 2019 22:42:04 +0000 Received: from MN2PR15MB2656.namprd15.prod.outlook.com ([fe80::a4fc:4858:3315:6fee]) by MN2PR15MB2656.namprd15.prod.outlook.com ([fe80::a4fc:4858:3315:6fee%2]) with mapi id 15.20.1730.013; Fri, 22 Mar 2019 22:42:04 +0000 From: Javier Honduvilla Coto To: Daniel Borkmann CC: "netdev@vger.kernel.org" , Yonghong Song , Kernel Team Subject: Re: [PATCH v3 bpf-next 0/3] bpf: add bpf_progenyof helper Thread-Topic: [PATCH v3 bpf-next 0/3] bpf: add bpf_progenyof helper Thread-Index: AQHU1MffIHrmlZaWLECfRgYPKUc6PaYYV1UA Date: Fri, 22 Mar 2019 22:42:04 +0000 Message-ID: <20190322224154.GA95149@fb.com> References: <20190301180614.4134278-2-javierhonduco@fb.com> <20190305224759.2555660-1-javierhonduco@fb.com> In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: LO2P265CA0075.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:8::15) To MN2PR15MB2656.namprd15.prod.outlook.com (2603:10b6:208:128::26) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [2620:10d:c092:180::1:c1d] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 3192ae4f-1b85-43b2-3a34-08d6af179b11 x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(5600127)(711020)(4605104)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020);SRVR:MN2PR15MB2528; x-ms-traffictypediagnostic: MN2PR15MB2528: x-microsoft-antispam-prvs: x-forefront-prvs: 09840A4839 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(396003)(346002)(366004)(136003)(39860400002)(53754006)(199004)(189003)(6246003)(6916009)(33656002)(14454004)(68736007)(71200400001)(71190400001)(229853002)(106356001)(102836004)(6486002)(6436002)(186003)(4326008)(81156014)(8676002)(478600001)(2906002)(54906003)(105586002)(81166006)(7736002)(46003)(486006)(6116002)(316002)(2616005)(446003)(476003)(11346002)(53936002)(5660300002)(36756003)(86362001)(99286004)(305945005)(6512007)(76176011)(52116002)(97736004)(53546011)(6506007)(386003)(1076003)(256004)(14444005)(5024004)(25786009)(8936002);DIR:OUT;SFP:1102;SCL:1;SRVR:MN2PR15MB2528;H:MN2PR15MB2656.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: yMgI2vD+HuBxyG4BB7VeFTLIwpqh1psNrb0RrUWQ0Z+04ihhSJ2J52g0ubGaUMzVPFCVGnSUuoIi5ekBR6CEfkx9/qoEVoJP24ohZFeKITC5WuDvCYq/E2x8yG1cIj8eppu0FMZmi8BIWfLa4KElQ3anyUEf3qVlwNHc+5YdSHMvHsxS9KO3ft3iLWBtd4wa6DA8phayQ4Y5DlEs8Di9F4HWOvHw1bwl9Y6n+9QJYt05IrT21E7na04oq5pPVmqfSVUth0jvg+vxWk5QQ1J7SPMBljyX5vvdpjYRrJtdVDYtXROteIxPBAUrZWKEYIg5xxuo4Syplb31jgLV1TuPll97xSeT7wkZ2TNxBQqTGp7R419Jq18y8T6hmrPwbDMtIogeFI9Ja0uTUN3ooD5g93B2zgabacJPbqhm6Y+0/kE= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 3192ae4f-1b85-43b2-3a34-08d6af179b11 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Mar 2019 22:42:04.6024 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR15MB2528 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-22_13:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Thu, Mar 07, 2019 at 10:26:22AM +0100, Daniel Borkmann wrote: > On 03/05/2019 11:47 PM, Javier Honduvilla Coto wrote: > > Hi all, > > > > This patch add the bpf_progenyof helper which receives a PID and return= s > > 1 if the process currently being executed is in the process hierarchy, > > including itself or 0 if not. > > > > This is very useful in tracing programs when we want to filter by a > > given PID and all the children it might have. The current workarounds > > most people implement for this purpose have issues: > > > > - Attaching to process spawning syscalls and dynamically add those PIDs > > to some bpf map that would be used to filter is cumbersome and > > potentially racy. > > - Unrolling some loop to perform what this helper is doing consumes lot= s > > of instructions. That and the impossibility to jump backwards makes i= t > > really hard to be correct in really large process chains. > > > > Let me know what do you think! > > > > Thanks, > > > > --- > > Changed in V3: > > - Removed RCU read (un)locking as BPF programs alredy run in RC= U locked > > context > > - progenyof(0) now returns 1, which, semantically makes more se= nse > > - Added new test case for PID 0 and changed sentinel value for = errors > > - Rebase on latest bpf-next/master > > - Used my work email as somehow I accidentally used my personal= one in v2 > > > > Changed in V2: > > - Adding missing docs in include/uapi/linux/bpf.h > > > > Javier Honduvilla Coto (3): > > bpf: add bpf_progenyof helper > > bpf: sync kernel uapi headers > > bpf: add tests for bpf_progenyof > > > > include/linux/bpf.h | 1 + > > include/uapi/linux/bpf.h | 10 +- > > kernel/bpf/core.c | 1 + > > kernel/bpf/helpers.c | 32 +++ > > kernel/trace/bpf_trace.c | 2 + > > tools/include/uapi/linux/bpf.h | 9 +- > > tools/testing/selftests/bpf/.gitignore | 1 + > > tools/testing/selftests/bpf/Makefile | 2 +- > > tools/testing/selftests/bpf/bpf_helpers.h | 1 + > > .../selftests/bpf/progs/test_progenyof_kern.c | 46 +++ > > .../selftests/bpf/test_progenyof_user.c | 268 ++++++++++++++++++ > > 11 files changed, 370 insertions(+), 3 deletions(-) > > create mode 100644 tools/testing/selftests/bpf/progs/test_progenyof_ke= rn.c > > create mode 100644 tools/testing/selftests/bpf/test_progenyof_user.c > > > > bpf-next is closed right now due to merge window, please resubmit once it > opens, thanks! Just did! Thanks :)