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=-6.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no 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 E3BFAC07E95 for ; Sat, 10 Jul 2021 18:21:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BB99F61360 for ; Sat, 10 Jul 2021 18:21:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229715AbhGJSYk (ORCPT ); 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-Google-Smtp-Source: ABdhPJyp03vt9Y+Rrv7vxXqz3ueQkI9ACBSfkEPH+e7KR1mLNxqUxTZEZdPzlpAkLTLtLJ5lggfV5A== 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