public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] fs: Do not allow get_file() to resurrect 0 f_count
@ 2024-05-02 22:33 Kees Cook
  2024-05-02 22:33 ` [PATCH 1/5] " Kees Cook
                   ` (4 more replies)
  0 siblings, 5 replies; 22+ messages in thread
From: Kees Cook @ 2024-05-02 22:33 UTC (permalink / raw)
  To: Christian Brauner, Will Deacon
  Cc: Kees Cook, Al Viro, Jan Kara, Zack Rusin,
	Broadcom internal kernel review list, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Daniel Vetter,
	Jani Nikula, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
	Andi Shyti, Lucas De Marchi, Matt Atwood, Matthew Auld,
	Nirmoy Das, Jonathan Cavitt, Peter Zijlstra, Boqun Feng,
	Mark Rutland, Kent Overstreet, Masahiro Yamada, Nathan Chancellor,
	Nicolas Schier, Andrew Morton, linux-kernel, linux-fsdevel,
	dri-devel, intel-gfx, linux-kbuild, linux-hardening

Hi,

Failure with f_count reference counting are better contained by
an actual reference counting type, like refcount_t. The first step
is for get_file() to use inc_not_zero to avoid resurrection. I also
found a couple open-coded modifications of f_count that should be using
get_file(). Since long ago, f_count was switched to atomic_long_t, so to
get proper reference count checking, I've added a refcount_long_t API,
and then converted f_count to refcount_long_t.

Now if there are underflows (or somehow an overflow), we'll see them
reported.

-Kees

Kees Cook (5):
  fs: Do not allow get_file() to resurrect 0 f_count
  drm/vmwgfx: Do not directly manipulate file->f_count
  drm/i915: Do not directly manipulate file->f_count
  refcount: Introduce refcount_long_t and APIs
  fs: Convert struct file::f_count to refcount_long_t

 MAINTAINERS                           |   2 +-
 Makefile                              |  11 +-
 drivers/gpu/drm/i915/gt/shmem_utils.c |   5 +-
 drivers/gpu/drm/vmwgfx/ttm_object.c   |   2 +-
 fs/file.c                             |   4 +-
 fs/file_table.c                       |   6 +-
 include/linux/fs.h                    |   7 +-
 include/linux/refcount-impl.h         | 344 ++++++++++++++++++++++++++
 include/linux/refcount.h              | 341 +------------------------
 include/linux/refcount_types.h        |  12 +
 lib/refcount.c                        |  17 +-
 11 files changed, 398 insertions(+), 353 deletions(-)
 create mode 100644 include/linux/refcount-impl.h

-- 
2.34.1


^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2024-05-06 10:42 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-02 22:33 [PATCH 0/5] fs: Do not allow get_file() to resurrect 0 f_count Kees Cook
2024-05-02 22:33 ` [PATCH 1/5] " Kees Cook
2024-05-02 22:53   ` Jann Horn
2024-05-02 23:03     ` Kees Cook
2024-05-03  9:02       ` Christian Brauner
2024-05-06 10:41         ` Hillf Danton
2024-05-02 22:33 ` [PATCH 2/5] drm/vmwgfx: Do not directly manipulate file->f_count Kees Cook
2024-05-02 22:33 ` [PATCH 3/5] drm/i915: " Kees Cook
2024-05-02 22:33 ` [PATCH 4/5] refcount: Introduce refcount_long_t and APIs Kees Cook
2024-05-06  8:04   ` kernel test robot
2024-05-02 22:33 ` [PATCH 5/5] fs: Convert struct file::f_count to refcount_long_t Kees Cook
2024-05-02 22:42   ` Al Viro
2024-05-02 22:52     ` Kees Cook
2024-05-02 23:12       ` Al Viro
2024-05-02 23:21         ` Kees Cook
2024-05-02 23:41           ` Al Viro
2024-05-03  0:10             ` Kees Cook
2024-05-03  0:14               ` Al Viro
2024-05-03  0:41                 ` Kees Cook
2024-05-03  9:37                   ` Christian Brauner
2024-05-03 10:36                     ` Peter Zijlstra
2024-05-03 11:35                       ` Christian Brauner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox