30 Oct, 2020

1 commit

  • There is a regular need in the kernel to provide a way to declare having a
    dynamically sized set of trailing elements in a structure. Kernel code should
    always use “flexible array members”[1] for these cases. The older style of
    one-element or zero-length arrays should no longer be used[2].

    [1] https://en.wikipedia.org/wiki/Flexible_array_member
    [2] https://www.kernel.org/doc/html/v5.9-rc1/process/deprecated.html#zero-length-and-one-element-arrays

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

    Gustavo A. R. Silva
     

25 Oct, 2020

1 commit

  • Pull misc vfs updates from Al Viro:
    "Assorted stuff all over the place (the largest group here is
    Christoph's stat cleanups)"

    * 'work.misc' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: remove KSTAT_QUERY_FLAGS
    fs: remove vfs_stat_set_lookup_flags
    fs: move vfs_fstatat out of line
    fs: implement vfs_stat and vfs_lstat in terms of vfs_fstatat
    fs: remove vfs_statx_fd
    fs: omfs: use kmemdup() rather than kmalloc+memcpy
    [PATCH] reduce boilerplate in fsid handling
    fs: Remove duplicated flag O_NDELAY occurring twice in VALID_OPEN_FLAGS
    selftests: mount: add nosymfollow tests
    Add a "nosymfollow" mount option.

    Linus Torvalds
     

19 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
     

17 Jul, 2020

