Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp1674047pxv; Sat, 10 Jul 2021 11:23:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFKlSP/cVk2m/SluHJ3DgQK5Ti3cRNDJWejngLlcX7EtfZjP6yY+Ikgk2enGU+h1WGXNX1 X-Received: by 2002:a05:6638:3a4:: with SMTP id z4mr266590jap.65.1625941390924; Sat, 10 Jul 2021 11:23:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625941390; cv=none; d=google.com; s=arc-20160816; b=a9t0hw5MmMH4ucaevZ3DpRtyWVBHNiJHx3cu/Zd8Xrhv5g+ujAJKlSCrtTMDi53Eo3 uLqOKRGhcj5d5jszoEvlfddcCF/prVzoz2+6j7h+gqf50hZzPGifjAbyWC3hsFFw+fn9 ZUltyNpkf6VuCN7+ZwfVwVDnwt4uBcengzhbGHUEmBtfn9kN16Roc0vhy4JLl7zJmiPr 3UNEWz3wQR4xMdiS1F2aqlzEFri8j+9JapafVUj5LQL2Z7xM7MsBTe2oY8KpafUMiCgQ MBqvN+bfqEOpvyy0Q3sCJu3Gxm4B26a9CEUeqoVP1spMDOiLzSGbIuZ3/AG65LMYi4mr +o+Q== 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=GFrC9GbYw2pfY1GNYl1j9fooO83KwnRoXAsiXo6YHdM=; b=gW3fdxrrKItIahE52DWrc32OmxdR/eGsEq6BOUCZdZzWPC4S2I/LKccNiUCk4rOxZy VNntg4v+LAnnCI7IeslC4ZyCdRLlfLtxaFhqXxKkA0nr4OYMH2FAnoHxiZgEu746VZpc B4EkAVUK/3vRmhgOx6igV+5FL+YgiHp5Db3lwO8jZ73MKTEbOk9QjzmRg8S1Rp757OB5 lHDcP6rJxV7fU3A4+bAeBCTNPjQ/Aj2oQeWRLwMsgLeGrh5wa8FWWCbpD+Ugz0aEjUaa 8OlKtZssBEApYil0zonwSompkGtKTZGQ/wAc6/XFg/LyJxf418koDthlrGUuTq1rto56 JdGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=CET5A4Gg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si10215172iot.72.2021.07.10.11.22.57; Sat, 10 Jul 2021 11:23:10 -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=@linux-foundation.org header.s=google header.b=CET5A4Gg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229700AbhGJSYk (ORCPT + 99 others); Sat, 10 Jul 2021 14:24:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229614AbhGJSYj (ORCPT ); Sat, 10 Jul 2021 14:24:39 -0400 Received: from mail-lf1-x132.google.com (mail-lf1-x132.google.com [IPv6:2a00:1450:4864:20::132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43CC1C0613DD for ; Sat, 10 Jul 2021 11:21:53 -0700 (PDT) Received: by mail-lf1-x132.google.com with SMTP id f30so31105826lfj.1 for ; Sat, 10 Jul 2021 11:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GFrC9GbYw2pfY1GNYl1j9fooO83KwnRoXAsiXo6YHdM=; b=CET5A4Gg6UTWVQrmn0T1UFde0+VITgRXMOtF+pC+mv+1LrV+kNA9wWC2viZ4co6z2Z GupTQr1pqFZgkylinpa4Eok8C1K+DAV+94Fj6fnpvqnGTSTbh7ZezFnFOIF3AiM7BxV0 3fi9D3iRZsJsnmsgjMjAz2eGZj55J4f0Av5j4= 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=GFrC9GbYw2pfY1GNYl1j9fooO83KwnRoXAsiXo6YHdM=; b=UvWt8LtomdY7bR5TNGGGZl0/GviMpkkbfDh6aMnKySZbmTugsVJmSO0Un60+0aGnbO lAQskBe0qPIrNYxWovT4ZXfvG72oAV0oVTvesfvb69Y0aD2nNwvYAdZuk8QiJvQMBlKu hhsstuiz99LH5+06DsEIFaumSdYIZt8ZBvdbWWt8w8PLGYcbqAZXMi+4K480lhxzruX7 JAIA6U9JcSshWp0ZE+UcQc7/yGPNr2sDB1/6bKikG4ztW6a/8/dZZJASqRHvZjn39mm/ fZBx3WVBz/ZzZ27Kzy8ylG0CSp+K9LyLBqn8J/5dQe6DYJixEjCUBMleWgTd3VfzZzF+ XobA== X-Gm-Message-State: AOAM5335FuNU32G8fPcmhJdIq5WbcqV7uLxCDnhKg+weTX5WsO6Z73wa cVZHPhvGkfKqfC4j4rhAtoNW18fW3sol36iS X-Received: by 2002:ac2:5590:: with SMTP id v16mr8191192lfg.453.1625941311260; Sat, 10 Jul 2021 11:21:51 -0700 (PDT) Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com. [209.85.167.44]) by smtp.gmail.com with ESMTPSA id i130sm756136lfd.304.2021.07.10.11.21.50 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 10 Jul 2021 11:21:50 -0700 (PDT) Received: by mail-lf1-f44.google.com with SMTP id y42so31075736lfa.3 for ; Sat, 10 Jul 2021 11:21:50 -0700 (PDT) X-Received: by 2002:ac2:4475:: with SMTP id y21mr5344683lfl.487.1625941310223; Sat, 10 Jul 2021 11:21:50 -0700 (PDT) MIME-Version: 1.0 References: <20210708155647.44208-1-kaleshsingh@google.com> In-Reply-To: <20210708155647.44208-1-kaleshsingh@google.com> From: Linus Torvalds Date: Sat, 10 Jul 2021 11:21:34 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] procfs: Prevent unpriveleged processes accessing fdinfo To: Kalesh Singh Cc: Kees Cook , "Eric W. Biederman" , Christian Brauner , Christian Koenig , Suren Baghdasaryan , Hridya Valsaraju , Android Kernel Team , Andrew Morton , Linux Kernel Mailing List , linux-fsdevel Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jul 8, 2021 at 8:57 AM Kalesh Singh wrote: > > The file permissions on the fdinfo dir from were changed from > S_IRUSR|S_IXUSR to S_IRUGO|S_IXUGO, and a PTRACE_MODE_READ check was > added for opening the fdinfo files [1]. However, the ptrace permission > check was not added to the directory, allowing anyone to get the open FD > numbers by reading the fdinfo directory. > > Add the missing ptrace permission check for opening the fdinfo directory. The more I look at this, the more I feel like we should look at instead changing how "get_proc_task()" works. That's one of the core functions for /proc, and I wonder if we couldn't just make it refuse to look up a task that has gone through a suid execve() since the proc inode was opened. I don't think it's basically ever ok to open something for one thread, and then use it after the thread has gone through a suid thing. In fact, I wonder if we could make it even stricter, and go "any exec at all", but I think a suid exec might be the minimum we should do. Then the logic really becomes very simple: we did the permission checks at open time (like UNIX permission checks should be done), and "get_proc_task()" basically verifies that "yeah, that open-time decision is still valid". Wouldn't that make a lot of sense? Linus