Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1692221pxx; Fri, 30 Oct 2020 17:05:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzNUQPZc8gsJtLS4GBwhpMx8fAiZT2ZKA9UhPBJI+WUrqIJM9cQY8yeWkMisCmQPzxJlxQ4 X-Received: by 2002:aa7:c054:: with SMTP id k20mr5316107edo.224.1604102711987; Fri, 30 Oct 2020 17:05:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604102711; cv=none; d=google.com; s=arc-20160816; b=N/OTx0mJphH6Sw+e7ftMj0XhfRT/FEZIjal3d6o0j/GuArvHRK+PtOmis+b7gxg7+K h494oZGHeSaVj8w+Ir322v5SlIH/b3Uv1YIPfrANrXrEtLw2BrCyliILb/FTeVGRL1kT p0d/VQ8S8+06SOhzlswt5TWJkgGQ61rH54dpZ0g6coBWWP04WliDoNd7u6gcb1DSRhIM k9mdZdxqvFaIHotF9D0gPcc+Vb9LRUGESwilnuKxYCTURiG2dd+MPzyfEp10u07Pc0Bp qPo315XfbQ1tiQCz+iEwyYUVjmUVsEqbY0dlK5HTbNuDzCZnPS8onFFDkLmZMTTbcP9S qPQA== 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=WcfIZ4DyYuYra18Epkw9ZgRpYT8KD2+5WLjR1EELkBs=; b=fU5gRPlejcUqHV+UV5afYjsWxOA5Trfnd18vl7FBHc8jg6d/hrTTNqQQrX87GpXWj/ DwgpDroTJ61UtmHjIZaBYi/4zDtGSHHZIYUr6l7p8arRpQtfKB3u+bkniJWwRbDayA4A TSFbdJMMBx+uDamcvxlX28RkIl8oChEdb2wLMpUE+s61pXRp92atc/C7UhSaprQLX0gc AXFBSKjsKuaqSrPFF61iB4/BA2Wf6+VTBvhDiWPY3z56xPhpH/oI7eikRTNRNnyma1hD IG080qR48HF/lKBYcgX6AeEuaZ2jmo5fMkvcdHYpfYsDTXUzHO88Bp//UIwD0l3NgF/2 hirg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gf4UuXuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e15si5416798edm.536.2020.10.30.17.04.49; Fri, 30 Oct 2020 17:05:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Gf4UuXuA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725861AbgJaACz (ORCPT + 99 others); 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-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