]> Git Repo - linux.git/commitdiff
Merge tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso...
authorLinus Torvalds <[email protected]>
Tue, 5 Jun 2018 22:15:32 +0000 (15:15 -0700)
committerLinus Torvalds <[email protected]>
Tue, 5 Jun 2018 22:15:32 +0000 (15:15 -0700)
Pull fscrypt updates from Ted Ts'o:
 "Add bunch of cleanups, and add support for the Speck128/256
  algorithms.

  Yes, Speck is contrversial, but the intention is to use them only for
  the lowest end Android devices, where the alternative *really* is no
  encryption at all for data stored at rest"

* tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt:
  fscrypt: log the crypto algorithm implementations
  fscrypt: add Speck128/256 support
  fscrypt: only derive the needed portion of the key
  fscrypt: separate key lookup from key derivation
  fscrypt: use a common logging function
  fscrypt: remove internal key size constants
  fscrypt: remove unnecessary check for non-logon key type
  fscrypt: make fscrypt_operations.max_namelen an integer
  fscrypt: drop empty name check from fname_decrypt()
  fscrypt: drop max_namelen check from fname_decrypt()
  fscrypt: don't special-case EOPNOTSUPP from fscrypt_get_encryption_info()
  fscrypt: don't clear flags on crypto transform
  fscrypt: remove stale comment from fscrypt_d_revalidate()
  fscrypt: remove error messages for skcipher_request_alloc() failure
  fscrypt: remove unnecessary NULL check when allocating skcipher
  fscrypt: clean up after fscrypt_prepare_lookup() conversions
  fs, fscrypt: only define ->s_cop when FS_ENCRYPTION is enabled
  fscrypt: use unbound workqueue for decryption

1  2 
fs/ext4/super.c
include/linux/fs.h
include/uapi/linux/fs.h

