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=-4.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no 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 B942FC4742C for ; Sat, 31 Oct 2020 00:02:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E49422245 for ; Sat, 31 Oct 2020 00:02:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604102576; bh=XcayW/yJcfpBZonnL860+1oal+jGF2JlNLnO8iX0Adg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=KkNXXqeH4MdXuUbErGhGL+4aicr2m0WeFNQETsfuw52q/QYMm7XYvWFV3TPLK92e2 sNZu8RjMn/wy+DukEJC382Ncy60iRGbfuxE8lLN/t3kEuxWHxc64290jX/nQ3s0XpC xYyTUe0/FFexK0k2/gDabNUc21RuanBmqtoG8JqQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725905AbgJaACz (ORCPT ); Fri, 30 Oct 2020 20:02:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:60668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbgJaACz (ORCPT ); Fri, 30 Oct 2020 20:02:55 -0400 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 08FD822245; Sat, 31 Oct 2020 00:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604102574; bh=XcayW/yJcfpBZonnL860+1oal+jGF2JlNLnO8iX0Adg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Gf4UuXuAvIBbtl18fjaZNvFv65PQhSxdu5jKSG5abh4Kc1iVeYGsAvEbcd7zTA+vs rckw14QUGGSDXcwPvj4Wd2XMLw+1nd4Yn/uLpQPm9YSKyO18THJi1pPtrZsGJCj9jj UjaNr7iKuIasSVZEJL+J6IWmDUG6zS6DnA1JjAGA= Received: by mail-lf1-f43.google.com with SMTP id l28so9990729lfp.10; Fri, 30 Oct 2020 17:02:53 -0700 (PDT) X-Gm-Message-State: AOAM531hk0EVOpO0YwKYmLs2tTWztjFPR/boh30sNSLMsuDHlTmhjaVM c647WHPLEnpP4bIQ/YmxIrJCqsUfabtN7qV+5Z4= X-Google-Smtp-Source: ABdhPJyMlt+0q1vF2Zy8DUufSjl9eV6bNPhC3X8kZTVnObP+T1whIr7MqwR62B3BcC0HoEIpJ9Yz1rQdL/NL4eOJAEo= X-Received: by 2002:a19:804d:: with SMTP id b74mr1837998lfd.55.1604102572217; Fri, 30 Oct 2020 17:02:52 -0700 (PDT) MIME-Version: 1.0 References: <20201027170317.2011119-1-kpsingh@chromium.org> <20201027170317.2011119-2-kpsingh@chromium.org> In-Reply-To: From: Song Liu Date: Fri, 30 Oct 2020 17:02:41 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH bpf-next 1/5] bpf: Implement task local storage To: KP Singh Cc: open list , bpf , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Paul Turner , Jann Horn , Hao Luo Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 30, 2020 at 4:07 AM KP Singh wrote: > > " > > On Fri, Oct 30, 2020 at 12:28 AM Song Liu wrote: > > > > On Wed, Oct 28, 2020 at 9:17 AM KP Singh wrote: > > > > > > From: KP Singh > > > > > > Similar to bpf_local_storage for sockets and inodes add local storage > > > for task_struct. > > > > > > The life-cycle of storage is managed with the life-cycle of the > > > task_struct. i.e. the storage is destroyed along with the owning task > > > with a callback to the bpf_task_storage_free from the task_free LSM > > > hook. > > > > It looks like task local storage is tightly coupled to LSM. As we discussed, > > it will be great to use task local storage in tracing programs. Would you > > like to enable it from the beginning? Alternatively, I guess we can also do > > follow-up patches. > > > > I would prefer if we do it in follow-up patches. > > > > > > > The BPF LSM allocates an __rcu pointer to the bpf_local_storage in > > > the security blob which are now stackable and can co-exist with other > > > LSMs. > > > > > > The userspace map operations can be done by using a pid fd as a key > > > passed to the lookup, update and delete operations. > > > > While testing task local storage, I noticed a limitation of pid fd: > > > > /* Currently, the process identified by > > * @pid must be a thread-group leader. This restriction currently exists > > * for all aspects of pidfds including pidfd creation (CLONE_PIDFD cannot > > * be used with CLONE_THREAD) and pidfd polling (only supports thread group > > * leaders). > > */ > > > > This could be a problem for some use cases. How about we try to remove > > this restriction (maybe with a new flag to pidfd_open) as part of this set? > > I would appreciate it if we could also do this in a follow-up patch. > > I do see that there is a comment in fork.c: > > "CLONE_THREAD is blocked until someone really needs it." > > But I don't understand the requirements well enough and would thus prefer > to do this in a follow-up series. Sounds good. Let's work on these in follow-up patches. Thanks, Song