Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp501975pxb; Fri, 15 Oct 2021 09:49:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy41VaFP6rSrvm9yrtPxjLR8OTXddaUCPuwjlbemj5Muow3VMXuul8driG6B9ZHYzJSWEQf X-Received: by 2002:a17:906:51d3:: with SMTP id v19mr8131365ejk.148.1634316587832; Fri, 15 Oct 2021 09:49:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634316587; cv=none; d=google.com; s=arc-20160816; b=grRNnXG9lxwGV94uj7vPq8XK3DaO7QBoxtGnyYpreY/h0OQRKoPIwc5M7jfohkpcaf reEgNiXld/koUaqAdzjOsiLjBKHmNhSxITr73BbydJcaoq1sGohKnxpgGg18pUx4DQer /Gx3X27QwYosacrUpL1Yd+sHXhgWcTfU5X7Bj0YzWInIePk3M4wJu2KWDnHTjxVuB1YX 1LpVZaFGwOq+yEExeljiS6Q4RlYswHlDBOeZaSUNBOIjodDK2QYNyqQXDsIOe5hTrLEg cxEF/YSDAlVD5dUivQLICqXcfeXcBIglgIWk+zVCpe4vLZAuS+kOYgWkw6ZQA6vsahWW 5u2Q== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rzrlLlNYi4/dUsUwqXHxhC12O+Bq9WOOWt6WfmntNuA=; b=qjTOoG0+S+y4Nbr0+nzP3QmQ4Xl5b6fe3geGrCM4YelJCFbFSWLSUAE52wUFHY9EA8 BDuDdA9YDNGA/tAx216WFClhnLyPj0W2unOYBaAs5MUfagA+Y62bWvPwJoHeRM8WNHaN wbVHJmYQIRlDCXVOprSTbDDBQrTdren3mj9/3z+SXCsZ/WUo5rKTEiqLtjFwdGPbB2fK RzNoCm6V3+PMhi5pZD/aDXWOqb3Trmyex0li8EcxcQuyXpZE/9zhy48W5wzD9+olZTaC 6pQ/XSLYqklJt8ofI1DUD68RsEcAs3ZRXrG3gW0+gIS2tOpDGxbDYgrddYvn/b2yKxl7 6/0g== ARC-Authentication-Results: i=1; mx.google.com; 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 ke2si8529624ejc.784.2021.10.15.09.49.22; Fri, 15 Oct 2021 09:49:47 -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; 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 S236999AbhJOJQ6 (ORCPT + 99 others); Fri, 15 Oct 2021 05:16:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:35366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbhJOJQ5 (ORCPT ); Fri, 15 Oct 2021 05:16:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6EEC660EE2; Fri, 15 Oct 2021 09:14:50 +0000 (UTC) Date: Fri, 15 Oct 2021 11:14:47 +0200 From: Christian Brauner To: Kees Cook Cc: Rob Landley , "linux-kernel@vger.kernel.org" , Linux FS Devel Subject: Re: The one and only "permission denied" in find /sys Message-ID: <20211015091447.634toiguzrgyz22j@wittgenstein> References: <7042EFC5-DA90-4B9A-951A-036889FD89CA@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <7042EFC5-DA90-4B9A-951A-036889FD89CA@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 06:48:26PM -0700, Kees Cook wrote: > > > On October 13, 2021 1:12:16 PM PDT, Rob Landley wrote: > >There is exactly one directory in the whole of sysfs that a normal user can't > >read (at least on my stock devuan laptop): > > > > $ find /sys -name potato > > find: ‘/sys/fs/pstore’: Permission denied > > > >It's the "pstore" filesystem, it was explicitly broken by commit d7caa33687ce, > >and the commit seems to say this was to fix an issue that didn't exist yet but > >might someday. > > Right, so, the problem did certainly exist: there was a capability check for opening the files, which made it difficult for pstore collector tools to run with sane least privileges. Adjusting the root directory was the simplest way to keep the files secure by default, and allow a system owner the ability to delegate collector permissions to a user or group via just a chmod on the root directory. > > >Did whatever issue it was concerned about ever actually start happening? Why did > >you not change the permissions on the files _in_ the directory so they weren't > >world readable instead? Should /dev/shm stop being world ls-able as well? > > Making the per-file permissions configurable at runtime was more complex for little additional gain. > > /dev/shm has the benefit of having an existing permission model for each created file. > > I wouldn't be opposed to a mount option to specify the default file owner/group, but it makes user space plumbing more difficult (i.e. last I checked, stuff like systemd tends to just mount kernel filesystems without options). Hm, no, we do mount kernel filesystems with different options. :) So if pstore gains an option that could be changed pretty easily. Unless you meant something else by kernel filesystems. :) static const MountPoint mount_table[] = { { "proc", "/proc", "proc", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_FATAL|MNT_IN_CONTAINER|MNT_FOLLOW_SYMLINK }, { "sysfs", "/sys", "sysfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_FATAL|MNT_IN_CONTAINER }, { "devtmpfs", "/dev", "devtmpfs", "mode=755" TMPFS_LIMITS_DEV, MS_NOSUID|MS_STRICTATIME, NULL, MNT_FATAL|MNT_IN_CONTAINER }, { "securityfs", "/sys/kernel/security", "securityfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_NONE }, #if ENABLE_SMACK { "smackfs", "/sys/fs/smackfs", "smackfs", "smackfsdef=*", MS_NOSUID|MS_NOEXEC|MS_NODEV, mac_smack_use, MNT_FATAL }, { "tmpfs", "/dev/shm", "tmpfs", "mode=1777,smackfsroot=*", MS_NOSUID|MS_NODEV|MS_STRICTATIME, mac_smack_use, MNT_FATAL }, #endif { "tmpfs", "/dev/shm", "tmpfs", "mode=1777", MS_NOSUID|MS_NODEV|MS_STRICTATIME, NULL, MNT_FATAL|MNT_IN_CONTAINER }, { "devpts", "/dev/pts", "devpts", "mode=620,gid=" STRINGIFY(TTY_GID), MS_NOSUID|MS_NOEXEC, NULL, MNT_IN_CONTAINER }, #if ENABLE_SMACK { "tmpfs", "/run", "tmpfs", "mode=755,smackfsroot=*" TMPFS_LIMITS_RUN, MS_NOSUID|MS_NODEV|MS_STRICTATIME, mac_smack_use, MNT_FATAL }, #endif { "tmpfs", "/run", "tmpfs", "mode=755" TMPFS_LIMITS_RUN, MS_NOSUID|MS_NODEV|MS_STRICTATIME, NULL, MNT_FATAL|MNT_IN_CONTAINER }, { "cgroup2", "/sys/fs/cgroup", "cgroup2", "nsdelegate,memory_recursiveprot", MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE }, { "cgroup2", "/sys/fs/cgroup", "cgroup2", "nsdelegate", MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE }, { "cgroup2", "/sys/fs/cgroup", "cgroup2", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_unified_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE }, { "tmpfs", "/sys/fs/cgroup", "tmpfs", "mode=755" TMPFS_LIMITS_SYS_FS_CGROUP, MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_STRICTATIME, cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER }, { "cgroup2", "/sys/fs/cgroup/unified", "cgroup2", "nsdelegate", MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_hybrid_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE }, { "cgroup2", "/sys/fs/cgroup/unified", "cgroup2", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_hybrid_wanted, MNT_IN_CONTAINER|MNT_CHECK_WRITABLE }, { "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd,xattr", MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_legacy_wanted, MNT_IN_CONTAINER }, { "cgroup", "/sys/fs/cgroup/systemd", "cgroup", "none,name=systemd", MS_NOSUID|MS_NOEXEC|MS_NODEV, cg_is_legacy_wanted, MNT_FATAL|MNT_IN_CONTAINER }, { "pstore", "/sys/fs/pstore", "pstore", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_NONE }, #if ENABLE_EFI { "efivarfs", "/sys/firmware/efi/efivars", "efivarfs", NULL, MS_NOSUID|MS_NOEXEC|MS_NODEV, is_efi_boot, MNT_NONE }, #endif { "bpf", "/sys/fs/bpf", "bpf", "mode=700", MS_NOSUID|MS_NOEXEC|MS_NODEV, NULL, MNT_NONE, }, };