1. 20 1月, 2017 1 次提交
    • F
      udf: allow implicit blocksize specification during mount · 70f16cef
      Fabian Frederick 提交于
      udf_fill_super() used udf_parse_options() to flag UDF_FLAG_BLOCKSIZE_SET
      when blocksize was specified otherwise used 512 bytes
      (bdev_logical_block_size) and 2048 bytes (UDF_DEFAULT_BLOCKSIZE)
      IOW both 1024 and 4096 specifications were required or resulted in
      
      "mount: wrong fs type, bad option, bad superblock on /dev/loop1"
      
      This patch loops through different block values but also updates
      udf_load_vrs() to return -EINVAL instead of 0 when udf_check_vsd()
      fails (and uopt->novrs = 0).
      The later being the reason for the RFC; we have that case when mounting
      a 4kb blocksize against other values but maybe VRS is not mandatory
      there ?
      
      Tested with 512, 1024, 2048 and 4096 blocksize
      Reported-by: NJan Kara <jack@suse.com>
      Signed-off-by: NFabian Frederick <fabf@skynet.be>
      Signed-off-by: NJan Kara <jack@suse.cz>
      70f16cef
  2. 10 1月, 2017 2 次提交
  3. 03 1月, 2017 1 次提交
    • D
      fs: udf: Replace CURRENT_TIME with current_time() · 88b50ce3
      Deepa Dinamani 提交于
      CURRENT_TIME is not y2038 safe.
      
      CURRENT_TIME macro is also not appropriate for filesystems
      as it doesn't use the right granularity for filesystem
      timestamps.
      
      Logical Volume Integrity format is described to have the
      same timestamp format for "Recording Date and time" as
      the other [a,c,m]timestamps.
      The function udf_time_to_disk_format() does this conversion.
      Hence the timestamp is passed directly to the function and
      not truncated. This is as per Arnd's suggestion on the
      thread.
      
      This is also in preparation for the patch that transitions
      vfs timestamps to use 64 bit time and hence make them
      y2038 safe. As part of the effort current_time() will be
      extended to do range checks.
      Signed-off-by: NDeepa Dinamani <deepa.kernel@gmail.com>
      Reviewed-by: NJan Kara <jack@suse.cz>
      Reviewed-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NJan Kara <jack@suse.cz>
      88b50ce3
  4. 19 5月, 2016 1 次提交
    • 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
  5. 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
  6. 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
  7. 09 2月, 2016 2 次提交
    • 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
    • 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
  8. 23 1月, 2016 1 次提交
  9. 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
  10. 15 12月, 2015 1 次提交
  11. 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
  12. 21 5月, 2015 1 次提交
  13. 18 5月, 2015 1 次提交
  14. 14 3月, 2015 1 次提交
  15. 05 2月, 2015 1 次提交
  16. 12 1月, 2015 1 次提交
  17. 20 11月, 2014 2 次提交
  18. 09 10月, 2014 1 次提交
    • J
      udf: Fix loading of special inodes · 6174c2eb
      Jan Kara 提交于
      Some UDF media have special inodes (like VAT or metadata partition
      inodes) whose link_count is 0. Thus commit 4071b913 (udf: Properly
      detect stale inodes) broke loading these inodes because udf_iget()
      started returning -ESTALE for them. Since we still need to properly
      detect stale inodes queried by NFS, create two variants of udf_iget() -
      one which is used for looking up special inodes (which ignores
      link_count == 0) and one which is used for other cases which return
      ESTALE when link_count == 0.
      
      Fixes: 4071b913
      CC: stable@vger.kernel.org
      Signed-off-by: NJan Kara <jack@suse.cz>
      6174c2eb
  19. 05 9月, 2014 1 次提交
    • J
      udf: Make udf_read_inode() and udf_iget() return error · 6d3d5e86
      Jan Kara 提交于
      Currently __udf_read_inode() wasn't returning anything and we found out
      whether we succeeded reading inode by checking whether inode is bad or
      not. udf_iget() returned NULL on failure and inode pointer otherwise.
      Make these two functions properly propagate errors up the call stack and
      use the return value in callers.
      Signed-off-by: NJan Kara <jack@suse.cz>
      6d3d5e86
  20. 16 7月, 2014 1 次提交
  21. 13 3月, 2014 1 次提交
    • T
      fs: push sync_filesystem() down to the file system's remount_fs() · 02b9984d
      Theodore Ts'o 提交于
      Previously, the no-op "mount -o mount /dev/xxx" operation when the
      file system is already mounted read-write causes an implied,
      unconditional syncfs().  This seems pretty stupid, and it's certainly
      documented or guaraunteed to do this, nor is it particularly useful,
      except in the case where the file system was mounted rw and is getting
      remounted read-only.
      
      However, it's possible that there might be some file systems that are
      actually depending on this behavior.  In most file systems, it's
      probably fine to only call sync_filesystem() when transitioning from
      read-write to read-only, and there are some file systems where this is
      not needed at all (for example, for a pseudo-filesystem or something
      like romfs).
      Signed-off-by: N"Theodore Ts'o" <tytso@mit.edu>
      Cc: linux-fsdevel@vger.kernel.org
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Artem Bityutskiy <dedekind1@gmail.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Evgeniy Dushistov <dushistov@mail.ru>
      Cc: Jan Kara <jack@suse.cz>
      Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
      Cc: Anders Larsen <al@alarsen.net>
      Cc: Phillip Lougher <phillip@squashfs.org.uk>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Cc: Petr Vandrovec <petr@vandrovec.name>
      Cc: xfs@oss.sgi.com
      Cc: linux-btrfs@vger.kernel.org
      Cc: linux-cifs@vger.kernel.org
      Cc: samba-technical@lists.samba.org
      Cc: codalist@coda.cs.cmu.edu
      Cc: linux-ext4@vger.kernel.org
      Cc: linux-f2fs-devel@lists.sourceforge.net
      Cc: fuse-devel@lists.sourceforge.net
      Cc: cluster-devel@redhat.com
      Cc: linux-mtd@lists.infradead.org
      Cc: jfs-discussion@lists.sourceforge.net
      Cc: linux-nfs@vger.kernel.org
      Cc: linux-nilfs@vger.kernel.org
      Cc: linux-ntfs-dev@lists.sourceforge.net
      Cc: ocfs2-devel@oss.oracle.com
      Cc: reiserfs-devel@vger.kernel.org
      02b9984d
  22. 03 3月, 2014 2 次提交
  23. 19 10月, 2013 1 次提交
    • P
      udf: fix for pathetic mount times in case of invalid file system · 44499602
      Peter A. Felvegi 提交于
      The UDF driver was not strict enough about checking the IDs in the
      VSDs when mounting, which resulted in reading through all the sectors
      of the block device in some unfortunate cases. Eg, trying to mount my
      uninitialized 200G SSD partition (all 0xFF bytes) took ~350 minutes to
      fail, because the code expected some of the valid IDs or a zero byte.
      During this, the mount couldn't be killed, sync from the cmdline
      blocked, and the machine froze into the shutdown. Valid filesystems
      (extX, btrfs, ntfs) were rejected by the mere accident of having a
      zero byte at just the right place in some of their sectors, close
      enough to the beginning not to generate excess I/O. The fix adds a
      hard limit on the VSD sector offset, adds the two missing VSD IDs, and
      stops scanning when encountering an invalid ID. Also replaced the
      magic number 32768 with a more meaningful #define, and supressed the
      bogus message about failing to read the first sector if no UDF fs was
      detected.
      Signed-off-by: NPeter A. Felvegi <petschy@gmail.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      44499602
  24. 24 9月, 2013 1 次提交
    • J
      udf: Fortify LVID loading · 69d75671
      Jan Kara 提交于
      A user has reported an oops in udf_statfs() that was caused by
      numOfPartitions entry in LVID structure being corrupted. Fix the problem
      by verifying whether numOfPartitions makes sense at least to the extent
      that LVID fits into a single block as it should.
      Reported-by: NJuergen Weigert <jw@suse.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      69d75671
  25. 01 8月, 2013 2 次提交
    • J
      udf: Refuse RW mount of the filesystem instead of making it RO · e729eac6
      Jan Kara 提交于
      Refuse RW mount of udf filesystem. So far we just silently changed it
      to RO mount but when the media is writeable, block layer won't notice
      this change and thus will think device is used RW and will block eject
      button of the drive. That is unexpected by users because for
      non-writeable media eject button works just fine.
      
      Userspace mount(8) command handles this just fine and retries mounting
      with MS_RDONLY set so userspace shouldn't see any regression.  Plus any
      tool mounting udf is likely confronted with the case of read-only
      media where block layer already refuses to mount the filesystem without
      MS_RDONLY set so our behavior shouldn't be anything new for it.
      Reported-by: NHui Wang <hui.wang@canonical.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      e729eac6
    • J
      udf: Standardize return values in mount sequence · d759bfa4
      Jan Kara 提交于
      Change all function used in filesystem discovery during mount to user
      standard kernel return values - -errno on error, 0 on success instead
      of 1 on failure and 0 on success. This allows us to pass error number
      (not just failure / success) so we can abort device scanning earlier
      in case of errors like EIO or ENOMEM . Also we will be able to return
      EROFS in case writeable mount is requested but writing isn't supported.
      Signed-off-by: NJan Kara <jack@suse.cz>
      d759bfa4
  26. 11 3月, 2013 1 次提交
  27. 06 2月, 2013 2 次提交
  28. 22 1月, 2013 1 次提交
    • N
      udf: add extent cache support in case of file reading · 99600051
      Namjae Jeon 提交于
      This patch implements extent caching in case of file reading.
      While reading a file, currently, UDF reads metadata serially
      which takes a lot of time depending on the number of extents present
      in the file. Caching last accessd extent improves metadata read time.
      Instead of reading file metadata from start, now we read from
      the cached extent.
      
      This patch considerably improves the time spent by CPU in kernel mode.
      For example, while reading a 10.9 GB file using dd:
      Time before applying patch:
      11677022208 bytes (10.9GB) copied, 1529.748921 seconds, 7.3MB/s
      real    25m 29.85s
      user    0m 12.41s
      sys     15m 34.75s
      
      Time after applying patch:
      11677022208 bytes (10.9GB) copied, 1469.338231 seconds, 7.6MB/s
      real    24m 29.44s
      user    0m 15.73s
      sys     3m 27.61s
      
      [JK: Fix bh refcounting issues, simplify initialization]
      Signed-off-by: NNamjae Jeon <namjae.jeon@samsung.com>
      Signed-off-by: NAshish Sangwan <a.sangwan@samsung.com>
      Signed-off-by: NBonggil Bak <bgbak@samsung.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      99600051
  29. 21 1月, 2013 1 次提交
  30. 15 1月, 2013 1 次提交
  31. 03 10月, 2012 1 次提交
  32. 21 9月, 2012 1 次提交
  33. 15 8月, 2012 2 次提交