Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp283238pxf; Wed, 17 Mar 2021 23:16:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwcXW7dT3pbWVpfSM9KqSg8HumeV8cGg0K7DDvXKQfSzsDFIFPM9DHgpJuScRpxVFANs0mP X-Received: by 2002:a05:6402:438f:: with SMTP id o15mr1617830edc.123.1616048164915; Wed, 17 Mar 2021 23:16:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616048164; cv=none; d=google.com; s=arc-20160816; b=QqsdAkbKWumxart1d9LdkidMI/BpMUvQ+zyy4dGgoXv+CpXt7Nb7oSgkBF/jAQcVCM Qm+kyhVxrRtdqy+lE4dWtKHMFsIE4TB/9A2yvUB5OFIZIlYgRArGdkSSUMQqUflR+ORR yxeUofWwguJ5T6rKR7xzoMZGtMyW09BgUfmAYOrLPoxXJpTK7W6LKWGS5c8qgUMD/HLf wSYX65UOcXezXEzrRYnmBooN7h3P0CstRD7Tq2jORCSHJYUypy/nrvZDXIsuiXnjUzLg tKmdu9j/2iR+uOTtYW8bSeiwspkg6hDoR0ddHBIttItIBPeMwXha+TWk4OnTj9661LZj lRGA== 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=2PfJSGhVIXOhUCTnbC4O18i2rgfMR9l6aqEhZ+m64aE=; b=EXn090nuCkiK7G9Ez8m4aCCwm7k0KaDji8UFTptSdvKaHZUCp3hxWhDMfRptY/PAx7 ZkNPuXfnTJ7A3YY2tTy+zXSAcZUswgsC5PTzucct5HLAV15e6dUEDze/sDSmBHONsk3H RAeRt3GEVFfedWvU9PNhm/GTiMajZevLAA3Fy6m0ncia01cayTj3aFUmkTycGYfEg9QX ZpKmKcOFHsNi1bsK8PhAQnSxdmsncsM1kKljaV/6hk5K74Ww1w8iSFAEC7PCoBPqiAO1 kjgkxO9xTevhzbna8bdjQZqu1DsOEfloLXkrLJ4+sjn9VkyCDb1uVLTjOcGnGADdnqi1 MQDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Bj20pbfJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si802368edy.342.2021.03.17.23.15.42; Wed, 17 Mar 2021 23:16:04 -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=@google.com header.s=20161025 header.b=Bj20pbfJ; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbhCRGOb (ORCPT + 99 others); Thu, 18 Mar 2021 02:14:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhCRGOW (ORCPT ); Thu, 18 Mar 2021 02:14:22 -0400 Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DF68C06175F for ; Wed, 17 Mar 2021 23:14:21 -0700 (PDT) Received: by mail-pl1-x633.google.com with SMTP id e14so756686plj.2 for ; Wed, 17 Mar 2021 23:14:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2PfJSGhVIXOhUCTnbC4O18i2rgfMR9l6aqEhZ+m64aE=; b=Bj20pbfJeNE2YdFKUD/MaTbGJmD4ZucMFS1HjM8hJ43vUiqq+wu14WIBSUYepacT17 G4Li7MpGUsW/o87QJXg1qgQcPhQTCya1C8xi7N8dKRD/Q/ZBB6S/AD15CqhBJD5oAKrn lwraLQ++Zhpp+fFHN8Xjd017DiACD6Dw01oGz1pfd19Rj9WXVTXsw44oQqrHmhpkvUnY YzhzTmiCp/yYdwgtqp4qzk+rvnebt502pdDiX1kSMSwJARFgI14p1DGaKuOawhZKsf7d BFhKqdKiirZd1l7A8L6CxYX8Re/LWihgbJBLZ03ZC8k0T5hm/TWc15r/oWNIJgJHYBGI H6xA== 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=2PfJSGhVIXOhUCTnbC4O18i2rgfMR9l6aqEhZ+m64aE=; b=s1u/+UD0uPnyfBeTqhfcxT8rweFpE7g9UqUdd1ds33o5dckxjp+bymRTGcqwdo256c 2werKmOE4UDrHC0tLHoj7CFjy6s3GpHXJ18QG3OXB+jL3Qpb4GDtamKIADsymv2mycZi eRXY7Jhry6uNeBdK++s6FEjrlUZxkAVZaxqJG/YxrY4nUEMFu6F3/0d+MMVxFTs+5K8E AtUrVRABWQtG02YycqWPNQm0yP0CHJyh2qFJK+gl0Aa2V1cMHEexgp2Afgq26elCzV7C 8Mx7rAY9prz0yqaUsQ2OgbEi9mGODVkzLdcCsetUtDkFh+Hxtf0FSDG3DlJDoxihMgL5 Tizg== X-Gm-Message-State: AOAM533s/9n8MOJ3qeVvfVP3RCxHJzn1Zw/71kFFzlBNL7l/rMEOr6pN zP/Sp8+mphujIUSSdb3rZdAb8JPYiZD6qjMjObZhBQ== X-Received: by 2002:a17:90a:fb8e:: with SMTP id cp14mr2661187pjb.52.1616048060530; Wed, 17 Mar 2021 23:14:20 -0700 (PDT) MIME-Version: 1.0 References: <20210308170651.919148-1-kaleshsingh@google.com> <202103172255.46B192DA@keescook> In-Reply-To: <202103172255.46B192DA@keescook> From: Kalesh Singh Date: Wed, 17 Mar 2021 23:14:08 -0700 Message-ID: Subject: Re: [RESEND PATCH v6 1/2] procfs: Allow reading fdinfo with PTRACE_MODE_READ To: Kees Cook Cc: Jann Horn , Jeffrey Vander Stoep , Suren Baghdasaryan , Minchan Kim , Hridya Valsaraju , Randy Dunlap , =?UTF-8?Q?Christian_K=C3=B6nig?= , Matthew Wilcox , Alexander Viro , "Cc: Android Kernel" , Alexey Dobriyan , Jonathan Corbet , Andrew Morton , Mauro Carvalho Chehab , Michal Hocko , Alexey Gladkov , Szabolcs Nagy , "Eric W. Biederman" , Christian Brauner , Michel Lespinasse , Bernd Edlinger , Andrei Vagin , Helge Deller , James Morris , LKML , linux-fsdevel , "open list:DOCUMENTATION" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 17, 2021 at 10:55 PM Kees Cook wrote: > > On Mon, Mar 08, 2021 at 05:06:40PM +0000, Kalesh Singh wrote: > > Android captures per-process system memory state when certain low memory > > events (e.g a foreground app kill) occur, to identify potential memory > > hoggers. In order to measure how much memory a process actually consumes, > > it is necessary to include the DMA buffer sizes for that process in the > > memory accounting. Since the handle to DMA buffers are raw FDs, it is > > important to be able to identify which processes have FD references to > > a DMA buffer. > > > > Currently, DMA buffer FDs can be accounted using /proc//fd/* and > > /proc//fdinfo -- both are only readable by the process owner, > > as follows: > > 1. Do a readlink on each FD. > > 2. If the target path begins with "/dmabuf", then the FD is a dmabuf FD. > > 3. stat the file to get the dmabuf inode number. > > 4. Read/ proc//fdinfo/, to get the DMA buffer size. > > > > Accessing other processes' fdinfo requires root privileges. This limits > > the use of the interface to debugging environments and is not suitable > > for production builds. Granting root privileges even to a system process > > increases the attack surface and is highly undesirable. > > > > Since fdinfo doesn't permit reading process memory and manipulating > > process state, allow accessing fdinfo under PTRACE_MODE_READ_FSCRED. > > > > Suggested-by: Jann Horn > > Signed-off-by: Kalesh Singh > > Reviewed-by: Kees Cook > > Who would be best to pick this up? Maybe akpm? Thanks Kees. Andrew has queued the patchset for the mm tree. > > -- > Kees Cook