Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp274255pxf; Wed, 17 Mar 2021 22:59:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAAnPKR23M5QCfFOGhg+lh7VFaBLycNodGJhAqn3yHz9VFdEGL8zEYh8GxvKaMq+TmxdBK X-Received: by 2002:a17:906:b288:: with SMTP id q8mr39040225ejz.210.1616047147296; Wed, 17 Mar 2021 22:59:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616047147; cv=none; d=google.com; s=arc-20160816; b=qdtOB+YNRgmhvy+VUeTkwsNH7IVP93SaPNPT44atNH18xZdwgpnsMME+pnkJoN+95B zMgpLwP1zgu1IqZcfCDxLHsaJfscipa5QR16Y8CSryXbEcleMK36DeljeM060y+Ej3yk EtsrthK/CSqLLbJAkP+gHKouN4S3fh8QPm/Ibyvy2pYag5td/UV6hZwItEu7dr9ZIK1+ HmvLtG4nhQuF6nvIam+kBlvlidInXvkWcss1YcRmYa6RzGuN5weVa3UwMDOCh+sPex7m 4dwGMNi4yz2zwnbXBMY6mgaQGYfkdsSNdzKVDgReimJpk1LCOD8kbXwCMfRI4Z3DnjhK Q4yA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=thuNdy/atXOJvAUmIiVmx8uB0ZvJ8lEzYDmOkR+xX6c=; b=XUrddV84Il8DGPTX3vM9MCf7S07dLM7quPqHYLtKffWFobH4nOnjrzDNVImrqoqje5 Mq670TGDGf44xUCmb1IbXlDeF3kDj0yBMce8gL5Ywu121X/+3PAjuyUgqLT+AlI+9D9u dAegien9Oj5a5jkfOrsWy/6BepWTiZBi1kffndOamZHOgkVVXgmP3Apax9l++OVvdtqT 2thN7d/CPW2vrzyFGcbn6uodnE7bReJbt7DZr9tltf1uofg1iLsJ3nMr2q5ySymrsxlh EwQoXUoOBWIKOLwPYOyrVhbwP8ISzuS2P+MUiMZaEcNwgJ51JdjoOLnZCL2ik7w7bRpq IMew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MprH25Hs; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c17si761839edr.46.2021.03.17.22.58.44; Wed, 17 Mar 2021 22:59:07 -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=@chromium.org header.s=google header.b=MprH25Hs; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229559AbhCRFzm (ORCPT + 99 others); Thu, 18 Mar 2021 01:55:42 -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-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