1 commit

  • Using uninitialized_var() is dangerous as it papers over real bugs[1]
    (or can in the future), and suppresses unrelated compiler warnings
    (e.g. "unused variable"). If the compiler thinks it is uninitialized,
    either simply initialize the variable or make compiler changes.

    In preparation for removing[2] the[3] macro[4], remove all remaining
    needless uses with the following script:

    git grep '\buninitialized_var\b' | cut -d: -f1 | sort -u | \
    xargs perl -pi -e \
    's/\buninitialized_var\(([^\)]+)\)/\1/g;
    s:\s*/\* (GCC be quiet|to make compiler happy) \*/$::g;'

    drivers/video/fbdev/riva/riva_hw.c was manually tweaked to avoid
    pathological white-space.

    No outstanding warnings were found building allmodconfig with GCC 9.3.0
    for x86_64, i386, arm64, arm, powerpc, powerpc64le, s390x, mips, sparc64,
    alpha, and m68k.

    [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/
    [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/
    [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/
    [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/

    Reviewed-by: Leon Romanovsky # drivers/infiniband and mlx4/mlx5
    Acked-by: Jason Gunthorpe # IB
    Acked-by: Kalle Valo # wireless drivers
    Reviewed-by: Chao Yu # erofs
    Signed-off-by: Kees Cook

    Kees Cook
     

22 May, 2020

1 commit


05 May, 2020

1 commit


11 Apr, 2020

1 commit

  • When removing files containing extended attributes, the hfsplus driver may
    remove the wrong entries from the attributes b-tree, causing major
    filesystem damage and in some cases even kernel crashes.

    To remove a file, all its extended attributes have to be removed as well.
    The driver does this by looking up all keys in the attributes b-tree with
    the cnid of the file. Each of these entries then gets deleted using the
    key used for searching, which doesn't contain the attribute's name when it
    should. Since the key doesn't contain the name, the deletion routine will
    not find the correct entry and instead remove the one in front of it. If
    parent nodes have to be modified, these become corrupt as well. This
    causes invalid links and unsorted entries that not even macOS's fsck_hfs
    is able to fix.

    To fix this, modify the search key before an entry is deleted from the
    attributes b-tree by copying the found entry's key into the search key,
    therefore ensuring that the correct entry gets removed from the tree.

    Signed-off-by: Simon Gander
    Signed-off-by: Andrew Morton
    Reviewed-by: Anton Altaparmakov
    Cc:
    Link: http://lkml.kernel.org/r/20200327155541.1521-1-simon@tuxera.com
    Signed-off-by: Linus Torvalds

    Simon Gander
     

19 Dec, 2019

1 commit

  • The interpretation of on-disk timestamps in HFS and HFS+ differs
    between 32-bit and 64-bit kernels at the moment. Use 64-bit timestamps
    consistently so apply the current 64-bit behavior everyhere.

    According to the official documentation for HFS+ [1], inode timestamps
    are supposed to cover the time range from 1904 to 2040 as originally
    used in classic MacOS.

    The traditional Linux usage is to convert the timestamps into an unsigned
    32-bit number based on the Unix epoch and from there to a time_t. On
    32-bit systems, that wraps the time from 2038 to 1902, so the last
    two years of the valid time range become garbled. On 64-bit systems,
    all times before 1970 get turned into timestamps between 2038 and 2106,
    which is more convenient but also different from the documented behavior.

    Looking at the Darwin sources [2], it seems that MacOS is inconsistent in
    yet another way: all timestamps are wrapped around to a 32-bit unsigned
    number when written to the disk, but when read back, all numeric values
    lower than 2082844800U are assumed to be invalid, so we cannot represent
    the times before 1970 or the times after 2040.

    While all implementations seem to agree on the interpretation of values
    between 1970 and 2038, they often differ on the exact range they support
    when reading back values outside of the common range:

    MacOS (traditional): 1904-2040
    Apple Documentation: 1904-2040
    MacOS X source comments: 1970-2040
    MacOS X source code: 1970-2038
    32-bit Linux: 1902-2038
    64-bit Linux: 1970-2106
    hfsfuse: 1970-2040
    hfsutils (32 bit, old libc) 1902-2038
    hfsutils (32 bit, new libc) 1970-2106
    hfsutils (64 bit) 1904-2040
    hfsplus-utils 1904-2040
    hfsexplorer 1904-2040
    7-zip 1904-2040

    Out of the above, the range from 1970 to 2106 seems to be the most useful,
    as it allows using HFS and HFS+ beyond year 2038, and this matches the
    behavior that most users would see today on Linux, as few people run
    32-bit kernels any more.

    Link: [1] https://developer.apple.com/library/archive/technotes/tn/tn1150.html
    Link: [2] https://opensource.apple.com/source/hfs/hfs-407.30.1/core/MacOSStubs.c.auto.html
    Link: https://lore.kernel.org/lkml/20180711224625.airwna6gzyatoowe@eaf/
    Suggested-by: "Ernesto A. Fernández"
    Reviewed-by: Vyacheslav Dubeyko
    Reviewed-by: Ernesto A. Fernández
    Signed-off-by: Arnd Bergmann
    ---
    v3: revert back to 1970-2106 time range
    fix bugs found in review
    merge both patches into one
    drop cc:stable tag
    v2: treat pre-1970 dates as invalid following MacOS X behavior,
    reword and expand changelog text

    Arnd Bergmann
     

17 Jul, 2019

1 commit

  • strncpy() was used to copy a fixed size buffer. Since NUL-terminating
    string is not required here, prefer a memcpy function. The generated
    code (ppc32) remains the same.

    Silence the following warning triggered using W=1:

    fs/hfsplus/xattr.c:410:3: warning: 'strncpy' output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation]

    Link: http://lkml.kernel.org/r/20190529113341.11972-1-malat@debian.org
    Signed-off-by: Mathieu Malaterre
    Reviewed-by: Vyacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mathieu Malaterre
     

01 Jul, 2019

1 commit

  • Create a generic function to check incoming FS_IOC_SETFLAGS flag values
    and later prepare the inode for updates so that we can standardize the
    implementations that follow ext4's flag values.

    Note that the efivarfs implementation no longer fails a no-op SETFLAGS
    without CAP_LINUX_IMMUTABLE since that's the behavior in ext*.

    Signed-off-by: Darrick J. Wong
    Reviewed-by: Jan Kara
    Reviewed-by: Christoph Hellwig
    Acked-by: David Sterba
    Reviewed-by: Bob Peterson

    Darrick J. Wong
     

21 May, 2019

2 commits


02 May, 2019

1 commit


05 Jan, 2019

1 commit

  • The immutable, append-only and no-dump attributes can only be retrieved
    with an ioctl; implement the ->getattr() method to return them on statx.
    Do not return the inode birthtime yet, because the issue of how best to
    handle the post-2038 timestamps is still under discussion.

    This patch is needed to pass xfstests generic/424.

    Link: http://lkml.kernel.org/r/20181014163558.sxorxlzjqccq2lpw@eaf
    Signed-off-by: Ernesto A. Fernández
    Cc: Viacheslav Dubeyko
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     

01 Dec, 2018

1 commit

  • hfs_bmap_free() frees node via hfs_bnode_put(node). However it then
    reads node->this when dumping error message on an error path, which may
    result in a use-after-free bug. This patch frees node only when it is
    never used.

    Link: http://lkml.kernel.org/r/1543053441-66942-1-git-send-email-bianpan2016@163.com
    Signed-off-by: Pan Bian
    Reviewed-by: Andrew Morton
    Cc: Ernesto A. Fernandez
    Cc: Joe Perches
    Cc: Viacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Pan Bian
     

31 Oct, 2018

5 commits

  • The vfs takes care of updating ctime and mtime on ftruncate(), but on
    truncate() it must be done by the module.

    This patch can be tested with xfstests generic/313.

    Link: http://lkml.kernel.org/r/9beb0913eea37288599e8e1b7cec8768fb52d1b8.1539316825.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernández
    Reviewed-by: Vyacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • Direct writes to empty inodes fail with EIO. The generic direct-io code
    is in part to blame (a patch has been submitted as "direct-io: allow
    direct writes to empty inodes"), but hfsplus is worse affected than the
    other filesystems because the fallback to buffered I/O doesn't happen.

    The problem is the return value of hfsplus_get_block() when called with
    !create. Change it to be more consistent with the other modules.

    Link: http://lkml.kernel.org/r/2cd1301404ec7cf1e39c8f11a01a4302f1460ad6.1539195310.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernández
    Reviewed-by: Vyacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • Inserting or deleting a record in a btree may require splitting several of
    its nodes. If we hit ENOSPC halfway through, the new nodes will be left
    orphaned and their records will be lost. This could mean lost inodes,
    extents or xattrs.

    Henceforth, check the available disk space before making any changes.
    This still leaves the potential problem of corruption on ENOMEM.

    The patch can be tested with xfstests generic/027.

    Link: http://lkml.kernel.org/r/4596eef22fbda137b4ffa0272d92f0da15364421.1536269129.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernández
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • Creating, renaming or deleting a file may hit BUG_ON() if the first
    record of both a leaf node and its parent are changed, and if this
    forces the parent to be split. This bug is triggered by xfstests
    generic/027, somewhat rarely; here is a more reliable reproducer:

    truncate -s 50M fs.iso
    mkfs.hfsplus fs.iso
    mount fs.iso /mnt
    i=1000
    while [ $i -le 2400 ]; do
    touch /mnt/$i &>/dev/null
    ((++i))
    done
    i=2400
    while [ $i -ge 1000 ]; do
    mv /mnt/$i /mnt/$(perl -e "print $i x61") &>/dev/null
    ((--i))
    done

    The issue is that a newly created bnode is being put twice. Reset
    new_node to NULL in hfs_brec_update_parent() before reaching goto again.

    Link: http://lkml.kernel.org/r/5ee1db09b60373a15890f6a7c835d00e76bf601d.1535682461.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernández
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • Creating, renaming or deleting a file may cause catalog corruption and
    data loss. This bug is randomly triggered by xfstests generic/027, but
    here is a faster reproducer:

    truncate -s 50M fs.iso
    mkfs.hfsplus fs.iso
    mount fs.iso /mnt
    i=100
    while [ $i -le 150 ]; do
    touch /mnt/$i &>/dev/null
    ((++i))
    done
    i=100
    while [ $i -le 150 ]; do
    mv /mnt/$i /mnt/$(perl -e "print $i x82") &>/dev/null
    ((++i))
    done
    umount /mnt
    fsck.hfsplus -n fs.iso

    The bug is triggered whenever hfs_brec_update_parent() needs to split the
    root node. The height of the btree is not increased, which leaves the new
    node orphaned and its records lost.

    Link: http://lkml.kernel.org/r/26d882184fc43043a810114258f45277752186c7.1535682461.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernández
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     

24 Aug, 2018

2 commits

  • hfs_find_exit() expects fd->bnode to be NULL after a search has failed.
    hfs_brec_insert() may instead set it to an error-valued pointer. Fix
    this to prevent a crash.

    Link: http://lkml.kernel.org/r/803590a35221fbf411b2c141419aea3233a6e990.1530294813.git.ernesto.mnd.fernandez@gmail.com
    Signed-off-by: Ernesto A. Fernandez
    Reported-by: Anatoly Trosinenko
    Reviewed-by: Vyacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernandez
     
  • An HFS+ filesystem can be mounted read-only without having a metadata
    directory, which is needed to support hardlinks. But if the catalog
    data is corrupted, a directory lookup may still find dentries claiming
    to be hardlinks.

    hfsplus_lookup() does check that ->hidden_dir is not NULL in such a
    situation, but mistakenly does so after dereferencing it for the first
    time. Reorder this check to prevent a crash.

    This happens when looking up corrupted catalog data (dentry) on a
    filesystem with no metadata directory (this could only ever happen on a
    read-only mount). Wen Xu sent the replication steps in detail to the
    fsdevel list: https://bugzilla.kernel.org/show_bug.cgi?id=200297

    Link: http://lkml.kernel.org/r/20180712215344.q44dyrhymm4ajkao@eaf
    Signed-off-by: Ernesto A. Fernández
    Reported-by: Wen Xu
    Cc: Viacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     

23 Aug, 2018

4 commits

  • The HFS+ Access Control Lists have not worked at all for the past five
    years, and nobody seems to have noticed. Besides, POSIX draft ACLs are
    not compatible with MacOS. Drop the feature entirely.

    Link: http://lkml.kernel.org/r/20180714190608.wtnmmtjqeyladkut@eaf
    Signed-off-by: Ernesto A. Fernández
    Acked-by: Christoph Hellwig
    Cc: Viacheslav Dubeyko
    Cc: Jan Kara
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • Files created under macOS cannot be opened under linux if their names
    contain Korean characters, and vice versa.

    The Korean alphabet is special because its normalization is done without a
    table. The module deals with it correctly when composing, but forgets
    about it for the decomposition.

    Fix this using the Hangul decomposition function provided in the Unicode
    Standard. The code fits a bit awkwardly because it requires a buffer,
    while all the other normalizations are returned as pointers to the
    decomposition table. This is actually also a bug because reordering may
    still be needed, but for now leave it as it is.

    The patch will cause trouble for Hangul filenames already created by the
    module in the past. This shouldn't really be concern because its main
    purpose was always sharing with macOS. If a user actually needs to access
    such a file the nodecompose mount option should be enough.

    Link: http://lkml.kernel.org/r/20180717220951.p6qqrgautc4pxvzu@eaf
    Signed-off-by: Ernesto A. Fernández
    Reported-by: Ting-Chang Hou
    Tested-by: Ting-Chang Hou
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • After an extent is removed from the extent tree, the corresponding bits
    are also cleared from the block allocation file. This is currently done
    without releasing the tree lock.

    The problem is that the allocation file has extents of its own; if it is
    fragmented enough, some of them may be in the extent tree as well, and
    hfsplus_get_block() will try to take the lock again.

    To avoid deadlock, only hold the extent tree lock during the actual tree
    operations.

    Link: http://lkml.kernel.org/r/20180709202549.auxwkb6memlegb4a@eaf
    Signed-off-by: Ernesto A. Fernández
    Reported-by: Anatoly Trosinenko
    Cc: Viacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernández
     
  • syzbot is reporting NULL pointer dereference at mount_fs() [1]. This is
    because hfsplus_fill_super() is by error returning 0 when
    hfsplus_fill_super() detected invalid filesystem image, and mount_bdev()
    is returning NULL because dget(s->s_root) == NULL if s->s_root == NULL,
    and mount_fs() is accessing root->d_sb because IS_ERR(root) == false if
    root == NULL. Fix this by returning -EINVAL when hfsplus_fill_super()
    detected invalid filesystem image.

    [1] https://syzkaller.appspot.com/bug?id=21acb6850cecbc960c927229e597158cf35f33d0

    Link: http://lkml.kernel.org/r/d83ce31a-874c-dd5b-f790-41405983a5be@I-love.SAKURA.ne.jp
    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Reviewed-by: Ernesto A. Fernández
    Reviewed-by: Andrew Morton
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tetsuo Handa
     

15 Jun, 2018

1 commit

  • Pull inode timestamps conversion to timespec64 from Arnd Bergmann:
    "This is a late set of changes from Deepa Dinamani doing an automated
    treewide conversion of the inode and iattr structures from 'timespec'
    to 'timespec64', to push the conversion from the VFS layer into the
    individual file systems.

    As Deepa writes:

    'The series aims to switch vfs timestamps to use struct timespec64.
    Currently vfs uses struct timespec, which is not y2038 safe.

    The series involves the following:
    1. Add vfs helper functions for supporting struct timepec64
    timestamps.
    2. Cast prints of vfs timestamps to avoid warnings after the switch.
    3. Simplify code using vfs timestamps so that the actual replacement
    becomes easy.
    4. Convert vfs timestamps to use struct timespec64 using a script.
    This is a flag day patch.

    Next steps:
    1. Convert APIs that can handle timespec64, instead of converting
    timestamps at the boundaries.
    2. Update internal data structures to avoid timestamp conversions'

    Thomas Gleixner adds:

    'I think there is no point to drag that out for the next merge
    window. The whole thing needs to be done in one go for the core
    changes which means that you're going to play that catchup game
    forever. Let's get over with it towards the end of the merge window'"

    * tag 'vfs-timespec64' of git://git.kernel.org/pub/scm/linux/kernel/git/arnd/playground:
    pstore: Remove bogus format string definition
    vfs: change inode times to use struct timespec64
    pstore: Convert internal records to timespec64
    udf: Simplify calls to udf_disk_stamp_to_time
    fs: nfs: get rid of memcpys for inode times
    ceph: make inode time prints to be long long
    lustre: Use long long type to print inode time
    fs: add timespec64_truncate()

    Linus Torvalds
     

06 Jun, 2018

1 commit

  • struct timespec is not y2038 safe. Transition vfs to use
    y2038 safe struct timespec64 instead.

    The change was made with the help of the following cocinelle
    script. This catches about 80% of the changes.
    All the header file and logic changes are included in the
    first 5 rules. The rest are trivial substitutions.
    I avoid changing any of the function signatures or any other
    filesystem specific data structures to keep the patch simple
    for review.

    The script can be a little shorter by combining different cases.
    But, this version was sufficient for my usecase.

    virtual patch

    @ depends on patch @
    identifier now;
    @@
    - struct timespec
    + struct timespec64
    current_time ( ... )
    {
    - struct timespec now = current_kernel_time();
    + struct timespec64 now = current_kernel_time64();
    ...
    - return timespec_trunc(
    + return timespec64_trunc(
    ... );
    }

    @ depends on patch @
    identifier xtime;
    @@
    struct \( iattr \| inode \| kstat \) {
    ...
    - struct timespec xtime;
    + struct timespec64 xtime;
    ...
    }

    @ depends on patch @
    identifier t;
    @@
    struct inode_operations {
    ...
    int (*update_time) (...,
    - struct timespec t,
    + struct timespec64 t,
    ...);
    ...
    }

    @ depends on patch @
    identifier t;
    identifier fn_update_time =~ "update_time$";
    @@
    fn_update_time (...,
    - struct timespec *t,
    + struct timespec64 *t,
    ...) { ... }

    @ depends on patch @
    identifier t;
    @@
    lease_get_mtime( ... ,
    - struct timespec *t
    + struct timespec64 *t
    ) { ... }

    @te depends on patch forall@
    identifier ts;
    local idexpression struct inode *inode_node;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier fn_update_time =~ "update_time$";
    identifier fn;
    expression e, E3;
    local idexpression struct inode *node1;
    local idexpression struct inode *node2;
    local idexpression struct iattr *attr1;
    local idexpression struct iattr *attr2;
    local idexpression struct iattr attr;
    identifier i_xtime1 =~ "^i_[acm]time$";
    identifier i_xtime2 =~ "^i_[acm]time$";
    identifier ia_xtime1 =~ "^ia_[acm]time$";
    identifier ia_xtime2 =~ "^ia_[acm]time$";
    @@
    (
    (
    - struct timespec ts;
    + struct timespec64 ts;
    |
    - struct timespec ts = current_time(inode_node);
    + struct timespec64 ts = current_time(inode_node);
    )

    i_xtime, &ts)
    + timespec64_equal(&inode_node->i_xtime, &ts)
    |
    - timespec_equal(&ts, &inode_node->i_xtime)
    + timespec64_equal(&ts, &inode_node->i_xtime)
    |
    - timespec_compare(&inode_node->i_xtime, &ts)
    + timespec64_compare(&inode_node->i_xtime, &ts)
    |
    - timespec_compare(&ts, &inode_node->i_xtime)
    + timespec64_compare(&ts, &inode_node->i_xtime)
    |
    ts = current_time(e)
    |
    fn_update_time(..., &ts,...)
    |
    inode_node->i_xtime = ts
    |
    node1->i_xtime = ts
    |
    ts = inode_node->i_xtime
    |
    ia_xtime ...+> = ts
    |
    ts = attr1->ia_xtime
    |
    ts.tv_sec
    |
    ts.tv_nsec
    |
    btrfs_set_stack_timespec_sec(..., ts.tv_sec)
    |
    btrfs_set_stack_timespec_nsec(..., ts.tv_nsec)
    |
    - ts = timespec64_to_timespec(
    + ts =
    ...
    -)
    |
    - ts = ktime_to_timespec(
    + ts = ktime_to_timespec64(
    ...)
    |
    - ts = E3
    + ts = timespec_to_timespec64(E3)
    |
    - ktime_get_real_ts(&ts)
    + ktime_get_real_ts64(&ts)
    |
    fn(...,
    - ts
    + timespec64_to_timespec(ts)
    ,...)
    )
    ...+>
    (

    )
    |
    - timespec_equal(&node1->i_xtime1, &node2->i_xtime2)
    + timespec64_equal(&node1->i_xtime2, &node2->i_xtime2)
    |
    - timespec_equal(&node1->i_xtime1, &attr2->ia_xtime2)
    + timespec64_equal(&node1->i_xtime2, &attr2->ia_xtime2)
    |
    - timespec_compare(&node1->i_xtime1, &node2->i_xtime2)
    + timespec64_compare(&node1->i_xtime1, &node2->i_xtime2)
    |
    node1->i_xtime1 =
    - timespec_trunc(attr1->ia_xtime1,
    + timespec64_trunc(attr1->ia_xtime1,
    ...)
    |
    - attr1->ia_xtime1 = timespec_trunc(attr2->ia_xtime2,
    + attr1->ia_xtime1 = timespec64_trunc(attr2->ia_xtime2,
    ...)
    |
    - ktime_get_real_ts(&attr1->ia_xtime1)
    + ktime_get_real_ts64(&attr1->ia_xtime1)
    |
    - ktime_get_real_ts(&attr.ia_xtime1)
    + ktime_get_real_ts64(&attr.ia_xtime1)
    )

    @ depends on patch @
    struct inode *node;
    struct iattr *attr;
    identifier fn;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    expression e;
    @@
    (
    - fn(node->i_xtime);
    + fn(timespec64_to_timespec(node->i_xtime));
    |
    fn(...,
    - node->i_xtime);
    + timespec64_to_timespec(node->i_xtime));
    |
    - e = fn(attr->ia_xtime);
    + e = fn(timespec64_to_timespec(attr->ia_xtime));
    )

    @ depends on patch forall @
    struct inode *node;
    struct iattr *attr;
    identifier i_xtime =~ "^i_[acm]time$";
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier fn;
    @@
    {
    + struct timespec ts;
    i_xtime);
    fn (...,
    - &node->i_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    fn (...,
    - &attr->ia_xtime,
    + &ts,
    ...);
    )
    ...+>
    }

    @ depends on patch forall @
    struct inode *node;
    struct iattr *attr;
    struct kstat *stat;
    identifier ia_xtime =~ "^ia_[acm]time$";
    identifier i_xtime =~ "^i_[acm]time$";
    identifier xtime =~ "^[acm]time$";
    identifier fn, ret;
    @@
    {
    + struct timespec ts;
    i_xtime);
    ret = fn (...,
    - &node->i_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(node->i_xtime);
    ret = fn (...,
    - &node->i_xtime);
    + &ts);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    ret = fn (...,
    - &attr->ia_xtime,
    + &ts,
    ...);
    |
    + ts = timespec64_to_timespec(attr->ia_xtime);
    ret = fn (...,
    - &attr->ia_xtime);
    + &ts);
    |
    + ts = timespec64_to_timespec(stat->xtime);
    ret = fn (...,
    - &stat->xtime);
    + &ts);
    )
    ...+>
    }

    @ depends on patch @
    struct inode *node;
    struct inode *node2;
    identifier i_xtime1 =~ "^i_[acm]time$";
    identifier i_xtime2 =~ "^i_[acm]time$";
    identifier i_xtime3 =~ "^i_[acm]time$";
    struct iattr *attrp;
    struct iattr *attrp2;
    struct iattr attr ;
    identifier ia_xtime1 =~ "^ia_[acm]time$";
    identifier ia_xtime2 =~ "^ia_[acm]time$";
    struct kstat *stat;
    struct kstat stat1;
    struct timespec64 ts;
    identifier xtime =~ "^[acmb]time$";
    expression e;
    @@
    (
    ( node->i_xtime2 \| attrp->ia_xtime2 \| attr.ia_xtime2 \) = node->i_xtime1 ;
    |
    node->i_xtime2 = \( node2->i_xtime1 \| timespec64_trunc(...) \);
    |
    node->i_xtime2 = node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \);
    |
    node->i_xtime1 = node->i_xtime3 = \(ts \| current_time(...) \);
    |
    stat->xtime = node2->i_xtime1;
    |
    stat1.xtime = node2->i_xtime1;
    |
    ( node->i_xtime2 \| attrp->ia_xtime2 \) = attrp->ia_xtime1 ;
    |
    ( attrp->ia_xtime1 \| attr.ia_xtime1 \) = attrp2->ia_xtime2;
    |
    - e = node->i_xtime1;
    + e = timespec64_to_timespec( node->i_xtime1 );
    |
    - e = attrp->ia_xtime1;
    + e = timespec64_to_timespec( attrp->ia_xtime1 );
    |
    node->i_xtime1 = current_time(...);
    |
    node->i_xtime2 = node->i_xtime1 = node->i_xtime3 =
    - e;
    + timespec_to_timespec64(e);
    |
    node->i_xtime1 = node->i_xtime3 =
    - e;
    + timespec_to_timespec64(e);
    |
    - node->i_xtime1 = e;
    + node->i_xtime1 = timespec_to_timespec64(e);
    )

    Signed-off-by: Deepa Dinamani
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:
    Cc:

    Deepa Dinamani
     

