27 Apr, 2017

2 commits

  • commit 32fe905c17f001c0eee13c59afddd0bf2eed509c upstream.

    It is perfectly fine to link a tmpfile back using linkat().
    Since tmpfiles are created with a link count of 0 they appear
    on the orphan list, upon re-linking the inode has to be removed
    from the orphan list again.

    Ralph faced a filesystem corruption in combination with overlayfs
    due to this bug.

    Cc: Ralph Sennhauser
    Cc: Amir Goldstein
    Reported-by: Ralph Sennhauser
    Tested-by: Ralph Sennhauser
    Reported-by: Amir Goldstein
    Fixes: 474b93704f321 ("ubifs: Implement O_TMPFILE")
    Signed-off-by: Richard Weinberger
    Signed-off-by: Greg Kroah-Hartman

    Richard Weinberger
     
  • commit c3d9fda688742c06e89aa1f0f8fd943fc11468cb upstream.

    Remove faulty leftover check in do_rename(), apparently introduced in a
    merge that combined whiteout support changes with commit f03b8ad8d386
    ("fs: support RENAME_NOREPLACE for local filesystems")

    Fixes: f03b8ad8d386 ("fs: support RENAME_NOREPLACE for local filesystems")
    Fixes: 9e0a1fff8db5 ("ubifs: Implement RENAME_WHITEOUT")
    Signed-off-by: Felix Fietkau
    Signed-off-by: Richard Weinberger
    Signed-off-by: Greg Kroah-Hartman

    Felix Fietkau
     

28 Oct, 2016

1 commit

  • Commit c83ed4c9dbb35 ("ubifs: Abort readdir upon error") broke
    overlayfs support because the fix exposed an internal error
    code to VFS.

    Reported-by: Peter Rosin
    Tested-by: Peter Rosin
    Reported-by: Ralph Sennhauser
    Tested-by: Ralph Sennhauser
    Fixes: c83ed4c9dbb35 ("ubifs: Abort readdir upon error")
    Cc: stable@vger.kernel.org
    Signed-off-by: Richard Weinberger

    Richard Weinberger
     

20 Oct, 2016

2 commits

  • If UBIFS is facing an error while walking a directory, it reports this
    error and ubifs_readdir() returns the error code. But the VFS readdir
    logic does not make the getdents system call fail in all cases. When the
    readdir cursor indicates that more entries are present, the system call
    will just return and the libc wrapper will try again since it also
    knows that more entries are present.
    This causes the libc wrapper to busy loop for ever when a directory is
    corrupted on UBIFS.
    A common approach do deal with corrupted directory entries is
    skipping them by setting the cursor to the next entry. On UBIFS this
    approach is not possible since we cannot compute the next directory
    entry cursor position without reading the current entry. So all we can
    do is setting the cursor to the "no more entries" position and make
    getdents exit.

    Cc: stable@vger.kernel.org
    Signed-off-by: Richard Weinberger

    Richard Weinberger
     
  • Since ->rename2 is gone, rename ubifs_rename2() to ubifs_rename().

    Suggested-by: Linus Torvalds
    Signed-off-by: Richard Weinberger

    Richard Weinberger
     

12 Oct, 2016

1 commit

  • Pull UBI/UBIFS updates from Richard Weinberger:
    "This pull request contains:

    - Fixes for both UBI and UBIFS
    - overlayfs support (O_TMPFILE, RENAME_WHITEOUT/EXCHANGE)
    - Code refactoring for the upcoming MLC support"

    [ Ugh, we just got rid of the "rename2()" naming for the extended rename
    functionality. And this re-introduces it in ubifs with the cross-
    renaming and whiteout support.

    But rather than do any re-organizations in the merge itself, the
    naming can be cleaned up later ]

    * tag 'upstream-4.9-rc1' of git://git.infradead.org/linux-ubifs: (27 commits)
    UBIFS: improve function-level documentation
    ubifs: fix host xattr_len when changing xattr
    ubifs: Use move variable in ubifs_rename()
    ubifs: Implement RENAME_EXCHANGE
    ubifs: Implement RENAME_WHITEOUT
    ubifs: Implement O_TMPFILE
    ubi: Fix Fastmap's update_vol()
    ubi: Fix races around ubi_refill_pools()
    ubi: Deal with interrupted erasures in WL
    UBI: introduce the VID buffer concept
    UBI: hide EBA internals
    UBI: provide an helper to query LEB information
    UBI: provide an helper to check whether a LEB is mapped or not
    UBI: add an helper to check lnum validity
    UBI: simplify LEB write and atomic LEB change code
    UBI: simplify recover_peb() code
    UBI: move the global ech and vidh variables into struct ubi_attach_info
    UBI: provide helpers to allocate and free aeb elements
    UBI: fastmap: use ubi_io_{read, write}_data() instead of ubi_io_{read, write}()
    UBI: fastmap: use ubi_rb_for_each_entry() in unmap_peb()
    ...

    Linus Torvalds
     

