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=-3.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 64371C4727E for ; Thu, 1 Oct 2020 16:19:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 28793208B6 for ; Thu, 1 Oct 2020 16:19:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kKCa/HMc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732274AbgJAQTL (ORCPT ); Thu, 1 Oct 2020 12:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732048AbgJAQTL (ORCPT ); Thu, 1 Oct 2020 12:19:11 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9EFEC0613D0; Thu, 1 Oct 2020 09:19:10 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id k13so5015178pfg.1; Thu, 01 Oct 2020 09:19:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=MJEN6/5FxUZ7OvX1MfoZIJYkf9njQgwG4hA1l6IMw0I=; b=kKCa/HMcidopfQYMgG1MnaV4E7MWeG0ZNU2ueVB6Ep4OYWvKYggKjzJkKTPBYAwfmU gDmiCAvNG6U+UyrWHMC4lpV7wI+FQ0u/iuWVHEVsOvXRxPjp1V7PkDYtTs4wIJpOrMVY F/3NMyqKUlnHboeHra8Rz17oKGWWKqsgaVoSUVOG4Zp89vGQNUvWDuGQjdA9/qD2wZSl ERDpbN98d5N105oqojlolCytrAGPVuFQ7PRqf7i7o2t6B0UxU5SFS2kokt4F4x/GxFLm VoBTG8G+9voKvVPNpHrJo425NMhCQOl3OlYzCiG/TGFTFIkIxGMpvQ85PMuSX5eq4u0C nArg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=MJEN6/5FxUZ7OvX1MfoZIJYkf9njQgwG4hA1l6IMw0I=; b=UVAXriNg5ky77JftuTaZ/G/FyIWFFpCD8hkYT2HFmxB4cdIXiAUkQE0+94v238Wv0M E0fqxqLmT555wOGzl1G65DSR1j1EkrN2xnwahfiLoBj0sQ5BQqIPJPZS+Qk6xycgG8mY IZxN8CW7D3+I0zNtFHhmnyC6/3neKQYR73d+bTy08kxE5dip7MhHLk4JauRARd10fMTI asFdOs0xTyV2uLU3xApry7iEuowkr94BcxhDv8e0gI5XFsYzFAIlfOQApNBiTshLM25+ /5UJh+7+1dRfI4JZ8C1Wz891Cr/ZMWKYnuTni+RCJEmoZACg99O/XoppW0LvVP+lcBkD QSSw== X-Gm-Message-State: AOAM5305OXWqfOz6z9ex6ayf+uqzgZMoV+NznFXN2EbtF4KcUgXotmTh UL41DEj7k2DCrqx11wmByKp05PfBdjtttH4PiEU= X-Google-Smtp-Source: ABdhPJyjU9K2yAHHlgJFP8jH9bKHRFNEu8FPzsXId8yBn7IKSN8taOEKNIEPNUGKxDexWM2C51Vpy6MLxd3XFzl9Z4c= X-Received: by 2002:a63:5043:: with SMTP id q3mr6682178pgl.293.1601569150444; Thu, 01 Oct 2020 09:19:10 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: YiFei Zhu Date: Thu, 1 Oct 2020 11:18:59 -0500 Message-ID: Subject: Re: [PATCH v3 seccomp 5/5] seccomp/cache: Report cache data through /proc/pid/seccomp_cache To: Jann Horn Cc: Linux Containers , YiFei Zhu , bpf , kernel list , Aleksa Sarai , Andrea Arcangeli , Andy Lutomirski , David Laight , Dimitrios Skarlatos , Giuseppe Scrivano , Hubertus Franke , Jack Chen , Josep Torrellas , Kees Cook , Tianyin Xu , Tobin Feldman-Fitzthum , Tycho Andersen , Valentin Rothberg , Will Drewry Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org On Thu, Oct 1, 2020 at 11:05 AM Jann Horn wrote: > Yeah. > > The ONE() entry you're adding to tgid_base_stuff is used to help > instantiate a "struct inode" when someone looks up the path > "/proc/$tgid/seccomp_cache"; then when that path is opened, a "struct > file" is created that holds a reference to the inode; and while that > file exists, your proc_pid_seccomp_cache() can be invoked. > > proc_pid_seccomp_cache() is invoked from proc_single_show() > ("PROC_I(inode)->op.proc_show" is proc_pid_seccomp_cache), and > proc_single_show() obtains a temporary reference to the task_struct > using get_pid_task() on a "struct pid" and drops that reference > afterwards with put_task_struct(). The "struct pid" is obtained from > the "struct proc_inode", which is essentially a subclass of "struct > inode". The "struct pid" is kept refererenced until the inode goes > away, via proc_pid_evict_inode(), called by proc_evict_inode(). > > By looking at put_task_struct() and its callees, you can figure out > which parts of the "struct task" are kept alive by the reference to > it. Ah I see. Thanks for the explanation. > By the way, maybe it'd make sense to add this to tid_base_stuff as > well? That should just be one extra line of code. Seccomp filters are > technically per-thread, so it would make sense to have them visible in > the per-thread subdirectories /proc/$pid/task/$tid/. Right. Will do. YiFei Zhu