24 Feb, 2020

2 commits

  • [ Upstream commit a4a8b99ec819ca60b49dc582a4287ef03411f117 ]

    Free space on filesystems with metadata or virtual partition maps
    currently gets misreported. This is because these partitions are just
    remapped onto underlying real partitions from which keep track of free
    blocks. Take this remapping into account when counting free blocks as
    well.

    Reviewed-by: Pali Rohár
    Reported-by: Pali Rohár
    Signed-off-by: Jan Kara
    Signed-off-by: Sasha Levin

    Jan Kara
     
  • [ Upstream commit 15fb05fd286ac57a0802d71624daeb5c1c2d5b07 ]

    UDF 2.60 standard states in section 2.2.14.2:

    A partition with Access Type 3 (rewritable) shall define a Freed
    Space Bitmap or a Freed Space Table, see 2.3.3. All other partitions
    shall not define a Freed Space Bitmap or a Freed Space Table.

    Rewritable partitions are used on media that require some form of
    preprocessing before re-writing data (for example legacy MO). Such
    partitions shall use Access Type 3.

    Overwritable partitions are used on media that do not require
    preprocessing before overwriting data (for example: CD-RW, DVD-RW,
    DVD+RW, DVD-RAM, BD-RE, HD DVD-Rewritable). Such partitions shall
    use Access Type 4.

    however older versions of the standard didn't have this wording and
    there are tools out there that create UDF filesystems with rewritable
    partitions but that don't contain a Freed Space Bitmap or a Freed Space
    Table on media that does not require pre-processing before overwriting a
    block. So instead of forcing media with rewritable partition read-only,
    base this decision on presence of a Freed Space Bitmap or a Freed Space
    Table.

    Reported-by: Pali Rohár
    Reviewed-by: Pali Rohár
    Fixes: b085fbe2ef7f ("udf: Fix crash during mount")
    Link: https://lore.kernel.org/linux-fsdevel/20200112144735.hj2emsoy4uwsouxz@pali
    Signed-off-by: Jan Kara
    Signed-off-by: Sasha Levin

    Jan Kara
     

05 Sep, 2019

3 commits

  • The brelse() function tests whether its argument is NULL
    and then returns immediately.
    Thus the test around the call is not needed.

    This issue was detected by using the Coccinelle software.

    Signed-off-by: Markus Elfring
    Link: https://lore.kernel.org/r/a254c1d1-0109-ab51-c67a-edc5c1c4b4cd@web.de
    Signed-off-by: Jan Kara

    Markus Elfring
     
  • Move some functions to make forward declarations unnecessary.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • OSTA UDF standard defines that domain identifier in logical volume
    descriptor and file set descriptor should contain a particular string
    and the identifier suffix contains flags possibly making media
    write-protected. Verify these constraints and allow only read-only mount
    if they are not met.

    Tested-by: Steven J. Magnani
    Reviewed-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Jan Kara
     

27 Aug, 2019

1 commit

  • Windows presents files created within Linux as read-only, even when
    permissions in Linux indicate the file should be writable.

    UDF defines a slightly different set of basic file permissions than Linux.
    Specifically, UDF has "delete" and "change attribute" permissions for each
    access class (user/group/other). Linux has no equivalents for these.

    When the Linux UDF driver creates a file (or directory), no UDF delete or
    change attribute permissions are granted. The lack of delete permission
    appears to cause Windows to mark an item read-only when its permissions
    otherwise indicate that it should be read-write.

    Fix this by having UDF delete permissions track Linux write permissions.
    Also grant UDF change attribute permission to the owner when creating a
    new inode.

    Reported by: Ty Young
    Signed-off-by: Steven J. Magnani
    Link: https://lore.kernel.org/r/20190827121359.9954-1-steve@digidescorp.com
    Signed-off-by: Jan Kara

    Steven J. Magnani
     

26 Aug, 2019

2 commits

  • Instead of relying on UDFFS_DEBUG define for debug printing, just use
    standard pr_debug() prints and rely on CONFIG_DYNAMIC_DEBUG
    infrastructure for enabling or disabling prints.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Windows is capable of creating UDF files having named streams.
    One example is the "Zone.Identifier" stream attached automatically
    to files downloaded from a network. See:
    https://msdn.microsoft.com/en-us/library/dn392609.aspx

    Modification of a file having one or more named streams in Linux causes
    the stream directory to become detached from the file, essentially leaking
    all blocks pertaining to the file's streams.

    Fix by saving off information about an inode's streams when reading it,
    for later use when its on-disk data is updated.

    Link: https://lore.kernel.org/r/20190814125002.10869-1-steve@digidescorp.com
    Signed-off-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Steven J. Magnani
     