05 Jun, 2018

1 commit

  • Pull dcache lookup cleanups from Al Viro:
    "Cleaning ->lookup() instances up - mostly d_splice_alias() conversions"

    * 'work.lookup' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (29 commits)
    switch the rest of procfs lookups to d_splice_alias()
    procfs: switch instantiate_t to d_splice_alias()
    don't bother with tid_fd_revalidate() in lookups
    proc_lookupfd_common(): don't bother with instantiate unless the file is open
    procfs: get rid of ancient BS in pid_revalidate() uses
    cifs_lookup(): switch to d_splice_alias()
    cifs_lookup(): cifs_get_inode_...() never returns 0 with *inode left NULL
    9p: unify paths in v9fs_vfs_lookup()
    ncp_lookup(): use d_splice_alias()
    hfsplus: switch to d_splice_alias()
    hfs: don't allow mounting over .../rsrc
    hfs: use d_splice_alias()
    omfs_lookup(): report IO errors, use d_splice_alias()
    orangefs_lookup: simplify
    openpromfs: switch to d_splice_alias()
    xfs_vn_lookup: simplify a bit
    adfs_lookup: do not fail with ENOENT on negatives, use d_splice_alias()
    adfs_lookup_byname: .. *is* taken care of in fs/namei.c
    romfs_lookup: switch to d_splice_alias()
    qnx6_lookup: switch to d_splice_alias()
    ...

    Linus Torvalds
     

