1. 09 2月, 2016 4 次提交
    • 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
  2. 23 1月, 2016 2 次提交
  3. 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
  4. 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
  5. 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
  6. 23 12月, 2015 1 次提交
  7. 15 12月, 2015 1 次提交
  8. 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
  9. 07 12月, 2015 1 次提交
  10. 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
  11. 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
  12. 24 6月, 2015 1 次提交
  13. 21 5月, 2015 1 次提交
  14. 18 5月, 2015 10 次提交
  15. 16 4月, 2015 1 次提交
  16. 12 4月, 2015 8 次提交
  17. 01 4月, 2015 1 次提交