11 Oct, 2016

1 commit

  • Pull more vfs updates from Al Viro:
    ">rename2() work from Miklos + current_time() from Deepa"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    fs: Replace current_fs_time() with current_time()
    fs: Replace CURRENT_TIME_SEC with current_time() for inode timestamps
    fs: Replace CURRENT_TIME with current_time() for inode timestamps
    fs: proc: Delete inode time initializations in proc_alloc_inode()
    vfs: Add current_time() api
    vfs: add note about i_op->rename changes to porting
    fs: rename "rename2" i_op to "rename"
    vfs: remove unused i_op->rename
    fs: make remaining filesystems use .rename2
    libfs: support RENAME_NOREPLACE in simple_rename()
    fs: support RENAME_NOREPLACE for local filesystems
    ncpfs: fix unused variable warning

    Linus Torvalds
     

08 Oct, 2016

1 commit


03 Oct, 2016

3 commits

  • Adds RENAME_EXCHANGE to UBIFS, the operation itself
    is completely disjunct from a regular rename() that's
    why we dispatch very early in ubifs_reaname().

    RENAME_EXCHANGE used by the renameat2() system call
    allows the caller to exchange two paths atomically.
    Both paths have to exist and have to be on the same
    filesystem.

    Signed-off-by: Richard Weinberger

    Richard Weinberger
     
  • Adds RENAME_WHITEOUT support to UBIFS, we implement
    it in the same way as ext4 and xfs do.
    For an overview of other ways to implement it please
    refere to commit 7dcf5c3e4527 ("xfs: add RENAME_WHITEOUT support").

    Signed-off-by: Richard Weinberger

    Richard Weinberger
     
  • This patchs adds O_TMPFILE support to UBIFS.
    A temp file is a reference to an unlinked inode, a user
    holding the reference can use it. As soon it is being closed
    all data vanishes.

    Signed-off-by: Richard Weinberger

    Richard Weinberger
     

27 Sep, 2016

2 commits

  • Generated patch:

    sed -i "s/\.rename2\t/\.rename\t\t/" `git grep -wl rename2`
    sed -i "s/\brename2\b/rename/g" `git grep -wl rename2`

    Signed-off-by: Miklos Szeredi

    Miklos Szeredi
     
  • This is trivial to do:

    - add flags argument to foo_rename()
    - check if flags doesn't have any other than RENAME_NOREPLACE
    - assign foo_rename() to .rename2 instead of .rename

    Filesystems converted:

    affs, bfs, exofs, ext2, hfs, hfsplus, jffs2, jfs, logfs, minix, msdos,
    nilfs2, omfs, reiserfs, sysvfs, ubifs, udf, ufs, vfat.

    Signed-off-by: Miklos Szeredi
    Acked-by: Boaz Harrosh
    Acked-by: Richard Weinberger
    Acked-by: Bob Copeland
    Acked-by: Jan Kara
    Cc: Theodore Ts'o
    Cc: Jaegeuk Kim
    Cc: OGAWA Hirofumi
    Cc: Mikulas Patocka
    Cc: David Woodhouse
    Cc: Dave Kleikamp
    Cc: Ryusuke Konishi
    Cc: Christoph Hellwig

    Miklos Szeredi
     

19 May, 2016

1 commit

  • Pull remaining vfs xattr work from Al Viro:
    "The rest of work.xattr (non-cifs conversions)"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    btrfs: Switch to generic xattr handlers
    ubifs: Switch to generic xattr handlers
    jfs: Switch to generic xattr handlers
    jfs: Clean up xattr name mapping
    gfs2: Switch to generic xattr handlers
    ceph: kill __ceph_removexattr()
    ceph: Switch to generic xattr handlers
    ceph: Get rid of d_find_alias in ceph_set_acl

    Linus Torvalds
     

18 May, 2016

1 commit

  • Ubifs internally uses special inodes for storing xattrs. Those inodes
    had NULL {get,set,remove}xattr inode operations before this change, so
    xattr operations on them would fail. The super block's s_xattr field
    would also apply to those special inodes. However, the inodes are not
    visible outside of ubifs, and so no xattr operations will ever be
    carried out on them anyway.

    Signed-off-by: Andreas Gruenbacher
    Reviewed-by: Richard Weinberger
    Signed-off-by: Al Viro

    Andreas Gruenbacher
     

