Skip to content

Commit

Permalink
Merge tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kern…
Browse files Browse the repository at this point in the history
…el/git/tytso/ext4

Pull ext4 updates from Ted Ts'o:
 "The major change this cycle is deleting ext4's copy of the file system
  encryption code and switching things over to using the copies in
  fs/crypto.  I've updated the MAINTAINERS file to add an entry for
  fs/crypto listing Jaeguk Kim and myself as the maintainers.

  There are also a number of bug fixes, most notably for some problems
  found by American Fuzzy Lop (AFL) courtesy of Vegard Nossum.  Also
  fixed is a writeback deadlock detected by generic/130, and some
  potential races in the metadata checksum code"

* tag 'ext4_for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: (21 commits)
  ext4: verify extent header depth
  ext4: short-cut orphan cleanup on error
  ext4: fix reference counting bug on block allocation error
  MAINTAINRES: fs-crypto maintainers update
  ext4 crypto: migrate into vfs's crypto engine
  ext2: fix filesystem deadlock while reading corrupted xattr block
  ext4: fix project quota accounting without quota limits enabled
  ext4: validate s_reserved_gdt_blocks on mount
  ext4: remove unused page_idx
  ext4: don't call ext4_should_journal_data() on the journal inode
  ext4: Fix WARN_ON_ONCE in ext4_commit_super()
  ext4: fix deadlock during page writeback
  ext4: correct error value of function verifying dx checksum
  ext4: avoid modifying checksum fields directly during checksum verification
  ext4: check for extents that wrap around
  jbd2: make journal y2038 safe
  jbd2: track more dependencies on transaction commit
  jbd2: move lockdep tracking to journal_s
  jbd2: move lockdep instrumentation for jbd2 handles
  ext4: respect the nobarrier mount option in nojournal mode
  ...
  • Loading branch information
Linus Torvalds committed Jul 27, 2016
2 parents 59ebc44 + 7bc9491 commit 396d109
Show file tree
Hide file tree
Showing 34 changed files with 538 additions and 2,103 deletions.
7 changes: 7 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -4942,6 +4942,13 @@ F: Documentation/filesystems/caching/
F: fs/fscache/
F: include/linux/fscache*.h

FS-CRYPTO: FILE SYSTEM LEVEL ENCRYPTION SUPPORT
M: Theodore Y. Ts'o <tytso@mit.edu>
M: Jaegeuk Kim <jaegeuk@kernel.org>
S: Supported
F: fs/crypto/
F: include/linux/fscrypto.h

F2FS FILE SYSTEM
M: Jaegeuk Kim <jaegeuk@kernel.org>
M: Changman Lee <cm224.lee@samsung.com>
Expand Down
21 changes: 21 additions & 0 deletions fs/ext2/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,27 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
return 1;
}

/*
* Returns 1 if the passed-in block region is valid; 0 if some part overlaps
* with filesystem metadata blocksi.
*/
int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
unsigned int count)
{
if ((start_blk <= le32_to_cpu(sbi->s_es->s_first_data_block)) ||
(start_blk + count < start_blk) ||
(start_blk > le32_to_cpu(sbi->s_es->s_blocks_count)))
return 0;

/* Ensure we do not step over superblock */
if ((start_blk <= sbi->s_sb_block) &&
(start_blk + count >= sbi->s_sb_block))
return 0;


return 1;
}

/*
* ext2_new_blocks() -- core block(s) allocation function
* @inode: file inode
Expand Down
3 changes: 3 additions & 0 deletions fs/ext2/ext2.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ struct ext2_inode {
*/
#define EXT2_VALID_FS 0x0001 /* Unmounted cleanly */
#define EXT2_ERROR_FS 0x0002 /* Errors detected */
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */

