1. 24 5月, 2017 19 次提交
  2. 17 5月, 2017 1 次提交
  3. 04 5月, 2017 12 次提交
    • E
      f2fs: switch to using fscrypt_match_name() · 1f73d491
      Eric Biggers 提交于
      Switch f2fs directory searches to use the fscrypt_match_name() helper
      function.  There should be no functional change.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Acked-by: NJaegeuk Kim <jaegeuk@kernel.org>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      1f73d491
    • E
      fscrypt: avoid collisions when presenting long encrypted filenames · 6b06cdee
      Eric Biggers 提交于
      When accessing an encrypted directory without the key, userspace must
      operate on filenames derived from the ciphertext names, which contain
      arbitrary bytes.  Since we must support filenames as long as NAME_MAX,
      we can't always just base64-encode the ciphertext, since that may make
      it too long.  Currently, this is solved by presenting long names in an
      abbreviated form containing any needed filesystem-specific hashes (e.g.
      to identify a directory block), then the last 16 bytes of ciphertext.
      This needs to be sufficient to identify the actual name on lookup.
      
      However, there is a bug.  It seems to have been assumed that due to the
      use of a CBC (ciphertext block chaining)-based encryption mode, the last
      16 bytes (i.e. the AES block size) of ciphertext would depend on the
      full plaintext, preventing collisions.  However, we actually use CBC
      with ciphertext stealing (CTS), which handles the last two blocks
      specially, causing them to appear "flipped".  Thus, it's actually the
      second-to-last block which depends on the full plaintext.
      
      This caused long filenames that differ only near the end of their
      plaintexts to, when observed without the key, point to the wrong inode
      and be undeletable.  For example, with ext4:
      
          # echo pass | e4crypt add_key -p 16 edir/
          # seq -f "edir/abcdefghijklmnopqrstuvwxyz012345%.0f" 100000 | xargs touch
          # find edir/ -type f | xargs stat -c %i | sort | uniq | wc -l
          100000
          # sync
          # echo 3 > /proc/sys/vm/drop_caches
          # keyctl new_session
          # find edir/ -type f | xargs stat -c %i | sort | uniq | wc -l
          2004
          # rm -rf edir/
          rm: cannot remove 'edir/_A7nNFi3rhkEQlJ6P,hdzluhODKOeWx5V': Structure needs cleaning
          ...
      
      To fix this, when presenting long encrypted filenames, encode the
      second-to-last block of ciphertext rather than the last 16 bytes.
      
      Although it would be nice to solve this without depending on a specific
      encryption mode, that would mean doing a cryptographic hash like SHA-256
      which would be much less efficient.  This way is sufficient for now, and
      it's still compatible with encryption modes like HEH which are strong
      pseudorandom permutations.  Also, changing the presented names is still
      allowed at any time because they are only provided to allow applications
      to do things like delete encrypted directories.  They're not designed to
      be used to persistently identify files --- which would be hard to do
      anyway, given that they're encrypted after all.
      
      For ease of backports, this patch only makes the minimal fix to both
      ext4 and f2fs.  It leaves ubifs as-is, since ubifs doesn't compare the
      ciphertext block yet.  Follow-on patches will clean things up properly
      and make the filesystems use a shared helper function.
      
      Fixes: 5de0b4d0 ("ext4 crypto: simplify and speed up filename encryption")
      Reported-by: NGwendal Grignou <gwendal@chromium.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      6b06cdee
    • J
      f2fs: check entire encrypted bigname when finding a dentry · 6332cd32
      Jaegeuk Kim 提交于
      If user has no key under an encrypted dir, fscrypt gives digested dentries.
      Previously, when looking up a dentry, f2fs only checks its hash value with
      first 4 bytes of the digested dentry, which didn't handle hash collisions fully.
      This patch enhances to check entire dentry bytes likewise ext4.
      
      Eric reported how to reproduce this issue by:
      
       # seq -f "edir/abcdefghijklmnopqrstuvwxyz012345%.0f" 100000 | xargs touch
       # find edir -type f | xargs stat -c %i | sort | uniq | wc -l
      100000
       # sync
       # echo 3 > /proc/sys/vm/drop_caches
       # keyctl new_session
       # find edir -type f | xargs stat -c %i | sort | uniq | wc -l
      99999
      
      Cc: <stable@vger.kernel.org>
      Reported-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      (fixed f2fs_dentry_hash() to work even when the hash is 0)
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      6332cd32
    • E
      f2fs: sync f2fs_lookup() with ext4_lookup() · faac7fd9
      Eric Biggers 提交于
      As for ext4, now that fscrypt_has_permitted_context() correctly handles
      the case where we have the key for the parent directory but not the
      child, f2fs_lookup() no longer has to work around it.  Also add the same
      warning message that ext4 uses.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      faac7fd9
    • Y
      f2fs: fix a mount fail for wrong next_scan_nid · e9cdd307
      Yunlei He 提交于
      -write_checkpoint
         -do_checkpoint
            -next_free_nid    <--- something wrong with next free nid
      
      -f2fs_fill_super
         -build_node_manager
            -build_free_nids
                -get_current_nat_page
                   -__get_meta_page   <--- attempt to access beyond end of device
      Signed-off-by: NYunlei He <heyunlei@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      e9cdd307
    • C
      f2fs: relocate inode_{,un}lock in F2FS_IOC_SETFLAGS · a72d4b97
      Chao Yu 提交于
      This patch expands cover region of inode->i_rwsem to keep setting flag
      atomically.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      a72d4b97
    • J
      f2fs: Make flush bios explicitely sync · 3adc5fcb
      Jan Kara 提交于
      Commit b685d3d6 "block: treat REQ_FUA and REQ_PREFLUSH as
      synchronous" removed REQ_SYNC flag from WRITE_{FUA|PREFLUSH|...}
      definitions.  generic_make_request_checks() however strips REQ_FUA and
      REQ_PREFLUSH flags from a bio when the storage doesn't report volatile
      write cache and thus write effectively becomes asynchronous which can
      lead to performance regressions.
      
      Fix the problem by making sure all bios which are synchronous are
      properly marked with REQ_SYNC.
      
      Fixes: b685d3d6
      Cc: stable@vger.kernel.org # 4.9+
      CC: Jaegeuk Kim <jaegeuk@kernel.org>
      CC: linux-f2fs-devel@lists.sourceforge.net
      Signed-off-by: NJan Kara <jack@suse.cz>
      Acked-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      3adc5fcb
    • J
      f2fs: show available_nids in f2fs/status · 5b0ef73c
      Jaegeuk Kim 提交于
      This patch adds an entry in f2fs/status to show # of available nids.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      5b0ef73c
    • J
      f2fs: flush dirty nats periodically · 1c0f4bf5
      Jaegeuk Kim 提交于
      This patch flushes dirty nats in order to acquire available nids by writing
      checkpoint. Otherwise, we can have no chance to get freed nids.
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1c0f4bf5
    • C
      f2fs: introduce CP_TRIMMED_FLAG to avoid unneeded discard · 1f43e2ad
      Chao Yu 提交于
      Introduce CP_TRIMMED_FLAG to indicate all invalid block were trimmed
      before umount, so once we do mount with image which contain the flag,
      we don't record invalid blocks as undiscard one, when fstrim is being
      triggered, we can avoid issuing redundant discard commands.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      1f43e2ad
    • C
      f2fs: allow cpc->reason to indicate more than one reason · c473f1a9
      Chao Yu 提交于
      Change to use different bits of cpc->reason to indicate different status,
      so cpc->reason can indicate more than one reason.
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      c473f1a9
    • H
      f2fs: release cp and dnode lock before IPU · 279d6df2
      Hou Pengyang 提交于
      We don't need to rewrite the page under cp_rwsem and dnode locks.
      Signed-off-by: NHou Pengyang <houpengyang@huawei.com>
      Signed-off-by: NChao Yu <yuchao0@huawei.com>
      Signed-off-by: NJaegeuk Kim <jaegeuk@kernel.org>
      279d6df2
  4. 03 5月, 2017 8 次提交