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=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 5A42BC433E6 for ; Thu, 18 Mar 2021 05:56:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B98764EB6 for ; Thu, 18 Mar 2021 05:56:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbhCRFzp (ORCPT ); Thu, 18 Mar 2021 01:55:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229703AbhCRFzZ (ORCPT ); Thu, 18 Mar 2021 01:55:25 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 31F13C061760 for ; Wed, 17 Mar 2021 22:55:25 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id n11so735152pgm.12 for ; Wed, 17 Mar 2021 22:55:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=thuNdy/atXOJvAUmIiVmx8uB0ZvJ8lEzYDmOkR+xX6c=; b=MprH25HsBRaGXUd3lCFp5j+Axa+FdUL+lgNyZG0FycK5F1yxkPxN1nQq0/zc6Q0XWy 7/YTwqm6bZJpwLi2rw76pSmRZojjDYWpLX/7cbSwX7vjvwy29E95ewkiEPBgunT0IJxW a3Kw5MJQeWoWflxa489bUZwYAR7aEvsiEaWbs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=thuNdy/atXOJvAUmIiVmx8uB0ZvJ8lEzYDmOkR+xX6c=; b=evPiueyjL7rJ6Oq7VUD6vPOipUAEHoSLen35EGrdqOGlR2t6J2PTx5gn2JWXpHg9J/ ++q/5EQGzJaH2Q62YlSjxX01UhVCeYxLzeVBvNNh45XpIovUvY4sg6P8uTvLl2G0kWz/ IE5EnFg7hp/fcKFbHHqynkpRP0VI1WoxOGl5bWruH2CB8Jl/r4vPOsABRz5MgwWQMonp DoUAfHd1lNb2QdnRmdygw6xjOSaYzPxKUvyrZ36mNiVD0hWHt02JiQcKiYlufOzt9o5O QYhcQQ4tapKhAAG+VluCpmoPwdnJbRhGhAqoRJ83ADu4BeT13fW+DdrW2sCwFlyIo3OV jvTg== X-Gm-Message-State: AOAM531d61M+U8ITqafWgsYYbXTNCHbz28njCQQoUBQ28QKSjWllpxVr NB8YSG3O+1Gkj/eTM0Fvm4U9qg== X-Google-Smtp-Source: ABdhPJzo0CH0324dBXSBMnA6LRAoHtG5Kf0XhoXnPszZLNeJrtGXWDwT27AAVxMw3VT6jqq4EtCtJw== X-Received: by 2002:aa7:9a89:0:b029:1f6:26b9:bb73 with SMTP id w9-20020aa79a890000b02901f626b9bb73mr2487427pfi.78.1616046924564; Wed, 17 Mar 2021 22:55:24 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id s22sm822368pgv.94.2021.03.17.22.55.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 22:55:23 -0700 (PDT) Date: Wed, 17 Mar 2021 22:55:22 -0700 From: Kees Cook To: Kalesh Singh Cc: jannh@google.com, jeffv@google.com, surenb@google.com, minchan@kernel.org, hridya@google.com, rdunlap@infradead.org, christian.koenig@amd.com, willy@infradead.org, viro@zeniv.linux.org.uk, kernel-team@android.com, 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 , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-doc@vger.kernel.org Subject: Re: [RESEND PATCH v6 1/2] procfs: Allow reading fdinfo with PTRACE_MODE_READ Message-ID: <202103172255.46B192DA@keescook> References: <20210308170651.919148-1-kaleshsingh@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210308170651.919148-1-kaleshsingh@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? -- Kees Cook