01 Aug, 2019

1 commit

  • The UDF bitmap allocation code assumes that a recorded
    Unallocated Space Bitmap is compliant with ECMA-167 4/13,
    which requires that pad bytes between the end of the bitmap
    and the end of a logical block are all zero.

    When a recorded bitmap does not comply with this requirement,
    for example one padded with FF to the block boundary instead
    of 00, the allocator may "allocate" blocks that are outside
    the UDF partition extent. This can result in UDF volume descriptors
    being overwritten by file data or by partition-level descriptors,
    and in extreme cases, even in scribbling on a subsequent disk partition.

    Add a check that the block selected by the allocator actually
    resides within the UDF partition extent.

    Signed-off-by: Steven J. Magnani

    Link: https://lore.kernel.org/r/1564341552-129750-1-git-send-email-steve@digidescorp.com
    Signed-off-by: Jan Kara

    Steve Magnani
     

31 Jul, 2019

2 commits

  • Some UDF creators (specifically Microsoft, but perhaps others) mishandle
    the ECMA-167 corner case that requires descriptors within a Volume
    Recognition Sequence to be placed at 4096-byte intervals on media where
    the block size is 4K. Instead, the descriptors are placed at the 2048-
    byte interval mandated for media with smaller blocks. This nonconformity
    currently prevents Linux from recognizing the filesystem as UDF.

    Modify the driver to tolerate a misformatted VRS on 4K media.

    [JK: Simplified descriptor checking]
    Signed-off-by: Steven J. Magnani
    Tested-by: Steven J. Magnani
    Link: https://lore.kernel.org/r/20190711133852.16887-2-steve@digidescorp.com
    Signed-off-by: Jan Kara

    Steven J. Magnani
     
  • Extract code that parses a Volume Recognition Sequence descriptor
    (component), in preparation for calling it twice against different
    locations in a block.

    Signed-off-by: Steven J. Magnani
    Link: https://lore.kernel.org/r/20190711133852.16887-1-steve@digidescorp.com
    Signed-off-by: Jan Kara

    Steven J. Magnani
     

11 Jul, 2019

1 commit

  • Pull ext2, udf and quota updates from Jan Kara:

    - some ext2 fixes and cleanups

    - a fix of udf bug when extending files

    - a fix of quota Q_XGETQSTAT[V] handling

    * tag 'for_v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    udf: Fix incorrect final NOT_ALLOCATED (hole) extent length
    ext2: Use kmemdup rather than duplicating its implementation
    quota: honor quota type in Q_XGETQSTAT[V] calls
    ext2: Always brelse bh on failure in ext2_iget()
    ext2: add missing brelse() in ext2_iget()
    ext2: Fix a typo in ext2_getattr argument
    ext2: fix a typo in comment
    ext2: add missing brelse() in ext2_new_inode()
    ext2: optimize ext2_xattr_get()
    ext2: introduce new helper for xattr entry comparison
    ext2: merge xattr next entry check to ext2_xattr_entry_valid()
    ext2: code cleanup for ext2_preread_inode()
    ext2: code cleanup by using test_opt() and clear_opt()
    doc: ext2: update description of quota options for ext2
    ext2: Strengthen xattr block checks
    ext2: Merge loops in ext2_xattr_set()
    ext2: introduce helper for xattr entry validation
    ext2: introduce helper for xattr header validation
    quota: add dqi_dirty_list description to comment of Dquot List Management

    Linus Torvalds
     

10 Jul, 2019

1 commit

  • In some cases, using the 'truncate' command to extend a UDF file results
    in a mismatch between the length of the file's extents (specifically, due
    to incorrect length of the final NOT_ALLOCATED extent) and the information
    (file) length. The discrepancy can prevent other operating systems
    (i.e., Windows 10) from opening the file.

    Two particular errors have been observed when extending a file:

    1. The final extent is larger than it should be, having been rounded up
    to a multiple of the block size.

    B. The final extent is not shorter than it should be, due to not having
    been updated when the file's information length was increased.

    [JK: simplified udf_do_extend_final_block(), fixed up some types]

    Fixes: 2c948b3f86e5 ("udf: Avoid IO in udf_clear_inode")
    CC: stable@vger.kernel.org
    Signed-off-by: Steven J. Magnani
    Link: https://lore.kernel.org/r/1561948775-5878-1-git-send-email-steve@digidescorp.com
    Signed-off-by: Jan Kara

    Steven J. Magnani
     

21 May, 2019

1 commit


14 May, 2019

