Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp603848pxb; Wed, 3 Feb 2021 12:54:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJdCVJBR2R5Z8yLA/khMJBkwAaKh5A6K7u5BUERHjb/RVFYYWQ0nxuSIzQmJlbZTpvbftC X-Received: by 2002:a17:906:84d7:: with SMTP id f23mr5291076ejy.87.1612385650369; Wed, 03 Feb 2021 12:54:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612385650; cv=none; d=google.com; s=arc-20160816; b=ntnma7uYCVF0e4VdB1aWN3aWGhINOX5UqkhPG0EYFHT7SktM1e4xxeuRnP7GvF5Ii0 IlmyPFJYWhLlJLSg6VVthDuXuYeJMLtSjlsHCBSkfa5hu7EssKOau+cvNQgUKBkPjbAw LRqcel6/SZA4MNwzfJjuD3WActW3DDXK3sqevYVa+5zrDZsMQzXZJRiLu+kF+wLa3xqp c8CGKJZRMgyqNMrxnXO/Wy+Cj0M3BiwDPR5Jz1Nk152+8YDeGPDgJrnncVagFV7DtxmV CW2dfq0OyI+UeA26yJw2eAgLxI7dR0Dai/FuRaTb8YNlOu2BgMoRzMcf/LLxZyO8cU02 xDpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:cc:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=M8lFoGv6mHlkS4pfcEZxXT0GjlBrKSHlOVSDDjgilMk=; b=m9m3X9zSrIwx6BgJyEQ6DAveEqz+woE4oC4rrw7O56VATAKSAu7Bdn9hgj6p4+fic9 qQd9AlurNzPUYi0CgFOzvWcCc6qylegsUIJOYK6stP2T9VFdjO59iB5tz0dePDDKf2Ed erAGmj3QbXwCcS7VqO7sti0xKPLCKSS+mEomcfr5ZdCi6reEYKzVIHY9HKH8msT13joO lG9tgUaRYxz4AkwLnZiwwc94HL81jcFQkpnHOf10oziEK6ISM2XSBo3bEWp+rO1GkpgL u1DbLt6XCf3sotcN3trnK6QJ7UOHpEAWC9/HgA9XE7yn4SwrPs4rs9ioR5+VmsKsI00y jt9A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=rM1xvLKC; 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 lt6si1960817ejb.133.2021.02.03.12.53.45; Wed, 03 Feb 2021 12:54:10 -0800 (PST) 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=rM1xvLKC; 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 S232597AbhBCUuq (ORCPT + 99 others); Wed, 3 Feb 2021 15:50:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232320AbhBCUuW (ORCPT ); Wed, 3 Feb 2021 15:50:22 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE073C0613ED for ; Wed, 3 Feb 2021 12:49:40 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id m6so621583pfk.1 for ; Wed, 03 Feb 2021 12:49:40 -0800 (PST) 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:cc :content-transfer-encoding; bh=M8lFoGv6mHlkS4pfcEZxXT0GjlBrKSHlOVSDDjgilMk=; b=rM1xvLKChJbMhPiPxDWEcePASMy0cf8HeErbywGhn2uz/vxUt3AWciE3Uj63Z9rkey 3clwXdhoaZ9tcupljd+xCp/yiRwzX/ekcHuZsIbhXa17Qm+44qBkGfi0JFpr2BfLDeUP uL4Jo+ge5eJYzKr58jmA5TrlIeovIVSgJdXR6bfIIoYV+m7rgmaz3WLeyQzZxEEjpNnU UNyxblr37Vse2cJev1TBfQXLjVuw5otZVV5JNNT8jZRq/IIGsHa9JjamNNJP/gdZTaZo +iWKjsNqQHVX2hrRwm0Ki4jIyyS7RT2xYbuq6koIXVc5C5NFulhXVP9qaCbJ3Xt/zb+N PvcA== 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:cc:content-transfer-encoding; bh=M8lFoGv6mHlkS4pfcEZxXT0GjlBrKSHlOVSDDjgilMk=; b=jhSBqEkapwp/7xjDfqWvap6XoZ4ugiauXZqOrmBJD20Vuhd2jcB+ZtjTIVPDUR3FNW LP0l//gjZz+3OVXOhQD/E6Ndmf10m2z0/8y4Hc5NjEA/RtFpgQD9qcGZL8nT2ETXp5sz u84fwQKlWVu//sz2FwYskN2XcU2RSY0Xi1e/qBv1TdG6FkKe3EM803JEC/hPJS3BEGGS WiC7ivi2I4PZ5u/0kNmGbKLOB+gXrBW/LVMvM3VOPrD+8QqHo82pvbKJRUlpRG0+Ta1f 64XGL0YTVcHMsRbXSR5yqlvApQnU7iGETQBXvHdY2oK5SDx+RFu+fypuuZV1NsyWcdCI 6Gpg== X-Gm-Message-State: AOAM533nJZnqb1wkc9p0LBEG+I1xrc2ej6HYqHVqJD/3i/FwqpElav9D VfdiLmA11XbjlbU4cdgPlH2mlDNZtQeYc7FJpD13uw== X-Received: by 2002:aa7:910a:0:b029:1c8:9947:305c with SMTP id 10-20020aa7910a0000b02901c89947305cmt3620827pfh.75.1612385380012; Wed, 03 Feb 2021 12:49:40 -0800 (PST) MIME-Version: 1.0 References: <20210128182432.2216573-1-kaleshsingh@google.com> In-Reply-To: <20210128182432.2216573-1-kaleshsingh@google.com> From: Kalesh Singh Date: Wed, 3 Feb 2021 15:49:27 -0500 Message-ID: Subject: Re: [PATCH 0/2] Allow reading process DMA buf stats from fdinfo Cc: Jann Horn , Jeffrey Vander Stoep , Kees Cook , Suren Baghdasaryan , Minchan Kim , Hridya Valsaraju , "Cc: Android Kernel" , Sumit Semwal , =?UTF-8?Q?Christian_K=C3=B6nig?= , Alexey Dobriyan , "Eric W. Biederman" , Andrew Morton , Alexey Gladkov , Daniel Jordan , Michel Lespinasse , Bernd Edlinger , Andrei Vagin , Yafang Shao , Christian Brauner , Linux Media Mailing List , DRI mailing list , "moderated list:DMA BUFFER SHARING FRAMEWORK" , LKML , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 1:24 PM 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=E2=80=99 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. > > This series proposes making the requirement to read fdinfo less strict > with PTRACE_MODE_READ. > Hi everyone, I will send v2 of this patch series. Please let me know if you have any other comments or feedback, that should be addressed in the new version. Thanks, Kalesh > Kalesh Singh (2): > procfs: Allow reading fdinfo with PTRACE_MODE_READ > dmabuf: Add dmabuf inode no to fdinfo > > drivers/dma-buf/dma-buf.c | 1 + > fs/proc/base.c | 4 ++-- > fs/proc/fd.c | 15 ++++++++++++++- > 3 files changed, 17 insertions(+), 3 deletions(-) > > -- > 2.30.0.365.g02bc693789-goog >