/*
* Mount flags
Expand Down Expand Up @@ -739,6 +740,8 @@ extern unsigned long ext2_bg_num_gdb(struct super_block *sb, int group);
extern ext2_fsblk_t ext2_new_block(struct inode *, unsigned long, int *);
extern ext2_fsblk_t ext2_new_blocks(struct inode *, unsigned long,
unsigned long *, int *);
extern int ext2_data_block_valid(struct ext2_sb_info *sbi, ext2_fsblk_t start_blk,
unsigned int count);
extern void ext2_free_blocks (struct inode *, unsigned long,
unsigned long);
extern unsigned long ext2_count_free_blocks (struct super_block *);
Expand Down
10 changes: 10 additions & 0 deletions fs/ext2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,16 @@ struct inode *ext2_iget (struct super_block *sb, unsigned long ino)
ei->i_frag_size = raw_inode->i_fsize;
ei->i_file_acl = le32_to_cpu(raw_inode->i_file_acl);
ei->i_dir_acl = 0;

if (ei->i_file_acl &&
!ext2_data_block_valid(EXT2_SB(sb), ei->i_file_acl, 1)) {
ext2_error(sb, "ext2_iget", "bad extended attribute block %u",
ei->i_file_acl);
brelse(bh);
ret = -EFSCORRUPTED;
goto bad_inode;
}

if (S_ISREG(inode->i_mode))
inode->i_size |= ((__u64)le32_to_cpu(raw_inode->i_size_high)) << 32;
else
Expand Down
9 changes: 9 additions & 0 deletions fs/ext2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,19 @@ void
ext2_xattr_delete_inode(struct inode *inode)
{
struct buffer_head *bh = NULL;
struct ext2_sb_info *sbi = EXT2_SB(inode->i_sb);

down_write(&EXT2_I(inode)->xattr_sem);
if (!EXT2_I(inode)->i_file_acl)
goto cleanup;

if (!ext2_data_block_valid(sbi, EXT2_I(inode)->i_file_acl, 0)) {
ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
"inode %ld: xattr block %d is out of data blocks range",
inode->i_ino, EXT2_I(inode)->i_file_acl);
goto cleanup;
}

bh = sb_bread(inode->i_sb, EXT2_I(inode)->i_file_acl);
if (!bh) {
ext2_error(inode->i_sb, "ext2_xattr_delete_inode",
Expand Down
12 changes: 2 additions & 10 deletions fs/ext4/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,9 @@ config EXT4_FS_SECURITY
extended attributes for file security labels, say N.

config EXT4_ENCRYPTION
tristate "Ext4 Encryption"
bool "Ext4 Encryption"
depends on EXT4_FS
select CRYPTO_AES
select CRYPTO_CBC
select CRYPTO_ECB
select CRYPTO_XTS
select CRYPTO_CTS
select CRYPTO_CTR
select CRYPTO_SHA256
select KEYS
select ENCRYPTED_KEYS
select FS_ENCRYPTION
help
Enable encryption of ext4 files and directories. This
feature is similar to ecryptfs, but it is more memory
Expand Down
2 changes: 0 additions & 2 deletions fs/ext4/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ ext4-y := balloc.o bitmap.o dir.o file.o fsync.o ialloc.o inode.o page-io.o \

ext4-$(CONFIG_EXT4_FS_POSIX_ACL) += acl.o
ext4-$(CONFIG_EXT4_FS_SECURITY) += xattr_security.o
ext4-$(CONFIG_EXT4_FS_ENCRYPTION) += crypto_policy.o crypto.o \
crypto_key.o crypto_fname.o
7 changes: 6 additions & 1 deletion fs/ext4/balloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ static int ext4_init_block_bitmap(struct super_block *sb,
memset(bh->b_data, 0, sb->s_blocksize);

bit_max = ext4_num_base_meta_clusters(sb, block_group);
if ((bit_max >> 3) >= bh->b_size)
return -EFSCORRUPTED;

for (bit = 0; bit < bit_max; bit++)
ext4_set_bit(bit, bh->b_data);

Expand Down Expand Up @@ -610,7 +613,9 @@ int ext4_should_retry_alloc(struct super_block *sb, int *retries)

jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id);

jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
smp_mb();
if (EXT4_SB(sb)->s_mb_free_pending)
jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal);
return 1;
}

Expand Down
Loading

0 comments on commit 396d109

Please sign in to comment.