1 commit

  • Pull misc filesystem updates from Jan Kara:
    "A couple of small bugfixes and cleanups for quota, udf, ext2, and
    reiserfs"

    * tag 'fs_for_v5.2-rc1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    quota: check time limit when back out space/inode change
    fs/quota: erase unused but set variable warning
    quota: fix wrong indentation
    udf: fix an uninitialized read bug and remove dead code
    fs/reiserfs/journal.c: Make remove_journal_hash static
    quota: remove trailing whitespaces
    quota: code cleanup for __dquot_alloc_space()
    ext2: Adjust the comment of function ext2_alloc_branch
    udf: Explain handling of load_nls() failure

    Linus Torvalds
     

02 May, 2019

1 commit


17 Apr, 2019

1 commit

  • In udf_lookup(), the pointer 'fi' is a local variable initialized by the
    return value of the function call udf_find_entry(). However, if the macro
    'UDF_RECOVERY' is defined, this variable will become uninitialized if the
    else branch is not taken, which can potentially cause incorrect results in
    the following execution.

    To fix this issue, this patch drops the whole code in the ifdef
    'UDF_RECOVERY' region, as it is dead code.

    Signed-off-by: Wenwen Wang
    Signed-off-by: Jan Kara

    Wenwen Wang
     

26 Mar, 2019

1 commit


18 Mar, 2019

2 commits

  • Make udf_truncate_extents() properly propagate errors to its callers and
    let udf_setsize() handle the error properly as well. This lets userspace
    know in case there's some error when truncating blocks.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • When truncate(2) hits IO error when reading indirect extent block the
    code just bugs with:

    kernel BUG at linux-4.15.0/fs/udf/truncate.c:249!
    ...

    Fix the problem by bailing out cleanly in case of IO error.

    CC: stable@vger.kernel.org
    Reported-by: jean-luc malet
    Signed-off-by: Jan Kara

    Jan Kara
     

22 Feb, 2019

1 commit

  • The check if (bh) in udf_sync_fs() is pointless as we cannot have
    sbi->s_lvid_dirty and !sbi->s_lvid_bh (as already asserted by
    udf_updated_lvid()). So just drop the pointless check.

    Reviewed-by: Steven J. Magnani
    Reported-by: Colin Ian King
    Signed-off-by: Jan Kara

    Jan Kara
     

12 Feb, 2019

1 commit

  • Refuse to mount a volume read-write without a coherent Logical Volume
    Integrity Descriptor, because we can't generate truly unique IDs without
    one.

    This fixes a bug where all inodes created on a UDF filesystem following
    mount without a coherent LVID are assigned unique ID 0 which can then
    confuse other UDF implementations.

    Signed-off-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Steve Magnani
     

11 Feb, 2019

2 commits

  • Make sure the CRC and tag checksum of the Logical Volume Integrity
    Descriptor are valid before the structure is written out to disk.
    Otherwise, unless the filesystem is unmounted gracefully, the on-disk
    LVID will be invalid - which is unnecessary filesystem damage.

    Signed-off-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Steve Magnani
     
  • Centralize timestamping and CRC/checksum updating of the in-core
    Logical Volume Integrity Descriptor, in preparation for adding
    a third site where this functionality is needed.

    Signed-off-by: Steven J. Magnani
    Signed-off-by: Jan Kara

    Steve Magnani
     

28 Dec, 2018

1 commit

  • Pull ext2, udf, and quota update from Jan Kara:
    "Some ext2 cleanups, a fix for UDF crash on corrupted media, and one
    quota locking fix"

    * tag 'fs_for_4.21-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
    quota: Lock s_umount in exclusive mode for Q_XQUOTA{ON,OFF} quotactls.
    udf: Fix BUG on corrupted inode
    ext2: change reusable parameter to true when calling mb_cache_entry_create()
    ext2: remove redundant condition check
    ext2: avoid unnecessary operation in ext2_error()

    Linus Torvalds
     

12 Dec, 2018

1 commit

  • When inode is corrupted so that extent type is invalid, some functions
    (such as udf_truncate_extents()) will just BUG. Check that extent type
    is valid when loading the inode to memory.

    Reported-by: Anatoly Trosinenko
    Signed-off-by: Jan Kara

    Jan Kara
     

19 Nov, 2018

1 commit

  • Commit c26f6c615788 ("udf: Fix conversion of 'dstring' fields to UTF8")
    started to be more strict when checking whether converted strings are
    properly formatted. Sudip reports that there are DVDs where the volume
    identification string is actually too long - UDF reports:

    [ 632.309320] UDF-fs: incorrect dstring lengths (32/32)

    during mount and fails the mount. This is mostly harmless failure as we
    don't need volume identification (and even less volume set
    identification) for anything. So just truncate the volume identification
    string if it is too long and replace it with 'Invalid' if we just cannot
    convert it for other reasons. This keeps slightly incorrect media still
    mountable.

    CC: stable@vger.kernel.org
    Fixes: c26f6c615788 ("udf: Fix conversion of 'dstring' fields to UTF8")
    Reported-and-tested-by: Sudip Mukherjee
    Signed-off-by: Jan Kara

    Jan Kara
     