diff --combined fs/ext4/super.c
index 7022d843c667e6b2a0ce593055278c26b6b2631d,502c36da292c7180d4f62665e37f9a6d4608756a..00fe75a71c4b6a2bd6b6afb7c49e8dd02e67c963
@@@ -763,36 -763,6 +763,36 @@@ __acquires(bitlock
        return;
  }
  
 +void ext4_mark_group_bitmap_corrupted(struct super_block *sb,
 +                                   ext4_group_t group,
 +                                   unsigned int flags)
 +{
 +      struct ext4_sb_info *sbi = EXT4_SB(sb);
 +      struct ext4_group_info *grp = ext4_get_group_info(sb, group);
 +      struct ext4_group_desc *gdp = ext4_get_group_desc(sb, group, NULL);
 +
 +      if ((flags & EXT4_GROUP_INFO_BBITMAP_CORRUPT) &&
 +          !EXT4_MB_GRP_BBITMAP_CORRUPT(grp)) {
 +              percpu_counter_sub(&sbi->s_freeclusters_counter,
 +                                      grp->bb_free);
 +              set_bit(EXT4_GROUP_INFO_BBITMAP_CORRUPT_BIT,
 +                      &grp->bb_state);
 +      }
 +
 +      if ((flags & EXT4_GROUP_INFO_IBITMAP_CORRUPT) &&
 +          !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {
 +              if (gdp) {
 +                      int count;
 +
 +                      count = ext4_free_inodes_count(sb, gdp);
 +                      percpu_counter_sub(&sbi->s_freeinodes_counter,
 +                                         count);
 +              }
 +              set_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT,
 +                      &grp->bb_state);
 +      }
 +}
 +
  void ext4_update_dynamic_rev(struct super_block *sb)
  {
        struct ext4_super_block *es = EXT4_SB(sb)->s_es;
@@@ -1267,19 -1237,13 +1267,13 @@@ static bool ext4_dummy_context(struct i
        return DUMMY_ENCRYPTION_ENABLED(EXT4_SB(inode->i_sb));
  }
  
- static unsigned ext4_max_namelen(struct inode *inode)
- {
-       return S_ISLNK(inode->i_mode) ? inode->i_sb->s_blocksize :
-               EXT4_NAME_LEN;
- }
  static const struct fscrypt_operations ext4_cryptops = {
        .key_prefix             = "ext4:",
        .get_context            = ext4_get_context,
        .set_context            = ext4_set_context,
        .dummy_context          = ext4_dummy_context,
        .empty_dir              = ext4_empty_dir,
-       .max_namelen            = ext4_max_namelen,
+       .max_namelen            = EXT4_NAME_LEN,
  };
  #endif
  
@@@ -2146,12 -2110,12 +2140,12 @@@ static int ext4_setup_super(struct supe
                            int read_only)
  {
        struct ext4_sb_info *sbi = EXT4_SB(sb);
 -      int res = 0;
 +      int err = 0;
  
        if (le32_to_cpu(es->s_rev_level) > EXT4_MAX_SUPP_REV) {
                ext4_msg(sb, KERN_ERR, "revision level too high, "
                         "forcing read-only mode");
 -              res = SB_RDONLY;
 +              err = -EROFS;
        }
        if (read_only)
                goto done;
        if (sbi->s_journal)
                ext4_set_feature_journal_needs_recovery(sb);
  
 -      ext4_commit_super(sb, 1);
 +      err = ext4_commit_super(sb, 1);
  done:
        if (test_opt(sb, DEBUG))
                printk(KERN_INFO "[EXT4 FS bs=%lu, gc=%u, "
                        sbi->s_mount_opt, sbi->s_mount_opt2);
  
        cleancache_init_fs(sb);
 -      return res;
 +      return err;
  }
  
  int ext4_alloc_flex_bg_array(struct super_block *sb, ext4_group_t ngroup)
@@@ -3762,7 -3726,8 +3756,7 @@@ static int ext4_fill_super(struct super
                                        " that may contain inline data");
                        sbi->s_mount_opt &= ~EXT4_MOUNT_DAX;
                }
 -              err = bdev_dax_supported(sb, blocksize);
 -              if (err) {
 +              if (!bdev_dax_supported(sb->s_bdev, blocksize)) {
                        ext4_msg(sb, KERN_ERR,
                                "DAX unsupported by block device. Turning off DAX.");
                        sbi->s_mount_opt &= ~EXT4_MOUNT_DAX;
@@@ -4253,12 -4218,8 +4247,12 @@@ no_journal
                goto failed_mount4;
        }
  
 -      if (ext4_setup_super(sb, es, sb_rdonly(sb)))
 +      ret = ext4_setup_super(sb, es, sb_rdonly(sb));
 +      if (ret == -EROFS) {
                sb->s_flags |= SB_RDONLY;
 +              ret = 0;
 +      } else if (ret)
 +              goto failed_mount4a;
  
        /* determine the minimum size of new large inodes, if present */
        if (sbi->s_inode_size > EXT4_GOOD_OLD_INODE_SIZE &&
@@@ -4793,7 -4754,11 +4787,7 @@@ static int ext4_commit_super(struct sup
                unlock_buffer(sbh);
                error = __sync_dirty_buffer(sbh,
                        REQ_SYNC | (test_opt(sb, BARRIER) ? REQ_FUA : 0));
 -              if (error)
 -                      return error;
 -
 -              error = buffer_write_io_error(sbh);
 -              if (error) {
 +              if (buffer_write_io_error(sbh)) {
                        ext4_msg(sb, KERN_ERR, "I/O error while writing "
                               "superblock");
                        clear_buffer_write_io_error(sbh);
@@@ -5194,12 -5159,8 +5188,12 @@@ static int ext4_remount(struct super_bl
                        if (sbi->s_journal)
                                ext4_clear_journal_err(sb, es);
                        sbi->s_mount_state = le16_to_cpu(es->s_state);
 -                      if (!ext4_setup_super(sb, es, 0))
 -                              sb->s_flags &= ~SB_RDONLY;
 +
 +                      err = ext4_setup_super(sb, es, 0);
 +                      if (err)
 +                              goto restore_opts;
 +
 +                      sb->s_flags &= ~SB_RDONLY;
                        if (ext4_has_feature_mmp(sb))
                                if (ext4_multi_mount_protect(sb,
                                                le64_to_cpu(es->s_mmp_block))) {
        }
  
        ext4_setup_system_zone(sb);
 -      if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY))
 -              ext4_commit_super(sb, 1);
 +      if (sbi->s_journal == NULL && !(old_sb_flags & SB_RDONLY)) {
 +              err = ext4_commit_super(sb, 1);
 +              if (err)
 +                      goto restore_opts;
 +      }
  
  #ifdef CONFIG_QUOTA
        /* Release old quota file names */
@@@ -5288,8 -5246,7 +5282,8 @@@ static int ext4_statfs_project(struct s
                 dquot->dq_dqb.dqb_bsoftlimit :
                 dquot->dq_dqb.dqb_bhardlimit) >> sb->s_blocksize_bits;
        if (limit && buf->f_blocks > limit) {
 -              curblock = dquot->dq_dqb.dqb_curspace >> sb->s_blocksize_bits;
 +              curblock = (dquot->dq_dqb.dqb_curspace +
 +                          dquot->dq_dqb.dqb_rsvspace) >> sb->s_blocksize_bits;
                buf->f_blocks = limit;
                buf->f_bfree = buf->f_bavail =
                        (buf->f_blocks > curblock) ?
diff --combined include/linux/fs.h
index f4b8c8dc67e3fcc9b29db8adcff46042d2b4aca1,8e2460694c3ae2d63f2058bdeebcc44bf5d08b9d..7ef7193488b843085eec6ed6d80acb0a2c1c9e2b
@@@ -94,7 -94,7 +94,7 @@@ typedef int (dio_iodone_t)(struct kioc
  
  /*
   * flags in file.f_mode.  Note that FMODE_READ and FMODE_WRITE must correspond
 - * to O_WRONLY and O_RDWR via the strange trick in __dentry_open()
 + * to O_WRONLY and O_RDWR via the strange trick in do_dentry_open()
   */
  
  /* file is open for reading */
@@@ -1250,7 -1250,7 +1250,7 @@@ static inline int locks_lock_file_wait(
  }
  
  struct fasync_struct {
 -      spinlock_t              fa_lock;
 +      rwlock_t                fa_lock;
        int                     magic;
        int                     fa_fd;
        struct fasync_struct    *fa_next; /* singly linked list */
@@@ -1364,9 -1364,9 +1364,9 @@@ struct super_block 
        void                    *s_security;
  #endif
        const struct xattr_handler **s_xattr;
+ #if IS_ENABLED(CONFIG_FS_ENCRYPTION)
        const struct fscrypt_operations *s_cop;
+ #endif
        struct hlist_bl_head    s_roots;        /* alternate root dentries for NFS */
        struct list_head        s_mounts;       /* list of mounts; _not_ for fs use */
        struct block_device     *s_bdev;
@@@ -1597,11 -1597,6 +1597,11 @@@ static inline void sb_start_intwrite(st
        __sb_start_write(sb, SB_FREEZE_FS, true);
  }
  
 +static inline int sb_start_intwrite_trylock(struct super_block *sb)
 +{
 +      return __sb_start_write(sb, SB_FREEZE_FS, false);
 +}
 +
  
  extern bool inode_owner_or_capable(const struct inode *inode);
  
@@@ -1716,8 -1711,6 +1716,8 @@@ struct file_operations 
        int (*iterate) (struct file *, struct dir_context *);
        int (*iterate_shared) (struct file *, struct dir_context *);
        __poll_t (*poll) (struct file *, struct poll_table_struct *);
 +      struct wait_queue_head * (*get_poll_head)(struct file *, __poll_t);
 +      __poll_t (*poll_mask) (struct file *, __poll_t);
        long (*unlocked_ioctl) (struct file *, unsigned int, unsigned long);
        long (*compat_ioctl) (struct file *, unsigned int, unsigned long);
        int (*mmap) (struct file *, struct vm_area_struct *);
@@@ -2577,7 -2570,7 +2577,7 @@@ extern bool is_bad_inode(struct inode *
  
  #ifdef CONFIG_BLOCK
  extern void check_disk_size_change(struct gendisk *disk,
 -                                 struct block_device *bdev);
 +              struct block_device *bdev, bool verbose);
  extern int revalidate_disk(struct gendisk *);
  extern int check_disk_change(struct block_device *);
  extern int __invalidate_device(struct block_device *, bool);
diff --combined include/uapi/linux/fs.h
index 9d132f8f2df8cc56d6202ce33f3a00cc14bd6ebb,0b6e07ee63a67d3f8005d4c28388df1d1ba867e1..73e01918f99634294c0e064a95e57f8eb30434e8
@@@ -242,8 -242,6 +242,8 @@@ struct fsxattr 
  #define FICLONERANGE  _IOW(0x94, 13, struct file_clone_range)
  #define FIDEDUPERANGE _IOWR(0x94, 54, struct file_dedupe_range)
  
 +#define FSLABEL_MAX 256       /* Max chars for the interface; each fs may differ */
 +
  #define       FS_IOC_GETFLAGS                 _IOR('f', 1, long)
  #define       FS_IOC_SETFLAGS                 _IOW('f', 2, long)
  #define       FS_IOC_GETVERSION               _IOR('v', 1, long)
  #define FS_IOC32_SETFLAGS             _IOW('f', 2, int)
  #define FS_IOC32_GETVERSION           _IOR('v', 1, int)
  #define FS_IOC32_SETVERSION           _IOW('v', 2, int)
 -#define FS_IOC_FSGETXATTR             _IOR ('X', 31, struct fsxattr)
 -#define FS_IOC_FSSETXATTR             _IOW ('X', 32, struct fsxattr)
 +#define FS_IOC_FSGETXATTR             _IOR('X', 31, struct fsxattr)
 +#define FS_IOC_FSSETXATTR             _IOW('X', 32, struct fsxattr)
 +#define FS_IOC_GETFSLABEL             _IOR(0x94, 49, char[FSLABEL_MAX])
 +#define FS_IOC_SETFSLABEL             _IOW(0x94, 50, char[FSLABEL_MAX])
  
  /*
   * File system encryption support
  #define FS_ENCRYPTION_MODE_AES_256_CTS                4
  #define FS_ENCRYPTION_MODE_AES_128_CBC                5
  #define FS_ENCRYPTION_MODE_AES_128_CTS                6
+ #define FS_ENCRYPTION_MODE_SPECK128_256_XTS   7
+ #define FS_ENCRYPTION_MODE_SPECK128_256_CTS   8
  
  struct fscrypt_policy {
        __u8 version;
This page took 0.079872 seconds and 4 git commands to generate.