1. 19 4月, 2018 2 次提交
    • J
      udf: Convert ident strings to proper charset · e966fc8d
      Jan Kara 提交于
      iocharset= mount option specifies the character set used on *console*
      (not on disk). So even dstrings from VRS need to be converted from CS0
      to the specified charset and not always UTF-8. This is barely user
      visible as those strings are shown only in UDF debug messages.
      
      CC: Andrew Gabbasov <andrew_gabbasov@mentor.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      e966fc8d
    • J
      udf: Always require NLS support · b8333ea1
      Jan Kara 提交于
      UDF needs to convert strings between OSTA CS0 charset and standard UTF8.
      Currently we implement our own utf-16 <-> utf-8 translations which is
      unnecessary code duplication. Always select NLS so that we can use
      translation functions from there.
      Signed-off-by: NJan Kara <jack@suse.cz>
      b8333ea1
  2. 02 3月, 2018 2 次提交
  3. 27 2月, 2018 5 次提交
  4. 16 2月, 2018 4 次提交
  5. 28 11月, 2017 1 次提交
    • L
      Rename superblock flags (MS_xyz -> SB_xyz) · 1751e8a6
      Linus Torvalds 提交于
      This is a pure automated search-and-replace of the internal kernel
      superblock flags.
      
      The s_flags are now called SB_*, with the names and the values for the
      moment mirroring the MS_* flags that they're equivalent to.
      
      Note how the MS_xyz flags are the ones passed to the mount system call,
      while the SB_xyz flags are what we then use in sb->s_flags.
      
      The script to do this was:
      
          # places to look in; re security/*: it generally should *not* be
          # touched (that stuff parses mount(2) arguments directly), but
          # there are two places where we really deal with superblock flags.
          FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
                  include/linux/fs.h include/uapi/linux/bfs_fs.h \
                  security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
          # the list of MS_... constants
          SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
                DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
                POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
                I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
                ACTIVE NOUSER"
      
          SED_PROG=
          for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done
      
          # we want files that contain at least one of MS_...,
          # with fs/namespace.c and fs/pnode.c excluded.
          L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')
      
          for f in $L; do sed -i $f $SED_PROG; done
      Requested-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1751e8a6
  6. 17 10月, 2017 2 次提交
    • S
      udf: Fix signed/unsigned format specifiers · fcbf7637
      Steve Magnani 提交于
      Fix problems noted in compilion with -Wformat=2 -Wformat-signedness.
      In particular, a mismatch between the signedness of a value and the
      signedness of its format specifier can result in unsigned values being
      printed as negative numbers, e.g.:
      
        Partition (0 type 1511) starts at physical 460, block length -1779968542
      
      ...which occurs when mounting a large (> 1 TiB) UDF partition.
      
      Changes since V1:
      * Fixed additional issues noted in udf_bitmap_free_blocks(),
        udf_get_fileident(), udf_show_options()
      Signed-off-by: NSteven J. Magnani <steve@digidescorp.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      fcbf7637
    • S
      udf: Fix 64-bit sign extension issues affecting blocks > 0x7FFFFFFF · b490bdd6
      Steve Magnani 提交于
      Large (> 1 TiB) UDF filesystems appear subject to several problems when
      mounted on 64-bit systems:
      
      * readdir() can fail on a directory containing File Identifiers residing
        above 0x7FFFFFFF. This manifests as a 'ls' command failing with EIO.
      
      * FIBMAP on a file block located above 0x7FFFFFFF can return a negative
        value. The low 32 bits are correct, but applications that don't mask the
        high 32 bits of the result can perform incorrectly.
      
      Per suggestion by Jan Kara, introduce a udf_pblk_t type for representation
      of UDF block addresses. Ultimately, all driver functions that manipulate
      UDF block addresses should use this type; for now, deployment is limited
      to functions with actual or potential sign extension issues.
      
      Changes to udf_readdir() and udf_block_map() address the issues noted
      above; other changes address potential similar issues uncovered during
      audit of the driver code.
      Signed-off-by: NSteven J. Magnani <steve@digidescorp.com>
      Signed-off-by: NJan Kara <jack@suse.cz>
      b490bdd6
  7. 16 10月, 2017 1 次提交
  8. 16 8月, 2017 3 次提交
  9. 17 7月, 2017 1 次提交
    • D
      VFS: Convert sb->s_flags & MS_RDONLY to sb_rdonly(sb) · bc98a42c
      David Howells 提交于
      Firstly by applying the following with coccinelle's spatch:
      
      	@@ expression SB; @@
      	-SB->s_flags & MS_RDONLY
      	+sb_rdonly(SB)
      
      to effect the conversion to sb_rdonly(sb), then by applying:
      
      	@@ expression A, SB; @@
      	(
      	-(!sb_rdonly(SB)) && A
      	+!sb_rdonly(SB) && A
      	|
      	-A != (sb_rdonly(SB))
      	+A != sb_rdonly(SB)
      	|
      	-A == (sb_rdonly(SB))
      	+A == sb_rdonly(SB)
      	|
      	-!(sb_rdonly(SB))
      	+!sb_rdonly(SB)
      	|
      	-A && (sb_rdonly(SB))
      	+A && sb_rdonly(SB)
      	|
      	-A || (sb_rdonly(SB))
      	+A || sb_rdonly(SB)
      	|
      	-(sb_rdonly(SB)) != A
      	+sb_rdonly(SB) != A
      	|
      	-(sb_rdonly(SB)) == A
      	+sb_rdonly(SB) == A
      	|
      	-(sb_rdonly(SB)) && A
      	+sb_rdonly(SB) && A
      	|
      	-(sb_rdonly(SB)) || A
      	+sb_rdonly(SB) || A
      	)
      
      	@@ expression A, B, SB; @@
      	(
      	-(sb_rdonly(SB)) ? 1 : 0
      	+sb_rdonly(SB)
      	|
      	-(sb_rdonly(SB)) ? A : B
      	+sb_rdonly(SB) ? A : B
      	)
      
      to remove left over excess bracketage and finally by applying:
      
      	@@ expression A, SB; @@
      	(
      	-(A & MS_RDONLY) != sb_rdonly(SB)
      	+(bool)(A & MS_RDONLY) != sb_rdonly(SB)
      	|
      	-(A & MS_RDONLY) == sb_rdonly(SB)
      	+(bool)(A & MS_RDONLY) == sb_rdonly(SB)
      	)
      
      to make comparisons against the result of sb_rdonly() (which is a bool)
      work correctly.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      bc98a42c
  10. 13 6月, 2017 1 次提交
  11. 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
  12. 10 1月, 2017 2 次提交
  13. 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
  14. 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
  15. 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
  16. 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
  17. 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
  18. 23 1月, 2016 1 次提交
  19. 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
  20. 15 12月, 2015 1 次提交
  21. 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
  22. 21 5月, 2015 1 次提交
  23. 18 5月, 2015 1 次提交
  24. 14 3月, 2015 1 次提交
  25. 05 2月, 2015 1 次提交
  26. 12 1月, 2015 1 次提交