07 Sep, 2018

4 commits

  • Drop pack pragma. The header file defines only in-memory structures.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • We don't support Free Space Table and Free Space Bitmap as specified by
    UDF standard for writing as we don't support erasing blocks before
    overwriting them. Just drop the handling of these structures as
    partition descriptor checking code already makes sure such filesystems
    can be mounted only read-only.

    Signed-off-by: Jan Kara

    Jan Kara
     
  • Fix a crash during an attempt to mount a filesystem that has both
    Unallocated Space Table and Unallocated Space Bitmap. Such filesystem
    actually violates the UDF standard so we just have to properly detect
    such situation and refuse to mount such filesystem read-write. When we
    are at it, verify also other constraints on the allocation information
    mandated by the standard.

    Reported-by: Anatoly Trosinenko
    Signed-off-by: Jan Kara

    Jan Kara
     
  • There are certain filesystem features which we support for reading but
    not for writing. We properly refuse to mount such filesystems read-write
    however for some features (such as read-only partitions), we don't check
    for these features when remounting the filesystem from read-only to
    read-write. Thus such filesystems could be remounted read-write leading
    to strange behavior (most likely crashes).

    Fix the problem by marking in superblock whether the filesystem has some
    features that are supported in read-only mode and check this flag during
    remount.

    Signed-off-by: Jan Kara

    Jan Kara
     

03 Sep, 2018

1 commit

  • Variables group_start and nr_groups are being assigned but are never used
    hence they are redundant and can be removed.

    Cleans up clang warning:
    variable 'group_start' set but not used [-Wunused-but-set-variable]
    variable 'nr_groups' set but not used [-Wunused-but-set-variable]

    Signed-off-by: Colin Ian King
    Signed-off-by: Jan Kara

    Colin Ian King
     

24 Aug, 2018

2 commits

  • Win7 is creating UDF filesystems with single partition with number 8192.
    Current partition descriptor scanning code does not handle this well as
    it incorrectly assumes that partition numbers will form mostly contiguous
    space of small numbers. This results in unmountable media due to errors
    like:

    UDF-fs: error (device dm-1): udf_read_tagged: tag version 0x0000 != 0x0002 || 0x0003, block 0
    UDF-fs: warning (device dm-1): udf_fill_super: No fileset found

    Fix the problem by handling partition descriptors in a way that sparse
    partition numbering does not matter.

    Reported-and-tested-by: jean-luc malet
    CC: stable@vger.kernel.org
    Fixes: 7b78fd02fb19530fd101ae137a1f46aa466d9bb6
    Signed-off-by: Jan Kara

    Jan Kara
     
  • Remove dead code and slightly simplify code in udf_find_fileset().

    Signed-off-by: Jan Kara

    Jan Kara
     

18 Aug, 2018

1 commit


14 Aug, 2018

1 commit

  • Pull vfs icache updates from Al Viro:

    - NFS mkdir/open_by_handle race fix

    - analogous solution for FUSE, replacing the one currently in mainline

    - new primitive to be used when discarding halfway set up inodes on
    failed object creation; gives sane warranties re icache lookups not
    returning such doomed by still not freed inodes. A bunch of
    filesystems switched to that animal.

    - Miklos' fix for last cycle regression in iget5_locked(); -stable will
    need a slightly different variant, unfortunately.

    - misc bits and pieces around things icache-related (in adfs and jfs).

    * 'work.mkdir' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
    jfs: don't bother with make_bad_inode() in ialloc()
    adfs: don't put inodes into icache
    new helper: inode_fake_hash()
    vfs: don't evict uninitialized inode
    jfs: switch to discard_new_inode()
    ext2: make sure that partially set up inodes won't be returned by ext2_iget()
    udf: switch to discard_new_inode()
    ufs: switch to discard_new_inode()
    btrfs: switch to discard_new_inode()
    new primitive: discard_new_inode()
    kill d_instantiate_no_diralias()
    nfs_instantiate(): prevent multiple aliases for directory inode

    Linus Torvalds
     

04 Aug, 2018

1 commit


27 Jun, 2018

1 commit

  • The VFS structures are finally converted to always use 64-bit timestamps,
    and this file system can represent a long range of on-disk timestamps
    already, so now let's fit in the missing bits for udf.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Jan Kara

    Arnd Bergmann
     

20 Jun, 2018

2 commits