1. 21 7月, 2016 1 次提交
  2. 08 6月, 2016 1 次提交
  3. 19 5月, 2016 3 次提交
    • A
      udf: Use correct partition reference number for metadata · 7888824b
      Alden Tondettar 提交于
      UDF/OSTA terminology is confusing. Partition Numbers (PNs) are arbitrary
      16-bit values, one for each physical partition in the volume.  Partition
      Reference Numbers (PRNs) are indices into the the Partition Map Table
      and do not necessarily equal the PN of the mapped partition.
      
      The current metadata code mistakenly uses the PN instead of the PRN when
      mapping metadata blocks to physical/sparable blocks.  Windows-created
      UDF 2.5 discs for some reason use large, arbitrary PNs, resulting in
      mount failure and KASAN read warnings in udf_read_inode().
      
      For example, a NetBSD UDF 2.5 partition might look like this:
      
      PRN PN Type
      --- -- ----
        0  0 Sparable
        1  0 Metadata
      
      Since PRN == PN, we are fine.
      
      But Windows could gives us:
      
      PRN PN   Type
      --- ---- ----
        0 8192 Sparable
        1 8192 Metadata
      
      So udf_read_inode() will start out by checking the partition length in
      sbi->s_partmaps[8192], which is obviously out of bounds.
      
      Fix this by creating a new field (s_phys_partition_ref) in struct
      udf_meta_data, referencing whatever physical or sparable map has the
      same partition number as the metadata partition.
      
      [JK: Add comment about s_phys_partition_ref, change its name]
      Signed-off-by: NAlden Tondettar <alden.tondettar@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      7888824b
    • A
      udf: Use IS_ERR when loading metadata mirror file entry · 3743a03e
      Alden Tondettar 提交于
      Currently when udf_get_pblock_meta25() fails to map a block using the
      primary metadata file, it will attempt to load the mirror file entry by
      calling udf_find_metadata_inode_efe().  That function will return a ERR_PTR
      if it fails, but the return value is only checked against NULL.  Test the
      return value using IS_ERR() and change it to NULL if needed.
      Signed-off-by: NAlden Tondettar <alden.tondettar@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      3743a03e
    • A
      udf: Don't BUG on missing metadata partition descriptor · 585d7000
      Alden Tondettar 提交于
      Currently, if a metadata partition map is missing its partition descriptor,
      then udf_get_pblock_meta25() will BUG() out the first time it is called.
      This is rather drastic for a corrupted filesystem, so just treat this case
      as an invalid mapping instead.
      Signed-off-by: NAlden Tondettar <alden.tondettar@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      585d7000
  4. 09 5月, 2016 1 次提交
  5. 02 5月, 2016 3 次提交
  6. 28 4月, 2016 1 次提交
  7. 26 4月, 2016 1 次提交
    • A
      udf: Prevent stack overflow on corrupted filesystem mount · a47241cd
      Alden Tondettar 提交于
      Presently, a corrupted or malicious UDF filesystem containing a very large
      number (or cycle) of Logical Volume Integrity Descriptor extent
      indirections may trigger a stack overflow and kernel panic in
      udf_load_logicalvolint() on mount.
      
      Replace the unnecessary recursion in udf_load_logicalvolint() with
      simple iteration. Set an arbitrary limit of 1000 indirections (which would
      have almost certainly overflowed the stack without this fix), and treat
      such cases as if there were no LVID.
      Signed-off-by: NAlden Tondettar <alden.tondettar@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      a47241cd
  8. 25 4月, 2016 1 次提交
    • A
      udf: Fix conversion of 'dstring' fields to UTF8 · c26f6c61
      Andrew Gabbasov 提交于
      Commit 9293fcfb
      ("udf: Remove struct ustr as non-needed intermediate storage"),
      while getting rid of 'struct ustr', does not take any special care
      of 'dstring' fields and effectively use fixed field length instead
      of actual string length, encoded in the last byte of the field.
      
      Also, commit 484a10f4
      ("udf: Merge linux specific translation into CS0 conversion function")
      introduced checking of the length of the string being converted,
      requiring proper alignment to number of bytes constituing each
      character.
      
      The UDF volume identifier is represented as a 32-bytes 'dstring',
      and needs to be converted from CS0 to UTF8, while mounting UDF
      filesystem. The changes in mentioned commits can in some cases
      lead to incorrect handling of volume identifier:
      - if the actual string in 'dstring' is of maximal length and
      does not have zero bytes separating it from dstring encoded
      length in last byte, that last byte may be included in conversion,
      thus making incorrect resulting string;
      - if the identifier is encoded with 2-bytes characters (compression
      code is 16), the length of 31 bytes (32 bytes of field length minus
      1 byte of compression code), taken as the string length, is reported
      as an incorrect (unaligned) length, and the conversion fails, which
      in its turn leads to volume mounting failure.
      
      This patch introduces handling of 'dstring' encoded length field
      in udf_CS0toUTF8 function, that is used in all and only cases
      when 'dstring' fields are converted. Currently these cases are
      processing of Volume Identifier and Volume Set Identifier fields.
      The function is also renamed to udf_dstrCS0toUTF8 to distinctly
      indicate that it handles 'dstring' input.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      c26f6c61
  9. 11 4月, 2016 1 次提交
  10. 05 4月, 2016 1 次提交
    • K
      mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros · 09cbfeaf
      Kirill A. Shutemov 提交于
      PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time
      ago with promise that one day it will be possible to implement page
      cache with bigger chunks than PAGE_SIZE.
      
      This promise never materialized.  And unlikely will.
      
      We have many places where PAGE_CACHE_SIZE assumed to be equal to
      PAGE_SIZE.  And it's constant source of confusion on whether
      PAGE_CACHE_* or PAGE_* constant should be used in a particular case,
      especially on the border between fs and mm.
      
      Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much
      breakage to be doable.
      
      Let's stop pretending that pages in page cache are special.  They are
      not.
      
      The changes are pretty straight-forward:
      
       - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
      
       - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>;
      
       - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN};
      
       - page_cache_get() -> get_page();
      
       - page_cache_release() -> put_page();
      
      This patch contains automated changes generated with coccinelle using
      script below.  For some reason, coccinelle doesn't patch header files.
      I've called spatch for them manually.
      
      The only adjustment after coccinelle is revert of changes to
      PAGE_CAHCE_ALIGN definition: we are going to drop it later.
      
      There are few places in the code where coccinelle didn't reach.  I'll
      fix them manually in a separate patch.  Comments and documentation also
      will be addressed with the separate patch.
      
      virtual patch
      
      @@
      expression E;
      @@
      - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT)
      + E
      
      @@
      expression E;
      @@
      - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT)
      + E
      
      @@
      @@
      - PAGE_CACHE_SHIFT
      + PAGE_SHIFT
      
      @@
      @@
      - PAGE_CACHE_SIZE
      + PAGE_SIZE
      
      @@
      @@
      - PAGE_CACHE_MASK
      + PAGE_MASK
      
      @@
      expression E;
      @@
      - PAGE_CACHE_ALIGN(E)
      + PAGE_ALIGN(E)
      
      @@
      expression E;
      @@
      - page_cache_get(E)
      + get_page(E)
      
      @@
      expression E;
      @@
      - page_cache_release(E)
      + put_page(E)
      Signed-off-by: NKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      09cbfeaf
  11. 09 2月, 2016 6 次提交
    • A
      udf: Merge linux specific translation into CS0 conversion function · 484a10f4
      Andrew Gabbasov 提交于
      Current implementation of udf_translate_to_linux function does not
      support multi-bytes characters at all: it counts bytes while calculating
      extension length, when inserting CRC inside the name it doesn't
      take into account inter-character boundaries and can break into
      the middle of the character.
      
      The most efficient way to properly support multi-bytes characters is
      merging of translation operations directly into conversion function.
      This can help to avoid extra passes along the string or parsing
      the multi-bytes character back into unicode to find out it's length.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      484a10f4
    • A
      udf: Remove struct ustr as non-needed intermediate storage · 9293fcfb
      Andrew Gabbasov 提交于
      Although 'struct ustr' tries to structurize the data by combining
      the string and its length, it doesn't actually make much benefit,
      since it saves only one parameter, but introduces an extra copying
      of the whole buffer, serving as an intermediate storage. It looks
      quite inefficient and not actually needed.
      
      This commit gets rid of the struct ustr by changing the parameters
      of some functions appropriately.
      
      Also, it removes using 'dstring' type, since it doesn't make much
      sense too.
      
      Just using the occasion, add a 'const' qualifier to udf_get_filename
      to make consistent parameters sets.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      9293fcfb
    • J
      udf: Use separate buffer for copying split names · 066b9cde
      Jan Kara 提交于
      Code in udf_find_entry() and udf_readdir() used the same buffer for
      storing filename that was split among blocks and for the resulting
      filename in utf8. This worked because udf_get_filename() first
      internally copied the name into a different buffer and only then
      performed a conversion into the destination buffer. However we want to
      get rid of intermediate buffers so use separate buffer for converted
      name and name split between blocks so that we don't have the same source
      and destination buffer when converting split names.
      Signed-off-by: NJan Kara <jack@suse.cz>
      066b9cde
    • A
      udf: Adjust UDF_NAME_LEN to better reflect actual restrictions · 9fba7056
      Andrew Gabbasov 提交于
      Actual name length restriction is 254 bytes, this is used in 'ustr'
      structure, and this is what fits into UDF File Ident structures.
      And in most cases the constant is used as UDF_NAME_LEN-2.
      So, it's better to just modify the constant to make it closer
      to reality.
      
      Also, in some cases it's useful to have a separate constant for
      the maximum length of file name field in CS0 encoding in UDF File
      Ident structures.
      
      Also, remove the unused UDF_PATH_LEN constant.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      9fba7056
    • A
      udf: Join functions for UTF8 and NLS conversions · 3e7fc205
      Andrew Gabbasov 提交于
      There is no much sense to have separate functions for UTF8 and
      NLS conversions, since UTF8 encoding is actually the special case
      of NLS.
      
      However, although UTF8 is also supported by general NLS framework,
      it would be good to have separate UTF8 character conversion functions
      (char2uni and uni2char) locally in UDF code, so that they could be
      used even if NLS support is not enabled in the kernel configuration.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      3e7fc205
    • A
      udf: Parameterize output length in udf_put_filename · 525e2c56
      Andrew Gabbasov 提交于
      Make the desired output length a parameter rather than have it
      hard-coded to UDF_NAME_LEN. Although all call sites still have
      this length the same, this parameterization will make the function
      more universal and also consistent with udf_get_filename.
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      525e2c56
  12. 23 1月, 2016 2 次提交
  13. 15 1月, 2016 1 次提交
    • V
      kmemcg: account certain kmem allocations to memcg · 5d097056
      Vladimir Davydov 提交于
      Mark those kmem allocations that are known to be easily triggered from
      userspace as __GFP_ACCOUNT/SLAB_ACCOUNT, which makes them accounted to
      memcg.  For the list, see below:
      
       - threadinfo
       - task_struct
       - task_delay_info
       - pid
       - cred
       - mm_struct
       - vm_area_struct and vm_region (nommu)
       - anon_vma and anon_vma_chain
       - signal_struct
       - sighand_struct
       - fs_struct
       - files_struct
       - fdtable and fdtable->full_fds_bits
       - dentry and external_name
       - inode for all filesystems. This is the most tedious part, because
         most filesystems overwrite the alloc_inode method.
      
      The list is far from complete, so feel free to add more objects.
      Nevertheless, it should be close to "account everything" approach and
      keep most workloads within bounds.  Malevolent users will be able to
      breach the limit, but this was possible even with the former "account
      everything" approach (simply because it did not account everything in
      fact).
      
      [akpm@linux-foundation.org: coding-style fixes]
      Signed-off-by: NVladimir Davydov <vdavydov@virtuozzo.com>
      Acked-by: NJohannes Weiner <hannes@cmpxchg.org>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Greg Thelen <gthelen@google.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Pekka Enberg <penberg@kernel.org>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5d097056
  14. 04 1月, 2016 3 次提交
    • A
      udf: Check output buffer length when converting name to CS0 · bb00c898
      Andrew Gabbasov 提交于
      If a name contains at least some characters with Unicode values
      exceeding single byte, the CS0 output should have 2 bytes per character.
      And if other input characters have single byte Unicode values, then
      the single input byte is converted to 2 output bytes, and the length
      of output becomes larger than the length of input. And if the input
      name is long enough, the output length may exceed the allocated buffer
      length.
      
      All this means that conversion from UTF8 or NLS to CS0 requires
      checking of output length in order to stop when it exceeds the given
      output buffer size.
      
      [JK: Make code return -ENAMETOOLONG instead of silently truncating the
      name]
      
      CC: stable@vger.kernel.org
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      bb00c898
    • A
      udf: Prevent buffer overrun with multi-byte characters · ad402b26
      Andrew Gabbasov 提交于
      udf_CS0toUTF8 function stops the conversion when the output buffer
      length reaches UDF_NAME_LEN-2, which is correct maximum name length,
      but, when checking, it leaves the space for a single byte only,
      while multi-bytes output characters can take more space, causing
      buffer overflow.
      
      Similar error exists in udf_CS0toNLS function, that restricts
      the output length to UDF_NAME_LEN, while actual maximum allowed
      length is UDF_NAME_LEN-2.
      
      In these cases the output can override not only the current buffer
      length field, causing corruption of the name buffer itself, but also
      following allocation structures, causing kernel crash.
      
      Adjust the output length checks in both functions to prevent buffer
      overruns in case of multi-bytes UTF8 or NLS characters.
      
      CC: stable@vger.kernel.org
      Signed-off-by: NAndrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      ad402b26
    • A
      udf: avoid uninitialized variable use · 4f1b1519
      Arnd Bergmann 提交于
      A new warning has come up from a recent cleanup:
      
      fs/udf/inode.c: In function 'udf_setup_indirect_aext':
      fs/udf/inode.c:1927:28: warning: 'adsize' may be used uninitialized in this function [-Wmaybe-uninitialized]
      
      If the alloc_type is neither ICBTAG_FLAG_AD_SHORT nor
      ICBTAG_FLAG_AD_LONG, the value of adsize is undefined. Currently,
      callers of these functions make sure alloc_type is one of the two valid
      ones but for future proofing make sure we handle the case of invalid
      alloc type as well.  This changes the code to return -EIOin that case.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Fixes: fcea62ba ("udf: Factor out code for creating indirect extent")
      Signed-off-by: NJan Kara <jack@suse.cz>
      4f1b1519
  15. 24 12月, 2015 2 次提交
    • J
      udf: Fix lost indirect extent block · 6c371578
      Jan Kara 提交于
      When inode ends with empty indirect extent block and we extended that
      file, udf_do_extend_file() ended up just overwriting pointer to it with
      another extent and thus effectively leaking the block and also
      corruptiong length of allocation descriptors.
      
      Fix the problem by properly following into next indirect extent when it
      is present.
      Signed-off-by: NJan Kara <jack@suse.cz>
      6c371578
    • J
      udf: Factor out code for creating indirect extent · fcea62ba
      Jan Kara 提交于
      Factor out code for creating indirect extent from udf_add_aext(). It was
      mostly duplicated in two places. Also remove some opencoded versions
      of udf_write_aext().
      Signed-off-by: NJan Kara <jack@suse.cz>
      fcea62ba
  16. 23 12月, 2015 1 次提交
  17. 15 12月, 2015 1 次提交
  18. 09 12月, 2015 1 次提交
    • A
      don't put symlink bodies in pagecache into highmem · 21fc61c7
      Al Viro 提交于
      kmap() in page_follow_link_light() needed to go - allowing to hold
      an arbitrary number of kmaps for long is a great way to deadlocking
      the system.
      
      new helper (inode_nohighmem(inode)) needs to be used for pagecache
      symlinks inodes; done for all in-tree cases.  page_follow_link_light()
      instrumented to yell about anything missed.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      21fc61c7
  19. 07 12月, 2015 1 次提交
  20. 20 8月, 2015 1 次提交
    • J
      udf: Don't modify filesystem for read-only mounts · 9181f8bf
      Jan Kara 提交于
      When read-write mount of a filesystem is requested but we find out we
      can mount the filesystem only in read-only mode, we still modify
      LVID in udf_close_lvid(). That is both unnecessary and contrary to
      expectation that when we fall back to read-only mount we don't modify
      the filesystem.
      
      Make sure we call udf_close_lvid() only if we called udf_open_lvid() so
      that filesystem gets modified only if we verified we are allowed to
      write to it.
      Reported-by: NKarel Zak <kzak@redhat.com>
      Signed-off-by: NJan Kara <jack@suse.com>
      9181f8bf
  21. 09 7月, 2015 1 次提交
    • S
      udf: Don't corrupt unalloc spacetable when writing it · 70f19f58
      Steven J. Magnani 提交于
      For a UDF filesystem configured with an Unallocated Space Table,
      a filesystem operation that triggers an update to the table results
      in on-disk corruption that prevents remounting:
      
        udf_read_tagged: tag version 0x0000 != 0x0002 || 0x0003, block 274
      
      For example:
        1. Create a filesystem
            $ mkudffs --media-type=hd --blocksize=512 --lvid=BUGTEST \
                    --vid=BUGTEST --fsid=BUGTEST --space=unalloctable \
                    /dev/mmcblk0
      
        2. Mount it
            # mount /dev/mmcblk0 /mnt
      
        3. Create a file
            $ echo "No corruption, please" > /mnt/new.file
      
        4. Umount
            # umount /mnt
      
        5. Attempt remount
            # mount /dev/mmcblk0 /mnt
      
      This appears to be a longstanding bug caused by zero-initialization of
      the Unallocated Space Entry block buffer and only partial repopulation
      of required fields before writing to disk.
      
      Commit 0adfb339fd64 ("udf: Fix unalloc space handling in udf_update_inode")
      addressed one such field, but several others are required.
      Signed-off-by: NSteven J. Magnani <steve@digidescorp.com>
      Signed-off-by: NJan Kara <jack@suse.com>
      70f19f58
  22. 24 6月, 2015 1 次提交
  23. 21 5月, 2015 1 次提交
  24. 18 5月, 2015 4 次提交