Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp852536pxx; Thu, 29 Oct 2020 16:30:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxpVkJpvRNfEXKfdLQziPxxs6PMXVROdrjxW97I5DJ2ynEDlgrkHI4oGNzo7UIubBcmte3 X-Received: by 2002:a17:906:249a:: with SMTP id e26mr6394758ejb.484.1604014211423; Thu, 29 Oct 2020 16:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604014211; cv=none; d=google.com; s=arc-20160816; b=0fz+HVP+QAlRgf9qcT/too5lsaAINulhcmD1FEeofNx++4rNSIvlJ9N4G/Ba6nvDYr uDporPW6NQyMQ/+1W0QSwICMu1ADd0J6o8+wrHjdjCHm53K9Mx4zjzpNLnIZ4wRCdZL8 ueatJfdbaJrZKY6xr3I4kMkOTXZ27hQ8uxj1hWL1Y1Z8VFgsqbjKbX7x9/udges1o1LA PkqGNR4dbEeuv/zNErAUYEWiXUmM4k6BG7FURL22D8RkCbaUepnfvKIUbwt2Gqgz+2ou zGreA0fjzDe1hwPZv1mdpNy12R4N7LH6RvGMtZwncSk36X1wfZuD/LHWoxOo1QESROeG Rppw== 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=ZyhmPneCsl+WZU2lnZQJy0VMEcwGzsdxK0GcYHzW4es=; b=ezfVKiA7YUXp/+qqk75JH0yb9KPCiPzzrm9PSDKV7YC7a8v8GSxtcTr2QxpKetbrXn FaPoZmMuhXfgpwgdrUMrVGBmd8VObqJfYqoyr16BayQXOHASKJWluv76n/w13tofnZoM aTQiTi7ATxzV3dAsHbU0DMzgXY9Fa+UE/FbtEHE7LQy+V+uBKWYQsArkhgsCij99aYOl iT1RSVfDSeP7gwz5d9srxtQci7si3XZE/keLIszoTrIGlRJFnD4SbLM6LZVtdNI2n1lM ZNfmdmFUxnaJn6RZGZjVhTEhC70ATLHxSvGWaaXKIdccrKppU6ZPpLVCX0M0TP28/q8W xbow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pmYHMztf; 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 p18si3034246ejm.186.2020.10.29.16.29.48; Thu, 29 Oct 2020 16:30: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=pmYHMztf; 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 S1725800AbgJ2X2M (ORCPT + 99 others); Thu, 29 Oct 2020 19:28:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:59462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbgJ2X2M (ORCPT ); Thu, 29 Oct 2020 19:28:12 -0400 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 305BD20BED; Thu, 29 Oct 2020 23:28:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604014091; bh=ZGC+Xp6nyJqG7qQE4W73onxUN0sycaXuLyBzJX/PmHo=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=pmYHMztfmCpO3ah+/yJRu1db0AsnD1WO6AhahE2I+BumtOhoxSIWNRpafkV5Q8Wx8 c0q6g91/SD15ADY4HFR4BVXhRkBe4OVfD5qeMy1YHcRPed7jkkCilp9KScJgsRE8L6 28L6TeGAbrBndY4vIgvJ4GwUY1UTHmC2dDsXVO40= Received: by mail-lj1-f181.google.com with SMTP id 2so4908116ljj.13; Thu, 29 Oct 2020 16:28:11 -0700 (PDT) X-Gm-Message-State: AOAM532Hc6D/GfpSkhM+j8m/uEDTGOBUqEF3PCsLZIsbvLYe0oUpy0yr C1ycP9whcniltiaOOOflFx0azLjsz4ElZ/p8/8A= X-Received: by 2002:a2e:a0d4:: with SMTP id f20mr1241951ljm.350.1604014089320; Thu, 29 Oct 2020 16:28:09 -0700 (PDT) MIME-Version: 1.0 References: <20201027170317.2011119-1-kpsingh@chromium.org> <20201027170317.2011119-2-kpsingh@chromium.org> In-Reply-To: <20201027170317.2011119-2-kpsingh@chromium.org> From: Song Liu Date: Thu, 29 Oct 2020 16:27:58 -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 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. > > 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? Thanks, Song [...]