1. 22 Jan, 2020 8 commits
    • Daniel Rosenberg's avatar
      fscrypt: improve format of no-key names · edc440e3
      Daniel Rosenberg authored
      When an encrypted directory is listed without the key, the filesystem
      must show "no-key names" that uniquely identify directory entries, are
      at most 255 (NAME_MAX) bytes long, and don't contain '/' or '\0'.
      Currently, for short names the no-key name is the base64 encoding of the
      ciphertext filename, while for long names it's the base64 encoding of
      the ciphertext filename's dirhash and second-to-last 16-byte block.
      
      This format has the following problems:
      
      - Since it doesn't always include the dirhash, it's incompatible with
        directories that will use a secret-keyed dirhash over the plaintext
        filenames.  In this case, the dirhash won't be computable from the
        ciphertext name without the key, so it instead must be retrieved from
        the directory entry and always included in the no-key name.
        Casefolded encrypted directories will use this type of dirhash.
      
      - It's ambiguous: it's possible to craft two filenames that map to the
        same no-key name, since the method used to abbreviate long filenames
        doesn't use a proper cryptographic hash function.
      
      Solve both these problems by switching to a new no-key name format that
      is the base64 encoding of a variable-length structure that contains the
      dirhash, up to 149 bytes of the ciphertext filename, and (if any bytes
      remain) the SHA-256 of the remaining bytes of the ciphertext filename.
      
      This ensures that each no-key name contains everything needed to find
      the directory entry again, contains only legal characters, doesn't
      exceed NAME_MAX, is unambiguous unless there's a SHA-256 collision, and
      that we only take the performance hit of SHA-256 on very long filenames.
      
      Note: this change does *not* address the existing issue where users can
      modify the 'dirhash' part of a no-key name and the filesystem may still
      accept the name.
      Signed-off-by: default avatarDaniel Rosenberg <drosen@google.com>
      [EB: improved comments and commit message, fixed checking return value
       of base64_decode(), check for SHA-256 error, continue to set disk_name
       for short names to keep matching simpler, and many other cleanups]
      Link: https://lore.kernel.org/r/20200120223201.241390-7-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      edc440e3
    • Eric Biggers's avatar
      ubifs: allow both hash and disk name to be provided in no-key names · aec992aa
      Eric Biggers authored
      In order to support a new dirhash method that is a secret-keyed hash
      over the plaintext filenames (which will be used by encrypted+casefolded
      directories on ext4 and f2fs), fscrypt will be switching to a new no-key
      name format that always encodes the dirhash in the name.
      
      UBIFS isn't happy with this because it has assertions that verify that
      either the hash or the disk name is provided, not both.
      
      Change it to use the disk name if one is provided, even if a hash is
      available too; else use the hash.
      
      Link: https://lore.kernel.org/r/20200120223201.241390-6-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      aec992aa
    • Eric Biggers's avatar
      ubifs: don't trigger assertion on invalid no-key filename · f0d07a98
      Eric Biggers authored
      If userspace provides an invalid fscrypt no-key filename which encodes a
      hash value with any of the UBIFS node type bits set (i.e. the high 3
      bits), gracefully report ENOENT rather than triggering ubifs_assert().
      
      Test case with kvm-xfstests shell:
      
          . fs/ubifs/config
          . ~/xfstests/common/encrypt
          dev=$(__blkdev_to_ubi_volume /dev/vdc)
          ubiupdatevol $dev -t
          mount $dev /mnt -t ubifs
          mkdir /mnt/edir
          xfs_io -c set_encpolicy /mnt/edir
          rm /mnt/edir/_,,,,,DAAAAAAAAAAAAAAAAAAAAAAAAAA
      
      With the bug, the following assertion fails on the 'rm' command:
      
          [   19.066048] UBIFS error (ubi0:0 pid 379): ubifs_assert_failed: UBIFS assert failed: !(hash & ~UBIFS_S_KEY_HASH_MASK), in fs/ubifs/key.h:170
      
      Fixes: f4f61d2c ("ubifs: Implement encrypted filenames")
      Cc: <stable@vger.kernel.org> # v4.10+
      Link: https://lore.kernel.org/r/20200120223201.241390-5-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      f0d07a98
    • Eric Biggers's avatar
      fscrypt: clarify what is meant by a per-file key · f592efe7
      Eric Biggers authored
      Now that there's sometimes a second type of per-file key (the dirhash
      key), clarify some function names, macros, and documentation that
      specifically deal with per-file *encryption* keys.
      
      Link: https://lore.kernel.org/r/20200120223201.241390-4-ebiggers@kernel.orgReviewed-by: default avatarDaniel Rosenberg <drosen@google.com>
      Signed-off-by: default avatarEric Biggers <ebiggers@google.com>
      f592efe7
    • Daniel Rosenberg's avatar
      fscrypt: derive dirhash key for casefolded directories · aa408f83
      Daniel Rosenberg authored
      When we allow indexed directories to use both encryption and
      casefolding, for the dirhash we can't just hash the ciphertext filenames
      that are stored on-disk (as is done currently) because the dirhash must
      be case insensitive, but the stored names are case-preserving.  Nor can
      we hash the plaintext names with an unkeyed hash (or a hash keyed with a
      value stored on-disk like ext4's s_hash_seed), since that would leak
      information about the names that encryption is meant to protect.
      
      Instead, if we can accept a dirhash that's only computable when the
      fscrypt key is available, we can hash the plaintext names with a keyed
      hash using a secret key derived from the directory's fscrypt master key.
      We'll use SipHash-2-4 for this purpose.
      
      Prepare for this by deriving a SipHash key for each casefolded encrypted
      directory.  Make sure to handle deriving the key not only when setting
      up the directory's fscrypt_info, but also in the case where the casefold
      flag is enabled after the fscrypt_info was already set up.  (We could
      just always derive the key regardless of casefolding, but that would
      introduce unnecessary overhead for people not using casefolding.)
      Signed-off-by: default avatarDaniel Rosenberg <drosen@google.com>
      [EB: improved commit message, updated fscrypt.rst, squashed with change
       that avoids unnecessarily deriving the key, and many other cleanups]
      Link: https://lore.kernel.org/r/20200120223201.241390-3-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      aa408f83
    • Daniel Rosenberg's avatar
      fscrypt: don't allow v1 policies with casefolding · 6e1918cf
      Daniel Rosenberg authored
      Casefolded encrypted directories will use a new dirhash method that
      requires a secret key.  If the directory uses a v2 encryption policy,
      it's easy to derive this key from the master key using HKDF.  However,
      v1 encryption policies don't provide a way to derive additional keys.
      
      Therefore, don't allow casefolding on directories that use a v1 policy.
      Specifically, make it so that trying to enable casefolding on a
      directory that has a v1 policy fails, trying to set a v1 policy on a
      casefolded directory fails, and trying to open a casefolded directory
      that has a v1 policy (if one somehow exists on-disk) fails.
      Signed-off-by: default avatarDaniel Rosenberg <drosen@google.com>
      [EB: improved commit message, updated fscrypt.rst, and other cleanups]
      Link: https://lore.kernel.org/r/20200120223201.241390-2-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      6e1918cf
    • Eric Biggers's avatar
      fscrypt: add "fscrypt_" prefix to fname_encrypt() · 1b3b827e
      Eric Biggers authored
      fname_encrypt() is a global function, due to being used in both fname.c
      and hooks.c.  So it should be prefixed with "fscrypt_", like all the
      other global functions in fs/crypto/.
      
      Link: https://lore.kernel.org/r/20200120071736.45915-1-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      1b3b827e
    • Eric Biggers's avatar
      fscrypt: don't print name of busy file when removing key · 13a10da9
      Eric Biggers authored
      When an encryption key can't be fully removed due to file(s) protected
      by it still being in-use, we shouldn't really print the path to one of
      these files to the kernel log, since parts of this path are likely to be
      encrypted on-disk, and (depending on how the system is set up) the
      confidentiality of this path might be lost by printing it to the log.
      
      This is a trade-off: a single file path often doesn't matter at all,
      especially if it's a directory; the kernel log might still be protected
      in some way; and I had originally hoped that any "inode(s) still busy"
      bugs (which are security weaknesses in their own right) would be quickly
      fixed and that to do so it would be super helpful to always know the
      file path and not have to run 'find dir -inum $inum' after the fact.
      
      But in practice, these bugs can be hard to fix (e.g. due to asynchronous
      process killing that is difficult to eliminate, for performance
      reasons), and also not tied to specific files, so knowing a file path
      doesn't necessarily help.
      
      So to be safe, for now let's just show the inode number, not the path.
      If someone really wants to know a path they can use 'find -inum'.
      
      Fixes: b1c0ec35 ("fscrypt: add FS_IOC_REMOVE_ENCRYPTION_KEY ioctl")
      Cc: <stable@vger.kernel.org> # v5.4+
      Link: https://lore.kernel.org/r/20200120060732.390362-1-ebiggers@kernel.orgSigned-off-by: default avatarEric Biggers <ebiggers@google.com>
      13a10da9
  2. 20 Jan, 2020 1 commit
  3. 14 Jan, 2020 2 commits
  4. 31 Dec, 2019 15 commits
  5. 29 Dec, 2019 5 commits
  6. 28 Dec, 2019 4 commits
  7. 27 Dec, 2019 5 commits
    • Linus Torvalds's avatar
      Merge tag 'drm-fixes-2019-12-28' of git://anongit.freedesktop.org/drm/drm · 48a8dd17
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Post-xmas food coma recovery fixes. Only three fixes for i915 since I
        expect most people are holidaying.
      
        i915:
         - power management rc6 fix
         - framebuffer tracking fix
         - display power management ratelimit fix"
      
      * tag 'drm-fixes-2019-12-28' of git://anongit.freedesktop.org/drm/drm:
        drm/i915: Hold reference to intel_frontbuffer as we track activity
        drm/i915/gt: Ratelimit display power w/a
        drm/i915/pmu: Ensure monotonic rc6
      48a8dd17
    • Linus Torvalds's avatar
      Merge tag 'linux-kselftest-5.5-rc4' of... · f4b39746
      Linus Torvalds authored
      Merge tag 'linux-kselftest-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
      
      Pull Kselftest fixes from Shuah Khan:
      
       - rseq build failures fixes related to glibc 2.30 compatibility from
         Mathieu Desnoyers
      
       - Kunit fixes and cleanups from SeongJae Park
      
       - Fixes to filesystems/epoll, firmware, and livepatch build failures
         and skip handling.
      
      * tag 'linux-kselftest-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
        rseq/selftests: Clarify rseq_prepare_unload() helper requirements
        rseq/selftests: Fix: Namespace gettid() for compatibility with glibc 2.30
        rseq/selftests: Turn off timeout setting
        kunit/kunit_tool_test: Test '--build_dir' option run
        kunit: Rename 'kunitconfig' to '.kunitconfig'
        kunit: Place 'test.log' under the 'build_dir'
        kunit: Create default config in '--build_dir'
        kunit: Remove duplicated defconfig creation
        docs/kunit/start: Use in-tree 'kunit_defconfig'
        selftests: livepatch: Fix it to do root uid check and skip
        selftests: firmware: Fix it to do root uid check and skip
        selftests: filesystems/epoll: fix build error
      f4b39746
    • Linus Torvalds's avatar
      Merge tag 'pm-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 1413c361
      Linus Torvalds authored
      Pull power management fixes from Rafael Wysocki:
       "Fix compile test of the Tegra devfreq driver (Arnd Bergmann) and
        remove redundant Kconfig dependencies from multiple devfreq drivers
        (Leonard Crestez)"
      
      * tag 'pm-5.5-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        PM / devfreq: tegra: Add COMMON_CLK dependency
        PM / devfreq: Drop explicit selection of PM_OPP
      1413c361
    • Linus Torvalds's avatar
      Merge tag 'io_uring-5.5-20191226' of git://git.kernel.dk/linux-block · 534121d2
      Linus Torvalds authored
      Pull io_uring fixes from Jens Axboe:
      
       - Removal of now unused busy wqe list (Hillf)
      
       - Add cond_resched() to io-wq work processing (Hillf)
      
       - And then the series that I hinted at from last week, which removes
         the sqe from the io_kiocb and keeps all sqe handling on the prep
         side. This guarantees that an opcode can't do the wrong thing and
         read the sqe more than once. This is unchanged from last week, no
         issues have been observed with this in testing. Hence I really think
         we should fold this into 5.5.
      
      * tag 'io_uring-5.5-20191226' of git://git.kernel.dk/linux-block:
        io-wq: add cond_resched() to worker thread
        io-wq: remove unused busy list from io_sqe
        io_uring: pass in 'sqe' to the prep handlers
        io_uring: standardize the prep methods
        io_uring: read 'count' for IORING_OP_TIMEOUT in prep handler
        io_uring: move all prep state for IORING_OP_{SEND,RECV}_MGS to prep handler
        io_uring: move all prep state for IORING_OP_CONNECT to prep handler
        io_uring: add and use struct io_rw for read/writes
        io_uring: use u64_to_user_ptr() consistently
      534121d2
    • Linus Torvalds's avatar
      Merge tag 'libata-5.5-20191226' of git://git.kernel.dk/linux-block · 0f710a55
      Linus Torvalds authored
      Pull libata fixes from Jens Axboe:
       "Two things in here:
      
         - First half of a series that fixes ahci_brcm, also marked for
           stable. The other part of the series is going into 5.6 (Florian)
      
         - sata_nv regression fix that is also marked for stable (Sascha)"
      
      * tag 'libata-5.5-20191226' of git://git.kernel.dk/linux-block:
        ata: ahci_brcm: Add missing clock management during recovery
        ata: ahci_brcm: BCM7425 AHCI requires AHCI_HFLAG_DELAY_ENGINE
        ata: ahci_brcm: Fix AHCI resources management
        ata: libahci_platform: Export again ahci_platform_<en/dis>able_phys()
        libata: Fix retrieving of active qcs
      0f710a55