26 Nov, 2020

1 commit

  • The following patches are now queued in f2fs/dev for 5.11, but
    android-mainline and android12-5.4 have an old version of them:

    libfs: Add generic function for setting dentry_ops
    fscrypt: Have filesystems handle their d_ops
    f2fs: Handle casefolding with Encryption

    Get them up-to-date.

    Link: https://lore.kernel.org/linux-f2fs-devel/20201119060904.463807-1-drosen@google.com
    Bug: 161184936
    Test: kvm-xfstests -c f2fs/default,f2fs/encrypt -g casefold
    Change-Id: I359bf4f23631c1b8175de8d5f12d0787fd7f42bd
    Signed-off-by: Eric Biggers

    Eric Biggers
     

23 Nov, 2020

2 commits

  • Linux 5.10-rc5

    Signed-off-by: Greg Kroah-Hartman
    Change-Id: Ia5b23cceb3e0212c1c841f1297ecfab65cc9aaa6

    Greg Kroah-Hartman
     
  • The attr->set() receive a value of u64, but simple_strtoll() is used for
    doing the conversion. It will lead to the error cast if user inputs a
    negative value.

    Use kstrtoull() instead of simple_strtoll() to convert a string got from
    the user to an unsigned value. The former will return '-EINVAL' if it
    gets a negetive value, but the latter can't handle the situation
    correctly. Make 'val' unsigned long long as what kstrtoull() takes,
    this will eliminate the compile warning on no 64-bit architectures.

    Fixes: f7b88631a897 ("fs/libfs.c: fix simple_attr_write() on 32bit machines")
    Signed-off-by: Yicong Yang
    Signed-off-by: Andrew Morton
    Cc: Al Viro
    Link: https://lkml.kernel.org/r/1605341356-11872-1-git-send-email-yangyicong@hisilicon.com
    Signed-off-by: Linus Torvalds

    Yicong Yang
     

23 Oct, 2020

1 commit


28 Sep, 2020

1 commit

  • Get the generic casefolding code in sync with the patches that are
    queued in f2fs.git#dev for 5.10.

    Equivalently, this reverts the patch
    "ANDROID-fs-adjust-casefolding-support-to-match-android-mainline.patch"
    from the android-mainline quilt series, with the following conflicts:

    Conflicts:
    fs/ext4/hash.c # due to "ANDROID: ext4: Handle casefolding with encryption"
    fs/ext4/namei.c # due to "ANDROID: ext4: Handle casefolding with encryption"
    fs/f2fs/dir.c # due to "ANDROID: f2fs: Handle casefolding with Encryption"

    Bug: 161184936
    Cc: Daniel Rosenberg
    Cc: Paul Lawrence
    Cc: Jaegeuk Kim
    Change-Id: I0ae169f0f5f413fb21e4be7a163213aef3fa6756
    Signed-off-by: Eric Biggers

    Eric Biggers
     

11 Sep, 2020

1 commit

  • This adds general supporting functions for filesystems that use
    utf8 casefolding. It provides standard dentry_operations and adds the
    necessary structures in struct super_block to allow this standardization.

    The new dentry operations are functionally equivalent to the existing
    operations in ext4 and f2fs, apart from the use of utf8_casefold_hash to
    avoid an allocation.

    By providing a common implementation, all users can benefit from any
    optimizations without needing to port over improvements.

    Signed-off-by: Daniel Rosenberg
    Reviewed-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Daniel Rosenberg
     

01 Sep, 2020

1 commit


24 Aug, 2020

1 commit

  • Replace the existing /* fall through */ comments and its variants with
    the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
    fall-through markings when it is the case.

    [1] https://www.kernel.org/doc/html/v5.7/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

25 Jun, 2020