23 May, 2018

1 commit


19 May, 2018

1 commit

  • syzbot is reporting ODEBUG messages at hfsplus_fill_super() [1]. This
    is because hfsplus_fill_super() forgot to call cancel_delayed_work_sync().

    As far as I can see, it is hfsplus_mark_mdb_dirty() from
    hfsplus_new_inode() in hfsplus_fill_super() that calls
    queue_delayed_work(). Therefore, I assume that hfsplus_new_inode() does
    not fail if queue_delayed_work() was called, and the out_put_hidden_dir
    label is the appropriate location to call cancel_delayed_work_sync().

    [1] https://syzkaller.appspot.com/bug?id=a66f45e96fdbeb76b796bf46eb25ea878c42a6c9

    Link: http://lkml.kernel.org/r/964a8b27-cd69-357c-fe78-76b066056201@I-love.SAKURA.ne.jp
    Signed-off-by: Tetsuo Handa
    Reported-by: syzbot
    Cc: Al Viro
    Cc: David Howells
    Cc: Ernesto A. Fernandez
    Cc: Vyacheslav Dubeyko
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tetsuo Handa
     

07 Feb, 2018

1 commit

  • When creating a file inside a directory that has the setgid flag set, give
    the new file the group ID of the parent, and also the setgid flag if it is
    a directory itself.

    Link: http://lkml.kernel.org/r/20171204192705.GA6101@debian.home
    Signed-off-by: Ernesto A. Fernandez
    Reviewed-by: Vyacheslav Dubeyko
    Cc: Al Viro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ernesto A. Fernandez
     

