Skip to content

fs: Do not allow get_file() to resurrect 0 f_count

Kees Cook dri-devel intel-gfx linux-fsdevel linux-hardening linux-kbuild lkml oe-lkp 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 15 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5fs: Do not allow get_file() to resurrect 0 f_countinclude/linux/fs.h+2 -14 replies
2/5drm/vmwgfx: Do not directly manipulate file->f_countdrivers/gpu/drm/vmwgfx/ttm_object.c+1 -10 replies
3/5drm/i915: Do not directly manipulate file->f_countdrivers/gpu/drm/i915/gt/shmem_utils.c+3 -20 replies
4/5refcount: Introduce refcount_long_t and APIsMAINTAINERS Makefile include/linux/refcount-impl.h +3 more+385 -3420 replies
5/5fs: Convert struct file::f_count to refcount_long_tfs/file.c fs/file_table.c include/linux/fs.h+8 -811 replies

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

PatchAl Viro
1/5
2/5
3/5
4/5
5/5NAKed-by

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/5] fs: Do not allow get_file() to resurrect 0 f_count

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
Signature · 1 line
2.34.1