1. 08 1月, 2017 1 次提交
    • T
      ext4: don't allow encrypted operations without keys · 173b8439
      Theodore Ts'o 提交于
      While we allow deletes without the key, the following should not be
      permitted:
      
      # cd /vdc/encrypted-dir-without-key
      # ls -l
      total 4
      -rw-r--r-- 1 root root   0 Dec 27 22:35 6,LKNRJsp209FbXoSvJWzB
      -rw-r--r-- 1 root root 286 Dec 27 22:35 uRJ5vJh9gE7vcomYMqTAyD
      # mv uRJ5vJh9gE7vcomYMqTAyD  6,LKNRJsp209FbXoSvJWzB
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      173b8439
  2. 03 1月, 2017 1 次提交
    • T
      fscrypt: make test_dummy_encryption require a keyring key · 5bbdcbbb
      Theodore Ts'o 提交于
      Currently, the test_dummy_encryption ext4 mount option, which exists
      only to test encrypted I/O paths with xfstests, overrides all
      per-inode encryption keys with a fixed key.
      
      This change minimizes test_dummy_encryption-specific code path changes
      by supplying a fake context for directories which are not encrypted
      for use when creating new directories, files, or symlinks.  This
      allows us to properly exercise the keyring lookup, derivation, and
      context inheritance code paths.
      
      Before mounting a file system using test_dummy_encryption, userspace
      must execute the following shell commands:
      
          mode='\x00\x00\x00\x00'
          raw="$(printf ""\\\\x%02x"" $(seq 0 63))"
          if lscpu | grep "Byte Order" | grep -q Little ; then
              size='\x40\x00\x00\x00'
          else
              size='\x00\x00\x00\x40'
          fi
          key="${mode}${raw}${size}"
          keyctl new_session
          echo -n -e "${key}" | keyctl padd logon fscrypt:4242424242424242 @s
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      5bbdcbbb
  3. 02 1月, 2017 1 次提交
  4. 01 1月, 2017 5 次提交
    • E
      fscrypt: pass up error codes from ->get_context() · efee590e
      Eric Biggers 提交于
      It was possible for the ->get_context() operation to fail with a
      specific error code, which was then not returned to the caller of
      FS_IOC_SET_ENCRYPTION_POLICY or FS_IOC_GET_ENCRYPTION_POLICY.  Make sure
      to pass through these error codes.  Also reorganize the code so that
      ->get_context() only needs to be called one time when setting an
      encryption policy, and handle contexts of unrecognized sizes more
      appropriately.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      efee590e
    • E
      fscrypt: remove user-triggerable warning messages · 868e1bc6
      Eric Biggers 提交于
      Several warning messages were not rate limited and were user-triggerable
      from FS_IOC_SET_ENCRYPTION_POLICY.  These shouldn't really have been
      there in the first place, but either way they aren't as useful now that
      the error codes have been improved.  So just remove them.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      868e1bc6
    • E
      fscrypt: use EEXIST when file already uses different policy · 8488cd96
      Eric Biggers 提交于
      As part of an effort to clean up fscrypt-related error codes, make
      FS_IOC_SET_ENCRYPTION_POLICY fail with EEXIST when the file already uses
      a different encryption policy.  This is more descriptive than EINVAL,
      which was ambiguous with some of the other error cases.
      
      I am not aware of any users who might be relying on the previous error
      code of EINVAL, which was never documented anywhere.
      
      This failure case will be exercised by an xfstest.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      8488cd96
    • E
      fscrypt: use ENOTDIR when setting encryption policy on nondirectory · dffd0cfa
      Eric Biggers 提交于
      As part of an effort to clean up fscrypt-related error codes, make
      FS_IOC_SET_ENCRYPTION_POLICY fail with ENOTDIR when the file descriptor
      does not refer to a directory.  This is more descriptive than EINVAL,
      which was ambiguous with some of the other error cases.
      
      I am not aware of any users who might be relying on the previous error
      code of EINVAL, which was never documented anywhere, and in some buggy
      kernels did not exist at all as the S_ISDIR() check was missing.
      
      This failure case will be exercised by an xfstest.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      dffd0cfa
    • E
      fscrypt: use ENOKEY when file cannot be created w/o key · 54475f53
      Eric Biggers 提交于
      As part of an effort to clean up fscrypt-related error codes, make
      attempting to create a file in an encrypted directory that hasn't been
      "unlocked" fail with ENOKEY.  Previously, several error codes were used
      for this case, including ENOENT, EACCES, and EPERM, and they were not
      consistent between and within filesystems.  ENOKEY is a better choice
      because it expresses that the failure is due to lacking the encryption
      key.  It also matches the error code returned when trying to open an
      encrypted regular file without the key.
      
      I am not aware of any users who might be relying on the previous
      inconsistent error codes, which were never documented anywhere.
      
      This failure case will be exercised by an xfstest.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      54475f53
  5. 31 12月, 2016 1 次提交
    • E
      fscrypt: fix renaming and linking special files · 42d97eb0
      Eric Biggers 提交于
      Attempting to link a device node, named pipe, or socket file into an
      encrypted directory through rename(2) or link(2) always failed with
      EPERM.  This happened because fscrypt_has_permitted_context() saw that
      the file was unencrypted and forbid creating the link.  This behavior
      was unexpected because such files are never encrypted; only regular
      files, directories, and symlinks can be encrypted.
      
      To fix this, make fscrypt_has_permitted_context() always return true on
      special files.
      
      This will be covered by a test in my encryption xfstests patchset.
      
      Fixes: 9bd8212f ("ext4 crypto: add encryption policy and password salt support")
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Reviewed-by: NRichard Weinberger <richard@nod.at>
      Cc: stable@vger.kernel.org
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      42d97eb0
  6. 28 12月, 2016 1 次提交
    • T
      fscrypt: fix the test_dummy_encryption mount option · fe4f6c80
      Theodore Ts'o 提交于
      Commit f1c131b4: "crypto: xts - Convert to skcipher" now fails
      the setkey operation if the AES key is the same as the tweak key.
      Previously this check was only done if FIPS mode is enabled.  Now this
      check is also done if weak key checking was requested.  This is
      reasonable, but since we were using the dummy key which was a constant
      series of 0x42 bytes, it now caused dummy encrpyption test mode to
      fail.
      
      Fix this by using 0x42... and 0x24... for the two keys, so they are
      different.
      
      Fixes: f1c131b4
      Cc: stable@vger.kernel.org
      Signed-off-by: NTheodore Ts'o <tytso@mit.edu>
      fe4f6c80
  7. 26 12月, 2016 3 次提交
    • T
      ktime: Get rid of ktime_equal() · 1f3a8e49
      Thomas Gleixner 提交于
      No point in going through loops and hoops instead of just comparing the
      values.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      1f3a8e49
    • T
      ktime: Cleanup ktime_set() usage · 8b0e1953
      Thomas Gleixner 提交于
      ktime_set(S,N) was required for the timespec storage type and is still
      useful for situations where a Seconds and Nanoseconds part of a time value
      needs to be converted. For anything where the Seconds argument is 0, this
      is pointless and can be replaced with a simple assignment.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      8b0e1953
    • T
      ktime: Get rid of the union · 2456e855
      Thomas Gleixner 提交于
      ktime is a union because the initial implementation stored the time in
      scalar nanoseconds on 64 bit machine and in a endianess optimized timespec
      variant for 32bit machines. The Y2038 cleanup removed the timespec variant
      and switched everything to scalar nanoseconds. The union remained, but
      become completely pointless.
      
      Get rid of the union and just keep ktime_t as simple typedef of type s64.
      
      The conversion was done with coccinelle and some manual mopping up.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
      2456e855
  8. 25 12月, 2016 1 次提交
  9. 23 12月, 2016 5 次提交
    • J
      ufs: fix function declaration for ufs_truncate_blocks · f698cccb
      Jeff Layton 提交于
      sparse says:
      
          fs/ufs/inode.c:1195:6: warning: symbol 'ufs_truncate_blocks' was not declared. Should it be static?
      
      Note that the forward declaration in the file is already marked static.
      Signed-off-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      f698cccb
    • A
      fs: exec: apply CLOEXEC before changing dumpable task flags · 613cc2b6
      Aleksa Sarai 提交于
      If you have a process that has set itself to be non-dumpable, and it
      then undergoes exec(2), any CLOEXEC file descriptors it has open are
      "exposed" during a race window between the dumpable flags of the process
      being reset for exec(2) and CLOEXEC being applied to the file
      descriptors. This can be exploited by a process by attempting to access
      /proc/<pid>/fd/... during this window, without requiring CAP_SYS_PTRACE.
      
      The race in question is after set_dumpable has been (for get_link,
      though the trace is basically the same for readlink):
      
      [vfs]
      -> proc_pid_link_inode_operations.get_link
         -> proc_pid_get_link
            -> proc_fd_access_allowed
               -> ptrace_may_access(task, PTRACE_MODE_READ_FSCREDS);
      
      Which will return 0, during the race window and CLOEXEC file descriptors
      will still be open during this window because do_close_on_exec has not
      been called yet. As a result, the ordering of these calls should be
      reversed to avoid this race window.
      
      This is of particular concern to container runtimes, where joining a
      PID namespace with file descriptors referring to the host filesystem
      can result in security issues (since PRCTL_SET_DUMPABLE doesn't protect
      against access of CLOEXEC file descriptors -- file descriptors which may
      reference filesystem objects the container shouldn't have access to).
      
      Cc: dev@opencontainers.org
      Cc: <stable@vger.kernel.org> # v3.2+
      Reported-by: NMichael Crosby <crosbymichael@gmail.com>
      Signed-off-by: NAleksa Sarai <asarai@suse.de>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      613cc2b6
    • T
      seq_file: reset iterator to first record for zero offset · e522751d
      Tomasz Majchrzak 提交于
      If kernfs file is empty on a first read, successive read operations
      using the same file descriptor will return no data, even when data is
      available. Default kernfs 'seq_next' implementation advances iterator
      position even when next object is not there. Kernfs 'seq_start' for
      following requests will not return iterator as position is already on
      the second object.
      
      This defect doesn't allow to monitor badblocks sysfs files from MD raid.
      They are initially empty but if data appears at some stage, userspace is
      not able to read it.
      Signed-off-by: NTomasz Majchrzak <tomasz.majchrzak@intel.com>
      Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      e522751d
    • D
      vfs: fix isize/pos/len checks for reflink & dedupe · 22725ce4
      Darrick J. Wong 提交于
      Strengthen the checking of pos/len vs. i_size, clarify the return values
      for the clone prep function, and remove pointless code.
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NDarrick J. Wong <darrick.wong@oracle.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      22725ce4
    • A
      move aio compat to fs/aio.c · c00d2c7e
      Al Viro 提交于
      ... and fix the minor buglet in compat io_submit() - native one
      kills ioctx as cleanup when put_user() fails.  Get rid of
      bogus compat_... in !CONFIG_AIO case, while we are at it - they
      should simply fail with ENOSYS, same as for native counterparts.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      c00d2c7e
  10. 22 12月, 2016 10 次提交
    • L
      befs: add NFS export support · ac632f5b
      Luis de Bethencourt 提交于
      Implement mandatory export_operations, so it is possible to export befs via
      nfs.
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      ac632f5b
    • L
      befs: remove trailing whitespaces · e60f749b
      Luis de Bethencourt 提交于
      Removing all trailing whitespaces in befs.
      
      I was skeptic about tainting the history with this, but whitespace changes
      can be ignored by using 'git blame -w' and 'git log -w'.
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      e60f749b
    • L
      befs: remove signatures from comments · 50b00fc4
      Luis de Bethencourt 提交于
      No idea why some comments have signatures. These predate git. Removing them
      since they add noise and no information.
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      50b00fc4
    • L
      befs: fix style issues in header files · 12ecb38d
      Luis de Bethencourt 提交于
      Fixing checkpatch.pl issues in befs header files:
      WARNING: Missing a blank line after declarations
      +       befs_inode_addr iaddr;
      +       iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
      
      WARNING: space prohibited between function name and open parenthesis '('
      +       return BEFS_SB(sb)->block_size / sizeof (befs_disk_inode_addr);
      
      ERROR: "foo * bar" should be "foo *bar"
      +                   const char *key, befs_off_t * value);
      
      ERROR: Macros with complex values should be enclosed in parentheses
      +#define PACKED __attribute__ ((__packed__))
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      12ecb38d
    • L
      befs: fix style issues in linuxvfs.c · 62b80719
      Luis de Bethencourt 提交于
      Fix the following type of checkpatch.pl issues:
      WARNING: line over 80 characters
      +static struct dentry *befs_lookup(struct inode *, struct dentry *, unsigned int);
      
      ERROR: code indent should use tabs where possible
      +        if (!bi)$
      
      WARNING: please, no spaces at the start of a line
      +        if (!bi)$
      
      WARNING: labels should not be indented
      +      unacquire_bh:
      
      WARNING: space prohibited between function name and open parenthesis '('
      +                                             sizeof (struct befs_inode_info),
      
      WARNING: braces {} are not necessary for single statement blocks
      +       if (!*out) {
      +               return -ENOMEM;
      +       }
      
      WARNING: Block comments use a trailing */ on a separate line
      +        * in special cases */
      
      WARNING: Missing a blank line after declarations
      +               int token;
      +               if (!*p)
      
      ERROR: do not use assignment in if condition
      +       if (!(bh = sb_bread(sb, sb_block))) {
      
      ERROR: space prohibited after that open parenthesis '('
      +       if( befs_sb->num_blocks > ~((sector_t)0) ) {
      
      ERROR: space prohibited before that close parenthesis ')'
      +       if( befs_sb->num_blocks > ~((sector_t)0) ) {
      
      ERROR: space required before the open parenthesis '('
      +       if( befs_sb->num_blocks > ~((sector_t)0) ) {
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      62b80719
    • L
      befs: fix typos in linuxvfs.c · 1ca7087e
      Luis de Bethencourt 提交于
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      1ca7087e
    • L
      befs: fix style issues in io.c · 4c7df645
      Luis de Bethencourt 提交于
      Fixing the two following checkpatch.pl issues:
      ERROR: trailing whitespace
      + * Based on portions of file.c and inode.c $
      
      WARNING: labels should not be indented
      +      error:
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      4c7df645
    • L
      befs: fix style issues in inode.c · 85a06b30
      Luis de Bethencourt 提交于
      Fixing the following checkpatch.pl errors and warning:
      ERROR: trailing whitespace
      + * $
      
      WARNING: Block comments use * on subsequent lines
      +/*
      +       Validates the correctness of the befs inode
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_check_inode(struct super_block *sb, befs_inode * raw_inode,
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      85a06b30
    • L
      befs: fix style issues in debug.c · a83179a8
      Luis de Bethencourt 提交于
      Fix all checkpatch.pl errors and warnings in debug.c:
      ERROR: trailing whitespace
      + * $
      
      WARNING: Missing a blank line after declarations
      +       va_list args;
      +       va_start(args, fmt);
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_dump_inode(const struct super_block *sb, befs_inode * inode)
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_dump_super_block(const struct super_block *sb, befs_super_block * sup)
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_dump_small_data(const struct super_block *sb, befs_small_data * sd)
      
      WARNING: line over 80 characters
      +befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super * super)
      
      ERROR: "foo * bar" should be "foo *bar"
      +befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead * node)
      Signed-off-by: NLuis de Bethencourt <luisbg@osg.samsung.com>
      a83179a8
    • L
      splice: reinstate SIGPIPE/EPIPE handling · 52bce911
      Linus Torvalds 提交于
      Commit 8924feff ("splice: lift pipe_lock out of splice_to_pipe()")
      caused a regression when there were no more readers left on a pipe that
      was being spliced into: rather than the expected SIGPIPE and -EPIPE
      return value, the writer would end up waiting forever for space to free
      up (which obviously was not going to happen with no readers around).
      
      Fixes: 8924feff ("splice: lift pipe_lock out of splice_to_pipe()")
      Reported-and-tested-by: NAndreas Schwab <schwab@linux-m68k.org>
      Debugged-by: NAl Viro <viro@zeniv.linux.org.uk>
      Cc: stable@kernel.org   # v4.9
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      52bce911
  11. 20 12月, 2016 11 次提交