09 May, 2016

1 commit


23 Jan, 2016

1 commit

  • parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
    inode_foo(inode) being mutex_foo(&inode->i_mutex).

    Please, use those for access to ->i_mutex; over the coming cycle
    ->i_mutex will become rwsem, with ->lookup() done with it held
    only shared.

    Signed-off-by: Al Viro

    Al Viro
     

07 Nov, 2015

3 commits

  • To make ubifs support atime flexily, this commit introduces
    a Kconfig option named as UBIFS_ATIME_SUPPORT.

    With UBIFS_ATIME_SUPPORT=n:
    ubifs keeps the full compatibility to no_atime from
    the start of ubifs.

    =================UBIFS_ATIME_SUPPORT=n=======================
    -o - no atime
    -o atime - no atime
    -o noatime - no atime
    -o relatime - no atime
    -o strictatime - no atime
    -o lazyatime - no atime

    With UBIFS_ATIME_SUPPORT=y:
    ubifs supports the atime same with other main stream
    file systems.
    =================UBIFS_ATIME_SUPPORT=y=======================
    -o - default behavior (relatime currently)
    -o atime - atime support
    -o noatime - no atime support
    -o relatime - relative atime support
    -o strictatime - strict atime support
    -o lazyatime - lazy atime support

    Signed-off-by: Dongsheng Yang
    Reviewed-by: Richard Weinberger
    Signed-off-by: Richard Weinberger

    Dongsheng Yang
     
  • If ubifs_tnc_next_ent() returns something else than -ENOENT
    we leak file->private_data.

    Signed-off-by: Richard Weinberger
    Reviewed-by: David Gstir

    Richard Weinberger
     
  • As currently new_valid_dev always returns 1, so new_valid_dev check is not
    needed, remove it.

    Signed-off-by: Yaowei Bai
    Reviewed-by: Richard Weinberger
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: Richard Weinberger

    Yaowei Bai
     

11 May, 2015

1 commit


27 Apr, 2015

1 commit

  • Pull fourth vfs update from Al Viro:
    "d_inode() annotations from David Howells (sat in for-next since before
    the beginning of merge window) + four assorted fixes"

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    RCU pathwalk breakage when running into a symlink overmounting something
    fix I_DIO_WAKEUP definition
    direct-io: only inc/dec inode->i_dio_count for file systems
    fs/9p: fix readdir()
    VFS: assorted d_backing_inode() annotations
    VFS: fs/inode.c helpers: d_inode() annotations
    VFS: fs/cachefiles: d_backing_inode() annotations
    VFS: fs library helpers: d_inode() annotations
    VFS: assorted weird filesystems: d_inode() annotations
    VFS: normal filesystems (and lustre): d_inode() annotations
    VFS: security/: d_inode() annotations
    VFS: security/: d_backing_inode() annotations
    VFS: net/: d_inode() annotations
    VFS: net/unix: d_backing_inode() annotations
    VFS: kernel/: d_inode() annotations
    VFS: audit: d_backing_inode() annotations
    VFS: Fix up some ->d_inode accesses in the chelsio driver
    VFS: Cachefiles should perform fs modifications on the top layer only
    VFS: AF_UNIX sockets should call mknod on the top layer only

    Linus Torvalds
     

16 Apr, 2015

1 commit


13 Apr, 2015