1 commit

  • The encrypt+casefold support needed to be adjusted following refactoring
    of f2fs filename handing upstream. Also, the upstream change to
    f2fs_d_compare() needed to be moved to generic_ci_d_compare(). See
    http://aosp/1341990 and also the other branches like android-5.4-stable.

    Also, a call f2fs_set_bio_crypt_ctx() went missing.

    Fixes: 8912845e4e95 ("Merge 42612e776331 ("Merge tag 'f2fs-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs") into android-mainline")
    Change-Id: Icd92029bab74e161497a1f03201826a737955725
    Signed-off-by: Eric Biggers

    Eric Biggers
     

18 Jun, 2020

1 commit


22 May, 2020

1 commit


31 Mar, 2020

1 commit


24 Mar, 2020

1 commit

  • Reading from a debugfs file at a nonzero position, without first reading
    at position 0, leaks uninitialized memory to userspace.

    It's a bit tricky to do this, since lseek() and pread() aren't allowed
    on these files, and write() doesn't update the position on them. But
    writing to them with splice() *does* update the position:

    #define _GNU_SOURCE 1
    #include
    #include
    #include
    int main()
    {
    int pipes[2], fd, n, i;
    char buf[32];

    pipe(pipes);
    write(pipes[1], "0", 1);
    fd = open("/sys/kernel/debug/fault_around_bytes", O_RDWR);
    splice(pipes[0], NULL, fd, NULL, 1, 0);
    n = read(fd, buf, sizeof(buf));
    for (i = 0; i < n; i++)
    printf("%02x", buf[i]);
    printf("\n");
    }

    Output:
    5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a5a30

    Fix the infoleak by making simple_attr_read() always fill
    simple_attr::get_buf if it hasn't been filled yet.

    Reported-by: syzbot+fcab69d1ada3e8d6f06b@syzkaller.appspotmail.com
    Reported-by: Alexander Potapenko
    Fixes: acaefc25d21f ("[PATCH] libfs: add simple attribute files")
    Cc: stable@vger.kernel.org
    Signed-off-by: Eric Biggers
    Acked-by: Kees Cook
    Link: https://lore.kernel.org/r/20200308023849.988264-1-ebiggers@kernel.org
    Signed-off-by: Greg Kroah-Hartman

    Eric Biggers
     

21 Feb, 2020

2 commits

  • This shifts the responsibility of setting up dentry operations from
    fscrypt to the individual filesystems, allowing them to have their own
    operations while still setting fscrypt's d_revalidate as appropriate.

    Also added helper function to libfs to unify ext4 and f2fs
    implementations.

    Signed-off-by: Daniel Rosenberg
    Test: Boots, /data/media is case insensitive
    Bug: 138322712
    Link: https://lore.kernel.org/linux-f2fs-devel/20200208013552.241832-1-drosen@google.com/T/#t
    Change-Id: Iaf77f8c5961ecf22e22478701ab0b7fe2025225d

    Daniel Rosenberg
     
  • This adds general supporting functions for filesystems that use
    utf8 casefolding. It provides standard dentry_operations and adds the
    necessary structures in struct super_block to allow this standardization.

    Ext4 and F2fs are switch to these implementations.

    Signed-off-by: Daniel Rosenberg
    Note: Fixed issue with non-strictly enforced fallback hash
    Test: Boots, /data/media is case insensitive
    Bug: 138322712
    Link: https://lore.kernel.org/linux-f2fs-devel/20200208013552.241832-1-drosen@google.com/T/#t
    Change-Id: I81b5fb5d3ce0259a60712ae2505c1e4b03dbafde

    Daniel Rosenberg
     

11 Dec, 2019

1 commit


15 Oct, 2019

1 commit

  • Fix kernel-doc warning in fs/libfs.c:

    fs/libfs.c:496: warning: Excess function parameter 'available' description in 'simple_write_end'

    Link: http://lkml.kernel.org/r/5fc9d70b-e377-0ec9-066a-970d49579041@infradead.org
    Fixes: ad2a722f196d ("libfs: Open code simple_commit_write into only user")
    Signed-off-by: Randy Dunlap
    Cc: Boaz Harrosh
    Cc: Alexander Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     

10 Oct, 2019

1 commit


23 Sep, 2019

1 commit

  • There are two problems in dcache_readdir() - one is that lockless traversal
    of the list needs non-trivial cooperation of d_alloc() (at least a switch
    to list_add_rcu(), and probably more than just that) and another is that
    it assumes that no removal will happen without the directory locked exclusive.
    Said assumption had always been there, never had been stated explicitly and
    is violated by several places in the kernel (devpts and selinuxfs).

    * replacement of next_positive() with different calling conventions:
    it returns struct list_head * instead of struct dentry *; the latter is
    passed in and out by reference, grabbing the result and dropping the original
    value.
    * scan is under ->d_lock. If we run out of timeslice, cursor is moved
    after the last position we'd reached and we reschedule; then the scan continues
    from that place. To avoid livelocks between multiple lseek() (with cursors
    getting moved past each other, never reaching the real entries) we always
    skip the cursors, need_resched() or not.
    * returned list_head * is either ->d_child of dentry we'd found or
    ->d_subdirs of parent (if we got to the end of the list).
    * dcache_readdir() and dcache_dir_lseek() switched to new helper.
    dcache_readdir() always holds a reference to dentry passed to dir_emit() now.
    Cursor is moved to just before the entry where dir_emit() has failed or into
    the very end of the list, if we'd run out.
    * move_cursor() eliminated - it had sucky calling conventions and
    after fixing that it became simply list_move() (in lseek and scan_positives)
    or list_move_tail() (in readdir).

    All operations with the list are under ->d_lock now, and we do not
    depend upon having all file removals done with parent locked exclusive
    anymore.

    Cc: stable@vger.kernel.org
    Reported-by: "zhengbin (A)"
    Signed-off-by: Al Viro

    Al Viro
     

20 Jul, 2019

1 commit

  • Pull vfs mount updates from Al Viro:
    "The first part of mount updates.

    Convert filesystems to use the new mount API"

    * 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
    mnt_init(): call shmem_init() unconditionally
    constify ksys_mount() string arguments
    don't bother with registering rootfs
    init_rootfs(): don't bother with init_ramfs_fs()
    vfs: Convert smackfs to use the new mount API
    vfs: Convert selinuxfs to use the new mount API
    vfs: Convert securityfs to use the new mount API
    vfs: Convert apparmorfs to use the new mount API
    vfs: Convert openpromfs to use the new mount API
    vfs: Convert xenfs to use the new mount API
    vfs: Convert gadgetfs to use the new mount API
    vfs: Convert oprofilefs to use the new mount API
    vfs: Convert ibmasmfs to use the new mount API
    vfs: Convert qib_fs/ipathfs to use the new mount API
    vfs: Convert efivarfs to use the new mount API
    vfs: Convert configfs to use the new mount API
    vfs: Convert binfmt_misc to use the new mount API
    convenience helper: get_tree_single()
    convenience helper get_tree_nodev()
    vfs: Kill sget_userns()
    ...

    Linus Torvalds
     

05 Jul, 2019

1 commit


26 May, 2019

4 commits


21 May, 2019

1 commit

  • Add SPDX license identifiers to all files which:

    - Have no license information of any form

    - Have EXPORT_.*_SYMBOL_GPL inside which was used in the
    initial scan/conversion to ignore the file

    These files fall under the project license, GPL v2 only. The resulting SPDX
    license identifier is:

    GPL-2.0-only

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

08 May, 2019

1 commit

  • Pull misc vfs updates from Al Viro:
    "Assorted stuff, with no common topic whatsoever..."

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    libfs: document simple_get_link()
    Documentation/filesystems/Locking: fix ->get_link() prototype
    Documentation/filesystems/vfs.txt: document how ->i_link works
    Documentation/filesystems/vfs.txt: remove bogus "Last updated" date
    fs: use timespec64 in relatime_need_update
    fs/block_dev.c: remove unused include

    Linus Torvalds
     

01 May, 2019

1 commit


09 Apr, 2019

1 commit

  • In preparation to enabling -Wimplicit-fallthrough, mark switch cases
    where we are expecting to fall through.

    This patch fixes the following warnings:

    fs/affs/affs.h:124:38: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/configfs/dir.c:1692:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/configfs/dir.c:1694:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ceph/file.c:249:3: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/hash.c:233:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/hash.c:246:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext2/inode.c:1237:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext2/inode.c:1244:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/indirect.c:1182:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/indirect.c:1188:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/indirect.c:1432:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ext4/indirect.c:1440:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/f2fs/node.c:618:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/f2fs/node.c:620:8: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/btrfs/ref-verify.c:522:15: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/gfs2/bmap.c:711:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/gfs2/bmap.c:722:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/jffs2/fs.c:339:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/nfsd/nfs4proc.c:429:12: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ufs/util.h:62:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/ufs/util.h:43:6: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/fcntl.c:770:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/seq_file.c:319:10: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/libfs.c:148:11: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/libfs.c:150:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/signalfd.c:178:7: warning: this statement may fall through [-Wimplicit-fallthrough=]
    fs/locks.c:1473:16: warning: this statement may fall through [-Wimplicit-fallthrough=]

    Warning level 3 was used: -Wimplicit-fallthrough=3

    This patch is part of the ongoing efforts to enabling
    -Wimplicit-fallthrough.

    Reviewed-by: Kees Cook
    Signed-off-by: Gustavo A. R. Silva

    Gustavo A. R. Silva
     

31 Mar, 2018

1 commit

  • In preparation for the dax implementation to start associating dax pages
    to inodes via page->mapping, we need to provide a 'struct
    address_space_operations' instance for dax. Define some generic VFS aops
    helpers for dax. These noop implementations are there in the dax case to
    prevent the VFS from falling back to operations with page-cache
    assumptions, dax_writeback_mapping_range() may not be referenced in the
    FS_DAX=n case.

    Cc: Jeff Moyer
    Cc: Ross Zwisler
    Suggested-by: Matthew Wilcox
    Suggested-by: Jan Kara
    Suggested-by: Christoph Hellwig
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jan Kara
    Suggested-by: Dave Chinner
    Signed-off-by: Dan Williams

    Dan Williams
     

28 Nov, 2017

1 commit

  • This is a pure automated search-and-replace of the internal kernel
    superblock flags.

    The s_flags are now called SB_*, with the names and the values for the
    moment mirroring the MS_* flags that they're equivalent to.

    Note how the MS_xyz flags are the ones passed to the mount system call,
    while the SB_xyz flags are what we then use in sb->s_flags.

    The script to do this was:

    # places to look in; re security/*: it generally should *not* be
    # touched (that stuff parses mount(2) arguments directly), but
    # there are two places where we really deal with superblock flags.
    FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
    include/linux/fs.h include/uapi/linux/bfs_fs.h \
    security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
    # the list of MS_... constants
    SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
    DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
    POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
    I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
    ACTIVE NOUSER"

    SED_PROG=
    for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done

    # we want files that contain at least one of MS_...,
    # with fs/namespace.c and fs/pnode.c excluded.
    L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')

    for f in $L; do sed -i $f $SED_PROG; done

    Requested-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

06 Jul, 2017

2 commits

  • Many simple, block-based filesystems use generic_file_fsync as their
    fsync operation. Some others (ext* and fat) also call this function
    to handle syncing out data.

    Switch this code over to use errseq_t based error reporting so that
    all of these filesystems get reliable error reporting via fsync,
    fdatasync and msync.

    Signed-off-by: Jeff Layton

    Jeff Layton
     
  • ext2 currently does a test+clear of the AS_EIO flag, which is
    is problematic for some coming changes.

    What we really need to do instead is call filemap_check_errors
    in __generic_file_fsync after syncing out the buffers. That
    will be sufficient for this case, and help other callers detect
    these errors properly as well.

    With that, we don't need to twiddle it in ext2.

    Suggested-by: Jan Kara
    Signed-off-by: Jeff Layton
    Reviewed-by: Christoph Hellwig
    Reviewed-by: Jan Kara
    Reviewed-by: Matthew Wilcox

    Jeff Layton
     

27 Apr, 2017

1 commit

  • simple_fill_super() is passed an array of tree_descr structures which
    describe the files to create in the filesystem's root directory. Since
    these arrays are never modified intentionally, they should be 'const' so
    that they are placed in .rodata and benefit from memory protection.
    This patch updates the function signature and all users, and also
    constifies tree_descr.name.

    Signed-off-by: Eric Biggers
    Signed-off-by: Al Viro

    Eric Biggers
     

04 Mar, 2017

1 commit

  • Pull vfs 'statx()' update from Al Viro.

    This adds the new extended stat() interface that internally subsumes our
    previous stat interfaces, and allows user mode to specify in more detail
    what kind of information it wants.

    It also allows for some explicit synchronization information to be
    passed to the filesystem, which can be relevant for network filesystems:
    is the cached value ok, or do you need open/close consistency, or what?

    From David Howells.

    Andreas Dilger points out that the first version of the extended statx
    interface was posted June 29, 2010:

    https://www.spinics.net/lists/linux-fsdevel/msg33831.html

    * 'rebased-statx' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    statx: Add a system call to make enhanced file info available

    Linus Torvalds
     

03 Mar, 2017

1 commit

  • Add a system call to make extended file information available, including
    file creation and some attribute flags where available through the
    underlying filesystem.

    The getattr inode operation is altered to take two additional arguments: a
    u32 request_mask and an unsigned int flags that indicate the
    synchronisation mode. This change is propagated to the vfs_getattr*()
    function.

    Functions like vfs_stat() are now inline wrappers around new functions
    vfs_statx() and vfs_statx_fd() to reduce stack usage.

    ========
    OVERVIEW
    ========

    The idea was initially proposed as a set of xattrs that could be retrieved
    with getxattr(), but the general preference proved to be for a new syscall
    with an extended stat structure.

    A number of requests were gathered for features to be included. The
    following have been included:

    (1) Make the fields a consistent size on all arches and make them large.

    (2) Spare space, request flags and information flags are provided for
    future expansion.

    (3) Better support for the y2038 problem [Arnd Bergmann] (tv_sec is an
    __s64).

    (4) Creation time: The SMB protocol carries the creation time, which could
    be exported by Samba, which will in turn help CIFS make use of
    FS-Cache as that can be used for coherency data (stx_btime).

    This is also specified in NFSv4 as a recommended attribute and could
    be exported by NFSD [Steve French].

    (5) Lightweight stat: Ask for just those details of interest, and allow a
    netfs (such as NFS) to approximate anything not of interest, possibly
    without going to the server [Trond Myklebust, Ulrich Drepper, Andreas
    Dilger] (AT_STATX_DONT_SYNC).

    (6) Heavyweight stat: Force a netfs to go to the server, even if it thinks
    its cached attributes are up to date [Trond Myklebust]
    (AT_STATX_FORCE_SYNC).

    And the following have been left out for future extension:

    (7) Data version number: Could be used by userspace NFS servers [Aneesh
    Kumar].

    Can also be used to modify fill_post_wcc() in NFSD which retrieves
    i_version directly, but has just called vfs_getattr(). It could get
    it from the kstat struct if it used vfs_xgetattr() instead.

    (There's disagreement on the exact semantics of a single field, since
    not all filesystems do this the same way).

    (8) BSD stat compatibility: Including more fields from the BSD stat such
    as creation time (st_btime) and inode generation number (st_gen)
    [Jeremy Allison, Bernd Schubert].

    (9) Inode generation number: Useful for FUSE and userspace NFS servers
    [Bernd Schubert].

    (This was asked for but later deemed unnecessary with the
    open-by-handle capability available and caused disagreement as to
    whether it's a security hole or not).

    (10) Extra coherency data may be useful in making backups [Andreas Dilger].

    (No particular data were offered, but things like last backup
    timestamp, the data version number and the DOS archive bit would come
    into this category).

    (11) Allow the filesystem to indicate what it can/cannot provide: A
    filesystem can now say it doesn't support a standard stat feature if
    that isn't available, so if, for instance, inode numbers or UIDs don't
    exist or are fabricated locally...

    (This requires a separate system call - I have an fsinfo() call idea
    for this).

    (12) Store a 16-byte volume ID in the superblock that can be returned in
    struct xstat [Steve French].

    (Deferred to fsinfo).

    (13) Include granularity fields in the time data to indicate the
    granularity of each of the times (NFSv4 time_delta) [Steve French].

    (Deferred to fsinfo).

    (14) FS_IOC_GETFLAGS value. These could be translated to BSD's st_flags.
    Note that the Linux IOC flags are a mess and filesystems such as Ext4
    define flags that aren't in linux/fs.h, so translation in the kernel
    may be a necessity (or, possibly, we provide the filesystem type too).

    (Some attributes are made available in stx_attributes, but the general
    feeling was that the IOC flags were to ext[234]-specific and shouldn't
    be exposed through statx this way).

    (15) Mask of features available on file (eg: ACLs, seclabel) [Brad Boyer,
    Michael Kerrisk].

    (Deferred, probably to fsinfo. Finding out if there's an ACL or
    seclabal might require extra filesystem operations).

    (16) Femtosecond-resolution timestamps [Dave Chinner].

    (A __reserved field has been left in the statx_timestamp struct for
    this - if there proves to be a need).

    (17) A set multiple attributes syscall to go with this.

    ===============
    NEW SYSTEM CALL
    ===============

    The new system call is:

    int ret = statx(int dfd,
    const char *filename,
    unsigned int flags,
    unsigned int mask,
    struct statx *buffer);

    The dfd, filename and flags parameters indicate the file to query, in a
    similar way to fstatat(). There is no equivalent of lstat() as that can be
    emulated with statx() by passing AT_SYMLINK_NOFOLLOW in flags. There is
    also no equivalent of fstat() as that can be emulated by passing a NULL
    filename to statx() with the fd of interest in dfd.

    Whether or not statx() synchronises the attributes with the backing store
    can be controlled by OR'ing a value into the flags argument (this typically
    only affects network filesystems):

    (1) AT_STATX_SYNC_AS_STAT tells statx() to behave as stat() does in this
    respect.

    (2) AT_STATX_FORCE_SYNC will require a network filesystem to synchronise
    its attributes with the server - which might require data writeback to
    occur to get the timestamps correct.

    (3) AT_STATX_DONT_SYNC will suppress synchronisation with the server in a
    network filesystem. The resulting values should be considered
    approximate.

    mask is a bitmask indicating the fields in struct statx that are of
    interest to the caller. The user should set this to STATX_BASIC_STATS to
    get the basic set returned by stat(). It should be noted that asking for
    more information may entail extra I/O operations.

    buffer points to the destination for the data. This must be 256 bytes in
    size.

    ======================
    MAIN ATTRIBUTES RECORD
    ======================

    The following structures are defined in which to return the main attribute
    set:

    struct statx_timestamp {
    __s64 tv_sec;
    __s32 tv_nsec;
    __s32 __reserved;
    };

    struct statx {
    __u32 stx_mask;
    __u32 stx_blksize;
    __u64 stx_attributes;
    __u32 stx_nlink;
    __u32 stx_uid;
    __u32 stx_gid;
    __u16 stx_mode;
    __u16 __spare0[1];
    __u64 stx_ino;
    __u64 stx_size;
    __u64 stx_blocks;
    __u64 __spare1[1];
    struct statx_timestamp stx_atime;
    struct statx_timestamp stx_btime;
    struct statx_timestamp stx_ctime;
    struct statx_timestamp stx_mtime;
    __u32 stx_rdev_major;
    __u32 stx_rdev_minor;
    __u32 stx_dev_major;
    __u32 stx_dev_minor;
    __u64 __spare2[14];
    };

    The defined bits in request_mask and stx_mask are:

    STATX_TYPE Want/got stx_mode & S_IFMT
    STATX_MODE Want/got stx_mode & ~S_IFMT
    STATX_NLINK Want/got stx_nlink
    STATX_UID Want/got stx_uid
    STATX_GID Want/got stx_gid
    STATX_ATIME Want/got stx_atime{,_ns}
    STATX_MTIME Want/got stx_mtime{,_ns}
    STATX_CTIME Want/got stx_ctime{,_ns}
    STATX_INO Want/got stx_ino
    STATX_SIZE Want/got stx_size
    STATX_BLOCKS Want/got stx_blocks
    STATX_BASIC_STATS [The stuff in the normal stat struct]
    STATX_BTIME Want/got stx_btime{,_ns}
    STATX_ALL [All currently available stuff]

    stx_btime is the file creation time, stx_mask is a bitmask indicating the
    data provided and __spares*[] are where as-yet undefined fields can be
    placed.

    Time fields are structures with separate seconds and nanoseconds fields
    plus a reserved field in case we want to add even finer resolution. Note
    that times will be negative if before 1970; in such a case, the nanosecond
    fields will also be negative if not zero.

    The bits defined in the stx_attributes field convey information about a
    file, how it is accessed, where it is and what it does. The following
    attributes map to FS_*_FL flags and are the same numerical value:

    STATX_ATTR_COMPRESSED File is compressed by the fs
    STATX_ATTR_IMMUTABLE File is marked immutable
    STATX_ATTR_APPEND File is append-only
    STATX_ATTR_NODUMP File is not to be dumped
    STATX_ATTR_ENCRYPTED File requires key to decrypt in fs

    Within the kernel, the supported flags are listed by:

    KSTAT_ATTR_FS_IOC_FLAGS

    [Are any other IOC flags of sufficient general interest to be exposed
    through this interface?]

    New flags include:

    STATX_ATTR_AUTOMOUNT Object is an automount trigger

    These are for the use of GUI tools that might want to mark files specially,
    depending on what they are.

    Fields in struct statx come in a number of classes:

    (0) stx_dev_*, stx_blksize.

    These are local system information and are always available.

    (1) stx_mode, stx_nlinks, stx_uid, stx_gid, stx_[amc]time, stx_ino,
    stx_size, stx_blocks.

    These will be returned whether the caller asks for them or not. The
    corresponding bits in stx_mask will be set to indicate whether they
    actually have valid values.

    If the caller didn't ask for them, then they may be approximated. For
    example, NFS won't waste any time updating them from the server,
    unless as a byproduct of updating something requested.

    If the values don't actually exist for the underlying object (such as
    UID or GID on a DOS file), then the bit won't be set in the stx_mask,
    even if the caller asked for the value. In such a case, the returned
    value will be a fabrication.

    Note that there are instances where the type might not be valid, for
    instance Windows reparse points.

    (2) stx_rdev_*.

    This will be set only if stx_mode indicates we're looking at a
    blockdev or a chardev, otherwise will be 0.

    (3) stx_btime.

    Similar to (1), except this will be set to 0 if it doesn't exist.

    =======
    TESTING
    =======

    The following test program can be used to test the statx system call:

    samples/statx/test-statx.c

    Just compile and run, passing it paths to the files you want to examine.
    The file is built automatically if CONFIG_SAMPLES is enabled.

    Here's some example output. Firstly, an NFS directory that crosses to
    another FSID. Note that the AUTOMOUNT attribute is set because transiting
    this directory will cause d_automount to be invoked by the VFS.

    [root@andromeda ~]# /tmp/test-statx -A /warthog/data
    statx(/warthog/data) = 0
    results=7ff
    Size: 4096 Blocks: 8 IO Block: 1048576 directory
    Device: 00:26 Inode: 1703937 Links: 125
    Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
    Access: 2016-11-24 09:02:12.219699527+0000
    Modify: 2016-11-17 10:44:36.225653653+0000
    Change: 2016-11-17 10:44:36.225653653+0000
    Attributes: 0000000000001000 (-------- -------- -------- -------- -------- -------- ---m---- --------)

    Secondly, the result of automounting on that directory.

    [root@andromeda ~]# /tmp/test-statx /warthog/data
    statx(/warthog/data) = 0
    results=7ff
    Size: 4096 Blocks: 8 IO Block: 1048576 directory
    Device: 00:27 Inode: 2 Links: 125
    Access: (3777/drwxrwxrwx) Uid: 0 Gid: 4041
    Access: 2016-11-24 09:02:12.219699527+0000
    Modify: 2016-11-17 10:44:36.225653653+0000
    Change: 2016-11-17 10:44:36.225653653+0000

    Signed-off-by: David Howells
    Signed-off-by: Al Viro

    David Howells
     

