1. 27 Aug, 2019 1 commit
    • Steven J. Magnani's avatar
      udf: augment UDF permissions on new inodes · c3367a1b
      Steven J. Magnani authored
      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: default avatarSteven J. Magnani <steve@digidescorp.com>
      Link: https://lore.kernel.org/r/20190827121359.9954-1-steve@digidescorp.comSigned-off-by: default avatarJan Kara <jack@suse.cz>
      c3367a1b
  2. 27 Feb, 2018 1 commit
  3. 14 Jun, 2017 2 commits
    • Jan Kara's avatar
      udf: Use i_size_read() in udf_adinicb_writepage() · 146c4ad6
      Jan Kara authored
      We don't hold inode_lock in udf_adinicb_writepage() so use i_size_read()
      to get i_size. This cannot cause real problems is i_size is guaranteed
      to be small but let's be careful.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      146c4ad6
    • Jan Kara's avatar
      udf: Fix races with i_size changes during readpage · 9795e0e8
      Jan Kara authored
      __udf_adinicb_readpage() uses i_size several times. When truncate
      changes i_size while the function is running, it can observe several
      different values and thus e.g. expose uninitialized parts of page to
      userspace. Also use i_size_read() in the function since it does not hold
      inode_lock. Since i_size is guaranteed to be small, this cannot really
      cause any issues even on 32-bit archs but let's be careful.
      
      CC: stable@vger.kernel.org
      Fixes: 9c2fc0deSigned-off-by: default avatarJan Kara <jack@suse.cz>
      9795e0e8
  4. 24 Apr, 2017 1 commit
  5. 03 Feb, 2017 2 commits
  6. 22 Sep, 2016 1 commit
  7. 19 Sep, 2016 1 commit
  8. 06 Sep, 2016 1 commit
  9. 01 May, 2016 3 commits
  10. 04 Apr, 2016 1 commit
    • Kirill A. Shutemov's avatar
      mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros · 09cbfeaf
      Kirill A. Shutemov authored
      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: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
      Acked-by: default avatarMichal Hocko <mhocko@suse.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      09cbfeaf
  11. 22 Jan, 2016 1 commit
    • Al Viro's avatar
      wrappers for ->i_mutex access · 5955102c
      Al Viro authored
      parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
      inode_foo(inode) being mutex_foo(&inode->i_mutex).
      
      Please, use those for access to ->i_mutex; over the coming cycle
      ->i_mutex will become rwsem, with ->lookup() done with it held
      only shared.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      5955102c
  12. 18 May, 2015 1 commit
  13. 15 Apr, 2015 1 commit
  14. 12 Apr, 2015 6 commits
  15. 26 Mar, 2015 1 commit
  16. 14 Mar, 2015 1 commit
  17. 13 Mar, 2015 1 commit
  18. 28 Jan, 2015 1 commit
    • Jan Kara's avatar
      udf: Release preallocation on last writeable close · b07ef352
      Jan Kara authored
      Commit 6fb1ca92 "udf: Fix race between write(2) and close(2)"
      changed the condition when preallocation is released. The idea was that
      we don't want to release the preallocation for an inode on close when
      there are other writeable file descriptors for the inode. However the
      condition was written in the opposite way so we released preallocation
      only if there were other writeable file descriptors. Fix the problem by
      changing the condition properly.
      
      CC: stable@vger.kernel.org
      Fixes: 6fb1ca92Reported-by: default avatarFabian Frederick <fabf@skynet.be>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      b07ef352
  19. 17 Sep, 2014 1 commit
    • Jan Kara's avatar
      udf: Fix race between write(2) and close(2) · 6fb1ca92
      Jan Kara authored
      Currently write(2) updating i_size and close(2) of the file can race in
      such a way that udf_truncate_tail_extent() called from
      udf_file_release() sees old i_size but already new extents added by the
      running write call. This results in complaints like:
        UDF-fs: warning (device vdb2): udf_truncate_tail_extent: Too long extent
          after EOF in inode 877: i_size: 0 lbcount: 1073739776 extent 0+1073739776
        UDF-fs: error (device vdb2): udf_truncate_tail_extent: Extent after EOF
          in inode 877
      
      Fix the problem by grabbing i_mutex in udf_file_release() to be sure
      i_size is consistent with current state of extent list. Also avoid
      truncating tail extent unnecessarily when the file is still open for
      writing.
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      6fb1ca92
  20. 15 Jul, 2014 2 commits
  21. 06 May, 2014 3 commits
  22. 02 Apr, 2014 1 commit
  23. 20 Feb, 2014 1 commit
    • Jan Kara's avatar
      udf: Fix data corruption on file type conversion · 09ebb17a
      Jan Kara authored
      UDF has two types of files - files with data stored in inode (ICB in
      UDF terminology) and files with data stored in external data blocks. We
      convert file from in-inode format to external format in
      udf_file_aio_write() when we find out data won't fit into inode any
      longer. However the following race between two O_APPEND writes can happen:
      
      CPU1					CPU2
      udf_file_aio_write()			udf_file_aio_write()
        down_write(&iinfo->i_data_sem);
        checks that i_size + count1 fits within inode
          => no need to convert
        up_write(&iinfo->i_data_sem);
      					  down_write(&iinfo->i_data_sem);
      					  checks that i_size + count2 fits
      					    within inode => no need to convert
      					  up_write(&iinfo->i_data_sem);
        generic_file_aio_write()
          - extends file by count1 bytes
      					  generic_file_aio_write()
      					    - extends file by count2 bytes
      
      Clearly if count1 + count2 doesn't fit into the inode, we overwrite
      kernel buffers beyond inode, possibly corrupting the filesystem as well.
      
      Fix the problem by acquiring i_mutex before checking whether write fits
      into the inode and using __generic_file_aio_write() afterwards which
      puts check and write into one critical section.
      Reported-by: default avatarAl Viro <viro@ZenIV.linux.org.uk>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      09ebb17a
  24. 30 Jul, 2013 1 commit
    • Kent Overstreet's avatar
      aio: Kill aio_rw_vect_retry() · 73a7075e
      Kent Overstreet authored
      This code doesn't serve any purpose anymore, since the aio retry
      infrastructure has been removed.
      
      This change should be safe because aio_read/write are also used for
      synchronous IO, and called from do_sync_read()/do_sync_write() - and
      there's no looping done in the sync case (the read and write syscalls).
      Signed-off-by: default avatarKent Overstreet <koverstreet@google.com>
      Cc: Zach Brown <zab@redhat.com>
      Cc: Felipe Balbi <balbi@ti.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: Asai Thambi S P <asamymuthupa@micron.com>
      Cc: Selvan Mani <smani@micron.com>
      Cc: Sam Bradshaw <sbradshaw@micron.com>
      Cc: Jeff Moyer <jmoyer@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Benjamin LaHaise <bcrl@kvack.org>
      Signed-off-by: default avatarBenjamin LaHaise <bcrl@kvack.org>
      73a7075e
  25. 26 Feb, 2013 1 commit
  26. 23 Feb, 2013 1 commit
  27. 06 Sep, 2012 1 commit
    • Ian Abbott's avatar
      UDF: Add support for O_DIRECT · 5eec54fc
      Ian Abbott authored
      Add support for the O_DIRECT flag.  There are two cases to deal with:
      
      1. Small files stored in the ICB (inode control block?): just return 0
      from the new udf_adinicb_direct_IO() handler to fall back to buffered
      I/O.
      
      2. Larger files, not stored in the ICB: nothing special here.  Just call
      blockdev_direct_IO() from our new udf_direct_IO() handler and tidy up
      any blocks instantiated outside i_size on error.  This is pretty
      standard.  Factor error handling code out of udf_write_begin() into new
      function udf_write_failed() so it can also be called by udf_direct_IO().
      
      Also change the whitespace in udf_aops to make it a bit neater.
      Signed-off-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      5eec54fc
  28. 05 Sep, 2012 1 commit
    • Jan Kara's avatar
      udf: Fix data corruption for files in ICB · 9c2fc0de
      Jan Kara authored
      When a file is stored in ICB (inode), we overwrite part of the file, and
      the page containing file's data is not in page cache, we end up corrupting
      file's data by overwriting them with zeros. The problem is we use
      simple_write_begin() which simply zeroes parts of the page which are not
      written to. The problem has been introduced by be021ee4 (udf: convert to
      new aops).
      
      Fix the problem by providing a ->write_begin function which makes the page
      properly uptodate.
      
      CC: <stable@vger.kernel.org> # >= 2.6.24
      Reported-by: default avatarIan Abbott <abbotti@mev.co.uk>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      9c2fc0de