02 Jan, 2018

1 commit

  • This link is replicated in most filesystems' config stanzas. Referring
    to an archived version of that site is pointless as it mostly deals with
    patches; user documentation is available elsewhere.

    Signed-off-by: Adam Borowski
    CC: Alexander Viro
    Reviewed-by: Darrick J. Wong
    Acked-by: Jan Kara
    Acked-by: Dave Kleikamp
    Acked-by: David Sterba
    Acked-by: "Yan, Zheng"
    Acked-by: Chao Yu
    Acked-by: Jaegeuk Kim
    Acked-by: Steve French
    Signed-off-by: Jonathan Corbet

    Adam Borowski
     

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
     

18 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

15 Sep, 2017

1 commit

  • Pull mount flag updates from Al Viro:
    "Another chunk of fmount preparations from dhowells; only trivial
    conflicts for that part. It separates MS_... bits (very grotty
    mount(2) ABI) from the struct super_block ->s_flags (kernel-internal,
    only a small subset of MS_... stuff).

    This does *not* convert the filesystems to new constants; only the
    infrastructure is done here. The next step in that series is where the
    conflicts would be; that's the conversion of filesystems. It's purely
    mechanical and it's better done after the merge, so if you could run
    something like

    list=$(for i in MS_RDONLY MS_NOSUID MS_NODEV MS_NOEXEC MS_SYNCHRONOUS MS_MANDLOCK MS_DIRSYNC MS_NOATIME MS_NODIRATIME MS_SILENT MS_POSIXACL MS_KERNMOUNT MS_I_VERSION MS_LAZYTIME; do git grep -l $i fs drivers/staging/lustre drivers/mtd ipc mm include/linux; done|sort|uniq|grep -v '^fs/namespace.c$')

    sed -i -e 's/\/SB_RDONLY/g' \
    -e 's/\/SB_NOSUID/g' \
    -e 's/\/SB_NODEV/g' \
    -e 's/\/SB_NOEXEC/g' \
    -e 's/\/SB_SYNCHRONOUS/g' \
    -e 's/\/SB_MANDLOCK/g' \
    -e 's/\/SB_DIRSYNC/g' \
    -e 's/\/SB_NOATIME/g' \
    -e 's/\/SB_NODIRATIME/g' \
    -e 's/\/SB_SILENT/g' \
    -e 's/\/SB_POSIXACL/g' \
    -e 's/\/SB_KERNMOUNT/g' \
    -e 's/\/SB_I_VERSION/g' \
    -e 's/\/SB_LAZYTIME/g' \
    $list

    and commit it with something along the lines of 'convert filesystems
    away from use of MS_... constants' as commit message, it would save a
    quite a bit of headache next cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    VFS: Differentiate mount flags (MS_*) from internal superblock flags
    VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb)
    vfs: Add sb_rdonly(sb) to query the MS_RDONLY flag on s_flags

    Linus Torvalds
     