02 Mar, 2017

1 commit


10 Jan, 2017

1 commit

  • Add MS_KERNMOUNT to the flags that are passed.
    Use sget_userns and force &init_user_ns instead of calling sget so that
    even if called from a weird context the internal filesystem will be
    considered to be in the intial user namespace.

    Luis Ressel reported that the the failure to pass MS_KERNMOUNT into
    mount_pseudo broke his in development graphics driver that uses the
    generic drm infrastructure. I am not certain the deriver was bug
    free in it's usage of that infrastructure but since
    mount_pseudo_xattr can never be triggered by userspace it is clearer
    and less error prone, and less problematic for the code to be explicit.

    Reported-by: Luis Ressel
    Tested-by: Luis Ressel
    Acked-by: Al Viro
    Signed-off-by: "Eric W. Biederman"

    Eric W. Biederman
     

25 Dec, 2016

1 commit


18 Dec, 2016

1 commit

  • …/linux/kernel/git/mszeredi/vfs

    Pull partial readlink cleanups from Miklos Szeredi.

    This is the uncontroversial part of the readlink cleanup patch-set that
    simplifies the default readlink handling.

    Miklos and Al are still discussing the rest of the series.

    * git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/vfs:
    vfs: make generic_readlink() static
    vfs: remove ".readlink = generic_readlink" assignments
    vfs: default to generic_readlink()
    vfs: replace calling i_op->readlink with vfs_readlink()
    proc/self: use generic_readlink
    ecryptfs: use vfs_get_link()
    bad_inode: add missing i_op initializers

    Linus Torvalds