1 commit

  • The INUM_WATERMARK is a unsigned 32bit value, `%d' prints it as negatave:
    [ 103.682255] UBIFS warning (ubi0:0 pid 691): ubifs_new_inode: running out of inode numbers (current 122763, max -256)

    Fix it as:
    [ 154.422940] UBIFS warning (ubi0:0 pid 688): ubifs_new_inode: running out of inode numbers (current 122765, max 4294967040)

    Signed-off-by: Sheng Yong
    Signed-off-by: Artem Bityutskiy

    Sheng Yong
     

25 Mar, 2015

2 commits

  • In the case where we have more than one volumes on different UBI
    devices, it may be not that easy to tell which volume prints the
    messages. Add ubi number and volume id in ubifs_msg/warn/error
    to help debug. These two values are passed by struct ubifs_info.

    For those where ubifs_info is not initialized yet, ubifs_* is
    replaced by pr_*. For those where ubifs_info is not avaliable,
    ubifs_info is passed to the calling function as a const parameter.

    The output looks like,

    [ 95.444879] UBIFS (ubi0:1): background thread "ubifs_bgt0_1" started, PID 696
    [ 95.484688] UBIFS (ubi0:1): UBIFS: mounted UBI device 0, volume 1, name "test1"
    [ 95.484694] UBIFS (ubi0:1): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
    [ 95.484699] UBIFS (ubi0:1): FS size: 30220288 bytes (28 MiB, 238 LEBs), journal size 1523712 bytes (1 MiB, 12 LEBs)
    [ 95.484703] UBIFS (ubi0:1): reserved for root: 1427378 bytes (1393 KiB)
    [ 95.484709] UBIFS (ubi0:1): media format: w4/r0 (latest is w4/r0), UUID 40DFFC0E-70BE-4193-8905-F7D6DFE60B17, small LPT model
    [ 95.489875] UBIFS (ubi1:0): background thread "ubifs_bgt1_0" started, PID 699
    [ 95.529713] UBIFS (ubi1:0): UBIFS: mounted UBI device 1, volume 0, name "test2"
    [ 95.529718] UBIFS (ubi1:0): LEB size: 126976 bytes (124 KiB), min./max. I/O unit sizes: 2048 bytes/2048 bytes
    [ 95.529724] UBIFS (ubi1:0): FS size: 19808256 bytes (18 MiB, 156 LEBs), journal size 1015809 bytes (0 MiB, 8 LEBs)
    [ 95.529727] UBIFS (ubi1:0): reserved for root: 935592 bytes (913 KiB)
    [ 95.529733] UBIFS (ubi1:0): media format: w4/r0 (latest is w4/r0), UUID EEB7779D-F419-4CA9-811B-831CAC7233D4, small LPT model

    [ 954.264767] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node type (255 but expected 6)
    [ 954.367030] UBIFS error (ubi1:0 pid 756): ubifs_read_node: bad node at LEB 0:0, LEB mapping status 1

    Signed-off-by: Sheng Yong
    Signed-off-by: Artem Bityutskiy

    Sheng Yong
     
  • When ubifs_init_security() fails, 'ui_mutex' is incorrectly
    unlocked and incorrectly restores 'i_size'. Fix this.

    Signed-off-by: Taesoo Kim
    Fixes: d7f0b70d30ff ("UBIFS: Add security.* XATTR support for the UBIFS")
    Reviewed-by: Ben Shelton
    Signed-off-by: Uwe Kleine-König
    Signed-off-by: Artem Bityutskiy

    Taesoo Kim
     

16 Feb, 2015

1 commit

  • Pull UBI and UBIFS updates from Richard Weinberger:
    - cleanups and bug fixes all over UBI and UBIFS
    - block-mq support for UBI Block
    - UBI volumes can now be renamed while they are in use
    - security.* XATTR support for UBIFS
    - a maintainer update

    * 'for-linus-v3.20' of git://git.infradead.org/linux-ubifs:
    UBI: block: Fix checking for NULL instead of IS_ERR()
    UBI: block: Continue creating ubiblocks after an initialization error
    UBIFS: return -EINVAL if log head is empty
    UBI: Block: Explain usage of blk_rq_map_sg()
    UBI: fix soft lockup in ubi_check_volume()
    UBI: Fastmap: Care about the protection queue
    UBIFS: add a couple of extra asserts
    UBI: do propagate positive error codes up
    UBI: clean-up printing helpers
    UBI: extend UBI layer debug/messaging capabilities - cosmetics
    UBIFS: add ubifs_err() to print error reason
    UBIFS: Add security.* XATTR support for the UBIFS
    UBIFS: Add xattr support for symlinks
    UBI: Block: Add blk-mq support
    UBI: Add initial support for scatter gather
    UBI: rename_volumes: Use UBI_METAONLY
    UBI: Implement UBI_METAONLY
    Add myself as UBI co-maintainer

    Linus Torvalds
     

28 Jan, 2015

1 commit

  • Artem: rename static functions so that they do not use the "ubifs_" prefix - we
    only use this prefix for non-static functions.
    Artem: remove few junk white-space changes in file.c

    Signed-off-by: Subodh Nijsure
    Signed-off-by: Marc Kleine-Budde
    Signed-off-by: Ben Shelton
    Acked-by: Brad Mouring
    Acked-by: Terry Wilcox
    Acked-by: Gratian Crisan
    Signed-off-by: Artem Bityutskiy

    Subodh Nijsure
     

21 Jan, 2015

1 commit

  • Now that we never use the backing_dev_info pointer in struct address_space
    we can simply remove it and save 4 to 8 bytes in every inode.

    Signed-off-by: Christoph Hellwig
    Acked-by: Ryusuke Konishi
    Reviewed-by: Tejun Heo
    Reviewed-by: Jan Kara
    Signed-off-by: Jens Axboe

    Christoph Hellwig
     

25 Oct, 2013

1 commit


29 Jun, 2013

3 commits

  • Signed-off-by: Al Viro

    Al Viro
     
  • Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
    mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
    in the middle of 'ubifs_readdir()'.

    This means that 'file->private_data' can be freed while 'ubifs_readdir()' uses
    it, and this is a very bad bug: not only 'ubifs_readdir()' can return garbage,
    but this may corrupt memory and lead to all kinds of problems like crashes an
    security holes.

    This patch fixes the problem by using the 'file->f_version' field, which
    '->llseek()' always unconditionally sets to zero. We set it to 1 in
    'ubifs_readdir()' and whenever we detect that it became 0, we know there was a
    seek and it is time to clear the state saved in 'file->private_data'.

    I tested this patch by writing a user-space program which runds readdir and
    seek in parallell. I could easily crash the kernel without these patches, but
    could not crash it with these patches.

    Cc: stable@vger.kernel.org
    Reported-by: Al Viro
    Tested-by: Artem Bityutskiy
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: Al Viro

    Artem Bityutskiy
     
  • Al Viro pointed me to the fact that '->readdir()' and '->llseek()' have no
    mutual exclusion, which means the 'ubifs_dir_llseek()' can be run while we are
    in the middle of 'ubifs_readdir()'.

    First of all, this means that 'file->private_data' can be freed while
    'ubifs_readdir()' uses it. But this particular patch does not fix the problem.
    This patch is only a preparation, and the fix will follow next.

    In this patch we make 'ubifs_readdir()' stop using 'file->f_pos' directly,
    because 'file->f_pos' can be changed by '->llseek()' at any point. This may
    lead 'ubifs_readdir()' to returning inconsistent data: directory entry names
    may correspond to incorrect file positions.

    So here we introduce a local variable 'pos', read 'file->f_pose' once at very
    the beginning, and then stick to 'pos'. The result of this is that when
    'ubifs_dir_llseek()' changes 'file->f_pos' while we are in the middle of
    'ubifs_readdir()', the latter "wins".

    Cc: stable@vger.kernel.org
    Reported-by: Al Viro
    Tested-by: Artem Bityutskiy
    Signed-off-by: Artem Bityutskiy
    Signed-off-by: Al Viro

    Artem Bityutskiy
     

23 Feb, 2013

1 commit


18 Dec, 2012

1 commit


31 Aug, 2012

1 commit


24 Jul, 2012

1 commit

  • Pull UBIFS updates from Artem Bityutskiy:

    - Added another debugfs knob for forcing UBIFS R/O mode without
    flushing caches or finishing commit or any other I/O operation. I've
    originally added this knob in order to reproduce the free space fixup
    bug (see commit c6727932cfdb: "UBIFS: fix a bug in empty space
    fix-up") on nandsim.

    Without this knob I would have to do real power-cuts, which would
    make debugging much harder. Then I've decided to keep this knob
    because it is also useful for UBIFS power-cut recovery end
    error-paths testing.

    - Well-spotted fix from Julia. This bug did not cause real troubles
    for UBIFS, but nevertheless it could cause issues for someone trying
    to modify the orphans handling code. Kudos to coccinelle!

    - Minor cleanups.

    * tag 'upstream-3.6-rc1' of git://git.infradead.org/linux-ubifs:
    UBIFS: remove invalid reference to list iterator variable
    UBIFS: simplify reply code a bit
    UBIFS: add debugfs knob to switch to R/O mode
    UBIFS: fix compilation warning

    Linus Torvalds
     

20 Jul, 2012

1 commit

  • Fix the following compilation warning:

    fs/ubifs/dir.c: In function 'ubifs_rename':
    fs/ubifs/dir.c:972:15: warning: 'saved_nlink' may be used uninitialized
    in this function

    Use the 'uninitialized_var()' macro to get rid of this false-positive.

    Artem: massaged the patch a bit.

    Signed-off-by: Alexandre Pereira da Silva
    Signed-off-by: Artem Bityutskiy

    Alexandre Pereira da Silva
     

14 Jul, 2012

2 commits

  • boolean "does it have to be exclusive?" flag is passed instead;
    Local filesystem should just ignore it - the object is guaranteed
    not to be there yet.

    Signed-off-by: Al Viro

    Al Viro
     
  • Just the flags; only NFS cares even about that, but there are
    legitimate uses for such argument. And getting rid of that
    completely would require splitting ->lookup() into a couple
    of methods (at least), so let's leave that alone for now...

    Signed-off-by: Al Viro

    Al Viro