08 Sep, 2017

1 commit

  • Pull block layer updates from Jens Axboe:
    "This is the first pull request for 4.14, containing most of the code
    changes. It's a quiet series this round, which I think we needed after
    the churn of the last few series. This contains:

    - Fix for a registration race in loop, from Anton Volkov.

    - Overflow complaint fix from Arnd for DAC960.

    - Series of drbd changes from the usual suspects.

    - Conversion of the stec/skd driver to blk-mq. From Bart.

    - A few BFQ improvements/fixes from Paolo.

    - CFQ improvement from Ritesh, allowing idling for group idle.

    - A few fixes found by Dan's smatch, courtesy of Dan.

    - A warning fixup for a race between changing the IO scheduler and
    device remova. From David Jeffery.

    - A few nbd fixes from Josef.

    - Support for cgroup info in blktrace, from Shaohua.

    - Also from Shaohua, new features in the null_blk driver to allow it
    to actually hold data, among other things.

    - Various corner cases and error handling fixes from Weiping Zhang.

    - Improvements to the IO stats tracking for blk-mq from me. Can
    drastically improve performance for fast devices and/or big
    machines.

    - Series from Christoph removing bi_bdev as being needed for IO
    submission, in preparation for nvme multipathing code.

    - Series from Bart, including various cleanups and fixes for switch
    fall through case complaints"

    * 'for-4.14/block' of git://git.kernel.dk/linux-block: (162 commits)
    kernfs: checking for IS_ERR() instead of NULL
    drbd: remove BIOSET_NEED_RESCUER flag from drbd_{md_,}io_bio_set
    drbd: Fix allyesconfig build, fix recent commit
    drbd: switch from kmalloc() to kmalloc_array()
    drbd: abort drbd_start_resync if there is no connection
    drbd: move global variables to drbd namespace and make some static
    drbd: rename "usermode_helper" to "drbd_usermode_helper"
    drbd: fix race between handshake and admin disconnect/down
    drbd: fix potential deadlock when trying to detach during handshake
    drbd: A single dot should be put into a sequence.
    drbd: fix rmmod cleanup, remove _all_ debugfs entries
    drbd: Use setup_timer() instead of init_timer() to simplify the code.
    drbd: fix potential get_ldev/put_ldev refcount imbalance during attach
    drbd: new disk-option disable-write-same
    drbd: Fix resource role for newly created resources in events2
    drbd: mark symbols static where possible
    drbd: Send P_NEG_ACK upon write error in protocol != C
    drbd: add explicit plugging when submitting batches
    drbd: change list_for_each_safe to while(list_first_entry_or_null)
    drbd: introduce drbd_recv_header_maybe_unplug
    ...

    Linus Torvalds
     

07 Sep, 2017

1 commit

  • Pull writeback error handling updates from Jeff Layton:
    "This pile continues the work from last cycle on better tracking
    writeback errors. In v4.13 we added some basic errseq_t infrastructure
    and converted a few filesystems to use it.

    This set continues refining that infrastructure, adds documentation,
    and converts most of the other filesystems to use it. The main
    exception at this point is the NFS client"

    * tag 'wberr-v4.14-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux:
    ecryptfs: convert to file_write_and_wait in ->fsync
    mm: remove optimizations based on i_size in mapping writeback waits
    fs: convert a pile of fsync routines to errseq_t based reporting
    gfs2: convert to errseq_t based writeback error reporting for fsync
    fs: convert sync_file_range to use errseq_t based error-tracking
    mm: add file_fdatawait_range and file_write_and_wait
    fuse: convert to errseq_t based error tracking for fsync
    mm: consolidate dax / non-dax checks for writeback
    Documentation: add some docs for errseq_t
    errseq: rename __errseq_set to errseq_set

    Linus Torvalds