linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [GIT PULL] vfs procfs
Date: Fri, 13 Sep 2024 16:44:47 +0200	[thread overview]
Message-ID: <20240913-vfs-procfs-f4fc141daed2@brauner> (raw)

/* Summary */
Hey Linus,

This contains the following changes for procfs:

* Add config options and parameters to block forcing memory writes.

  This adds a Kconfig option and boot param to allow removing the
  FOLL_FORCE flag from /proc/<pid>/mem write calls as this can be used
  in various attacks.

  The traditional forcing behavior is kept as default because it can
  break GDB and some other use cases.

  This is the simpler version that you had requested.

* Restrict overmounting of ephemeral entities.

  It is currently possible to mount on top of various ephemeral entities
  in procfs. This specifically includes magic links. To recap, magic
  links are links of the form /proc/<pid>/fd/<nr>. They serve as
  references to a target file and during path lookup they cause a jump
  to the target path. Such magic links disappear if the corresponding
  file descriptor is closed.

  Currently it is possible to overmount such magic links. This is mostly
  interesting for an attacker that wants to somehow trick a process into
  e.g., reopening something that it didn't intend to reopen or to hide
  a malicious file descriptor.

  But also it risks leaking mounts for long-running processes. When
  overmounting a magic link like above, the mount will not be detached
  when the file descriptor is closed. Only the target mountpoint will
  disappear. Which has the consequence of making it impossible to unmount
  that mount afterwards. So the mount will stick around until the process
  exits and the /proc/<pid>/ directory is cleaned up during
  proc_flush_pid() when the dentries are pruned and invalidated.

  That in turn means it's possible for a program to accidentally leak
  mounts and it's also possible to make a task leak mounts without it's
  knowledge if the attacker just keeps overmounting things under
  /proc/<pid>/fd/<nr>.

  Disallow overmounting of such ephemeral entities.

* Cleanup the readdir method naming in some procfs file operations.

* Replace kmalloc() and strcpy() with a simple kmemdup() call.

/* Testing */

gcc version 14.2.0 (Debian 14.2.0-3)
Debian clang version 16.0.6 (27+b1)

All patches are based on v6.11-rc1 and have been sitting in linux-next.
No build failures or warnings were observed.

/* Conflicts */

Merge conflicts with mainline
=============================

None.

Merge conflicts with other trees
================================

None.

The following changes since commit 8400291e289ee6b2bf9779ff1c83a291501f017b:

  Linux 6.11-rc1 (2024-07-28 14:19:55 -0700)

are available in the Git repository at:

  git@gitolite.kernel.org:pub/scm/linux/kernel/git/vfs/vfs tags/vfs-6.12.procfs

for you to fetch changes up to 4ad5f9a021bd7e3a48a8d11c52cef36d5e05ffcc:

  proc: fold kmalloc() + strcpy() into kmemdup() (2024-09-09 10:51:20 +0200)

Please consider pulling these changes from the signed vfs-6.12.procfs tag.

Thanks!
Christian

----------------------------------------------------------------
vfs-6.12.procfs

----------------------------------------------------------------
Adrian Ratiu (1):
      proc: add config & param to block forcing mem writes

Alexey Dobriyan (1):
      proc: fold kmalloc() + strcpy() into kmemdup()

Christian Brauner (7):
      proc: proc_readfd() -> proc_fd_iterate()
      proc: proc_readfdinfo() -> proc_fdinfo_iterate()
      proc: add proc_splice_unmountable()
      proc: block mounting on top of /proc/<pid>/map_files/*
      proc: block mounting on top of /proc/<pid>/fd/*
      proc: block mounting on top of /proc/<pid>/fdinfo/*
      Merge patch series "proc: restrict overmounting of ephemeral entities"

 Documentation/admin-guide/kernel-parameters.txt | 10 ++++
 fs/proc/base.c                                  | 65 +++++++++++++++++++++++--
 fs/proc/fd.c                                    | 16 +++---
 fs/proc/generic.c                               |  4 +-
 fs/proc/internal.h                              | 13 +++++
 security/Kconfig                                | 32 ++++++++++++
 6 files changed, 127 insertions(+), 13 deletions(-)

             reply	other threads:[~2024-09-13 14:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-13 14:44 Christian Brauner [this message]
2024-09-16  7:59 ` [GIT PULL] vfs procfs pr-tracker-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240913-vfs-procfs-f4fc141daed2@brauner \
    --to=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).