Skip to contentSkip to conversation

rework of open-related logics

GIT PULL Al Viro 1 participant 1 message Aug 12, 2018 VFS

lore
Share & tools
lore

Al Viro

author maintainer
#0 lore raw

* "do we need fput() or put_filp()" rules are gone - it's always fput() now. We keep track of that state where it belongs - in ->f_mode.
* int *opened mess killed - in finish_open(), in ->atomic_open() instances and in fs/namei.c code around do_last()/lookup_open()/atomic_open().
* alloc_file() wrappers with saner calling conventions are introduced (alloc_file_clone() and alloc_file_pseudo()); callers converted, with much simplification.
* while we are at it, saner calling conventions for path_init() and link_path_walk(), simplifying things inside fs/namei.c (both on open-related paths and elsewhere).

The following changes since commit c7e9075fb89362812059fbf8e25bb4a6e825c4c5:

ocxlflash_getfile(): fix double-iput() on alloc_file() failures (2018-07-10 23:29:03 -0400)

are available in the git repository at:

git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs.git work.open3

for you to fetch changes up to 5f336e722cc961be94d264d96b90c92888fffae1:

few more cleanups of link_path_walk() callers (2018-07-12 10:04:31 -0400)

----------------------------------------------------------------
Al Viro (40):
fold security_file_free() into file_free()
turn filp_clone_open() into inline wrapper for dentry_open() create_pipe_files(): use fput() if allocation of the second file fails make sure do_dentry_open() won't return positive as an error alloc_file(): switch to passing O_... flags instead of FMODE_... mode pass creds to get_empty_filp(), make sure dentry_open() passes the right creds pass ->f_flags value to alloc_empty_file()
get rid of cred argument of vfs_open() and do_dentry_open() security_file_open(): lose cred argument
->file_open(): lose cred argument
introduce FMODE_OPENED
fold put_filp() into fput()
lift fput() on late failures into path_openat()
now we can fold open_check_o_direct() into do_dentry_open() switch all remaining checks for FILE_OPENED to FMODE_OPENED introduce FMODE_CREATED and switch to it
IMA: don't propagate opened through the entire thing
getting rid of 'opened' argument of ->atomic_open() - part 1 getting rid of 'opened' argument of ->atomic_open() - part 2
get rid of 'opened' argument of ->atomic_open() - part 3
get rid of 'opened' in path_openat() and the helpers downstream ->atomic_open(): return 0 in all success cases
document ->atomic_open() changes
switch atomic_open() and lookup_open() to returning 0 in all success cases kill FILE_{CREATED,OPENED}
new wrapper: alloc_file_pseudo()
__shmem_file_setup(): reorder allocations
... and switch shmem_file_setup() to alloc_file_pseudo() cxl_getfile(): switch to alloc_file_pseudo() ocxlflash_getfile(): switch to alloc_file_pseudo() hugetlb_file_setup(): switch to alloc_file_pseudo() anon_inode_getfile(): switch to alloc_file_pseudo() create_pipe_files(): switch the first allocation to alloc_file_pseudo() new helper: alloc_file_clone()
do_shmat(): grab shp->shm_file earlier, switch to alloc_file_clone() make alloc_file() static
document alloc_file() changes
make path_init() unconditionally paired with terminate_walk() allow link_path_walk() to take ERR_PTR()
few more cleanups of link_path_walk() callers

 Documentation/filesystems/Locking     |   2 +-
 Documentation/filesystems/porting     |  20 +++
 Documentation/filesystems/vfs.txt     |  18 +--
 drivers/gpu/drm/drm_lease.c           |   2 +-
 drivers/misc/cxl/api.c                |  22 +---
 drivers/scsi/cxlflash/ocxl_hw.c       |  24 +---
 fs/9p/vfs_inode.c                     |   7 +-
 fs/9p/vfs_inode_dotl.c                |   7 +-
 fs/aio.c                              |  24 +---
 fs/anon_inodes.c                      |  30 +----
 fs/bad_inode.c                        |   2 +-
 fs/binfmt_misc.c                      |   2 +-
 fs/ceph/file.c                        |   7 +-
 fs/ceph/super.h                       |   3 +-
 fs/cifs/cifsfs.h                      |   3 +-
 fs/cifs/dir.c                         |   7 +-
 fs/file_table.c                       |  85 +++++++++----
 fs/fuse/dir.c                         |  10 +-
 fs/gfs2/inode.c                       |  32 +++--
 fs/hugetlbfs/inode.c                  |  54 +++-----
 fs/internal.h                         |   5 +-
 fs/namei.c                            | 225 +++++++++++++---------------------
 fs/nfs/dir.c                          |  14 ++-
 fs/nfs/nfs4_fs.h                      |   2 +-
 fs/nfs/nfs4proc.c                     |   2 +-
 fs/nfsd/vfs.c                         |   2 +-
 fs/open.c                             |  88 ++++---------
 fs/pipe.c                             |  43 ++-----
 include/linux/file.h                  |   8 +-
 include/linux/fs.h                    |  17 +--
 include/linux/ima.h                   |   4 +-
 include/linux/lsm_hooks.h             |   2 +-
 include/linux/security.h              |   5 +-
 ipc/shm.c                             |  45 ++++---
 mm/memfd.c                            |   2 +-
 mm/shmem.c                            |  49 ++------
 net/socket.c                          |  29 +----
 security/apparmor/lsm.c               |   4 +-
 security/integrity/ima/ima.h          |   4 +-
 security/integrity/ima/ima_appraise.c |   4 +-
 security/integrity/ima/ima_main.c     |  16 +--
 security/security.c                   |   4 +-
 security/selinux/hooks.c              |   4 +-
 security/smack/smack_lsm.c            |   6 +-
 security/tomoyo/tomoyo.c              |   2 +-
 45 files changed, 371 insertions(+), 576 deletions(-)