-----BEGIN PGP SIGNATURE-----
 
 iQEzBAABCAAdFiEEq1nRK9aeMoq1VSgcnJ2qBz9kQNkFAl/bPtUACgkQnJ2qBz9k
 QNkMAgf9EpCGLmglunFMge4vQVnsHtjOS9/yy2mQGxy2q1rVc40OtSoRouDH2AoD
 aehKE144q1OyH05jnRcUydhMFABMzyDXULGmX4kKflcaV13j7M4bXVY454mlc/D0
 kXAjKAB5j7yJySr6s+B6dhUr78y+BlCnofZZiI98TgVzNPFc3Ip075B4LOaWX1GN
 zKkvMrdOj0ESpjR6+Uvw7c/SRB+7nRSK+uASZC0oM6YPMNXm4dlHA0n1N3/8QFOb
 cz0pf0WH9XwKpDXNRH0jcFfkCajHp8gCjNbEWTGWnqpkpe3lWcvvhl5zqr+7EybU
 BYuM07QNe70FkMH1DONpgrCgEdczmQ==
 =k1fg
 -----END PGP SIGNATURE-----

Merge tag 'for_v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs

Pull ext2, reiserfs, quota and writeback updates from Jan Kara:

 - a couple of quota fixes (mostly for problems found by syzbot)

 - several ext2 cleanups

 - one fix for reiserfs crash on corrupted image

 - a fix for spurious warning in writeback code

* tag 'for_v5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jack/linux-fs:
  writeback: don't warn on an unregistered BDI in __mark_inode_dirty
  fs: quota: fix array-index-out-of-bounds bug by passing correct argument to vfs_cleanup_quota_inode()
  reiserfs: add check for an invalid ih_entry_count
  ext2: Fix fall-through warnings for Clang
  fs/ext2: Use ext2_put_page
  docs: filesystems: Reduce ext2.rst to one top-level heading
  quota: Sanity-check quota file headers on load
  quota: Don't overflow quota file offsets
  ext2: Remove unnecessary blank
  fs/quota: update quota state flags scheme with project quota flags
This commit is contained in:
Linus Torvalds 2020-12-17 11:00:37 -08:00
commit b97d4c424e
12 changed files with 61 additions and 33 deletions

View file

@ -1,6 +1,7 @@
.. SPDX-License-Identifier: GPL-2.0 .. SPDX-License-Identifier: GPL-2.0
==============================
The Second Extended Filesystem The Second Extended Filesystem
============================== ==============================

View file

@ -66,12 +66,6 @@ static inline unsigned ext2_chunk_size(struct inode *inode)
return inode->i_sb->s_blocksize; return inode->i_sb->s_blocksize;
} }
static inline void ext2_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
/* /*
* Return the offset into page `page_nr' of the last valid * Return the offset into page `page_nr' of the last valid
* byte in that page, plus one. * byte in that page, plus one.
@ -336,6 +330,8 @@ ext2_readdir(struct file *file, struct dir_context *ctx)
* returns the page in which the entry was found (as a parameter - res_page), * returns the page in which the entry was found (as a parameter - res_page),
* and the entry itself. Page is returned mapped and unlocked. * and the entry itself. Page is returned mapped and unlocked.
* Entry is guaranteed to be valid. * Entry is guaranteed to be valid.
*
* On Success ext2_put_page() should be called on *res_page.
*/ */
struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir, struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
const struct qstr *child, struct page **res_page) const struct qstr *child, struct page **res_page)
@ -401,6 +397,12 @@ struct ext2_dir_entry_2 *ext2_find_entry (struct inode *dir,
return de; return de;
} }
/**
* Return the '..' directory entry and the page in which the entry was found
* (as a parameter - p).
*
* On Success ext2_put_page() should be called on *p.
*/
struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p) struct ext2_dir_entry_2 * ext2_dotdot (struct inode *dir, struct page **p)
{ {
struct page *page = ext2_get_page(dir, 0, 0); struct page *page = ext2_get_page(dir, 0, 0);

View file

@ -16,6 +16,8 @@
#include <linux/blockgroup_lock.h> #include <linux/blockgroup_lock.h>
#include <linux/percpu_counter.h> #include <linux/percpu_counter.h>
#include <linux/rbtree.h> #include <linux/rbtree.h>
#include <linux/mm.h>
#include <linux/highmem.h>
/* XXX Here for now... not interested in restructing headers JUST now */ /* XXX Here for now... not interested in restructing headers JUST now */
@ -745,6 +747,11 @@ extern int ext2_delete_entry (struct ext2_dir_entry_2 *, struct page *);
extern int ext2_empty_dir (struct inode *); extern int ext2_empty_dir (struct inode *);
extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **); extern struct ext2_dir_entry_2 * ext2_dotdot (struct inode *, struct page **);
extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int); extern void ext2_set_link(struct inode *, struct ext2_dir_entry_2 *, struct page *, struct inode *, int);
static inline void ext2_put_page(struct page *page)
{
kunmap(page);
put_page(page);
}
/* ialloc.c */ /* ialloc.c */
extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *); extern struct inode * ext2_new_inode (struct inode *, umode_t, const struct qstr *);

View file

@ -1256,6 +1256,7 @@ static void __ext2_truncate_blocks(struct inode *inode, loff_t offset)
mark_inode_dirty(inode); mark_inode_dirty(inode);
ext2_free_branches(inode, &nr, &nr+1, 3); ext2_free_branches(inode, &nr, &nr+1, 3);
} }
break;
case EXT2_TIND_BLOCK: case EXT2_TIND_BLOCK:
; ;
} }

View file

@ -389,23 +389,18 @@ static int ext2_rename (struct inode * old_dir, struct dentry * old_dentry,
if (dir_de) { if (dir_de) {
if (old_dir != new_dir) if (old_dir != new_dir)
ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0); ext2_set_link(old_inode, dir_de, dir_page, new_dir, 0);
else { else
kunmap(dir_page); ext2_put_page(dir_page);
put_page(dir_page);
}
inode_dec_link_count(old_dir); inode_dec_link_count(old_dir);
} }
return 0; return 0;
out_dir: out_dir:
if (dir_de) { if (dir_de)
kunmap(dir_page); ext2_put_page(dir_page);
put_page(dir_page);
}
out_old: out_old:
kunmap(old_page); ext2_put_page(old_page);
put_page(old_page);
out: out:
return err; return err;
} }

View file

@ -1070,7 +1070,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
/ EXT2_BLOCKS_PER_GROUP(sb)) + 1; / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
EXT2_DESC_PER_BLOCK(sb); EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc_array (db_count, sbi->s_group_desc = kmalloc_array(db_count,
sizeof(struct buffer_head *), sizeof(struct buffer_head *),
GFP_KERNEL); GFP_KERNEL);
if (sbi->s_group_desc == NULL) { if (sbi->s_group_desc == NULL) {

View file

@ -2321,10 +2321,6 @@ void __mark_inode_dirty(struct inode *inode, int flags)
wb = locked_inode_to_wb_and_lock_list(inode); wb = locked_inode_to_wb_and_lock_list(inode);
WARN((wb->bdi->capabilities & BDI_CAP_WRITEBACK) &&
!test_bit(WB_registered, &wb->state),
"bdi-%s not registered\n", bdi_dev_name(wb->bdi));
inode->dirtied_when = jiffies; inode->dirtied_when = jiffies;
if (dirtytime) if (dirtytime)
inode->dirtied_time_when = jiffies; inode->dirtied_time_when = jiffies;

View file

@ -2455,7 +2455,7 @@ int dquot_resume(struct super_block *sb, int type)
ret = dquot_load_quota_sb(sb, cnt, dqopt->info[cnt].dqi_fmt_id, ret = dquot_load_quota_sb(sb, cnt, dqopt->info[cnt].dqi_fmt_id,
flags); flags);
if (ret < 0) if (ret < 0)
vfs_cleanup_quota_inode(sb, type); vfs_cleanup_quota_inode(sb, cnt);
} }
return ret; return ret;

View file

@ -62,7 +62,7 @@ static ssize_t read_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
memset(buf, 0, info->dqi_usable_bs); memset(buf, 0, info->dqi_usable_bs);
return sb->s_op->quota_read(sb, info->dqi_type, buf, return sb->s_op->quota_read(sb, info->dqi_type, buf,
info->dqi_usable_bs, blk << info->dqi_blocksize_bits); info->dqi_usable_bs, (loff_t)blk << info->dqi_blocksize_bits);
} }
static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf) static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
@ -71,7 +71,7 @@ static ssize_t write_blk(struct qtree_mem_dqinfo *info, uint blk, char *buf)
ssize_t ret; ssize_t ret;
ret = sb->s_op->quota_write(sb, info->dqi_type, buf, ret = sb->s_op->quota_write(sb, info->dqi_type, buf,
info->dqi_usable_bs, blk << info->dqi_blocksize_bits); info->dqi_usable_bs, (loff_t)blk << info->dqi_blocksize_bits);
if (ret != info->dqi_usable_bs) { if (ret != info->dqi_usable_bs) {
quota_error(sb, "dquota write failed"); quota_error(sb, "dquota write failed");
if (ret >= 0) if (ret >= 0)
@ -284,7 +284,7 @@ static uint find_free_dqentry(struct qtree_mem_dqinfo *info,
blk); blk);
goto out_buf; goto out_buf;
} }
dquot->dq_off = (blk << info->dqi_blocksize_bits) + dquot->dq_off = ((loff_t)blk << info->dqi_blocksize_bits) +
sizeof(struct qt_disk_dqdbheader) + sizeof(struct qt_disk_dqdbheader) +
i * info->dqi_entry_size; i * info->dqi_entry_size;
kfree(buf); kfree(buf);
@ -559,7 +559,7 @@ static loff_t find_block_dqentry(struct qtree_mem_dqinfo *info,
ret = -EIO; ret = -EIO;
goto out_buf; goto out_buf;
} else { } else {
ret = (blk << info->dqi_blocksize_bits) + sizeof(struct ret = ((loff_t)blk << info->dqi_blocksize_bits) + sizeof(struct
qt_disk_dqdbheader) + i * info->dqi_entry_size; qt_disk_dqdbheader) + i * info->dqi_entry_size;
} }
out_buf: out_buf:

View file

@ -157,6 +157,25 @@ static int v2_read_file_info(struct super_block *sb, int type)
qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk); qinfo->dqi_entry_size = sizeof(struct v2r1_disk_dqblk);
qinfo->dqi_ops = &v2r1_qtree_ops; qinfo->dqi_ops = &v2r1_qtree_ops;
} }
ret = -EUCLEAN;
/* Some sanity checks of the read headers... */
if ((loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits >
i_size_read(sb_dqopt(sb)->files[type])) {
quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).",
(loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits,
i_size_read(sb_dqopt(sb)->files[type]));
goto out;
}
if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) {
quota_error(sb, "Free block number too big (%u >= %u).",
qinfo->dqi_free_blk, qinfo->dqi_blocks);
goto out;
}
if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) {
quota_error(sb, "Block with free entry too big (%u >= %u).",
qinfo->dqi_free_entry, qinfo->dqi_blocks);
goto out;
}
ret = 0; ret = 0;
out: out:
up_read(&dqopt->dqio_sem); up_read(&dqopt->dqio_sem);

View file

@ -454,6 +454,12 @@ static int is_leaf(char *buf, int blocksize, struct buffer_head *bh)
"(second one): %h", ih); "(second one): %h", ih);
return 0; return 0;
} }
if (is_direntry_le_ih(ih) && (ih_item_len(ih) < (ih_entry_count(ih) * IH_SIZE))) {
reiserfs_warning(NULL, "reiserfs-5093",
"item entry count seems wrong %h",
ih);
return 0;
}
prev_location = ih_location(ih); prev_location = ih_location(ih);
} }

View file

@ -448,17 +448,18 @@ struct quota_format_type {
}; };
/** /**
* Quota state flags - they actually come in two flavors - for users and groups. * Quota state flags - they come in three flavors - for users, groups and projects.
* *
* Actual typed flags layout: * Actual typed flags layout:
* USRQUOTA GRPQUOTA * USRQUOTA GRPQUOTA PRJQUOTA
* DQUOT_USAGE_ENABLED 0x0001 0x0002 * DQUOT_USAGE_ENABLED 0x0001 0x0002 0x0004
* DQUOT_LIMITS_ENABLED 0x0004 0x0008 * DQUOT_LIMITS_ENABLED 0x0008 0x0010 0x0020
* DQUOT_SUSPENDED 0x0010 0x0020 * DQUOT_SUSPENDED 0x0040 0x0080 0x0100
* *
* Following bits are used for non-typed flags: * Following bits are used for non-typed flags:
* DQUOT_QUOTA_SYS_FILE 0x0040 * DQUOT_QUOTA_SYS_FILE 0x0200
* DQUOT_NEGATIVE_USAGE 0x0080 * DQUOT_NEGATIVE_USAGE 0x0400
* DQUOT_NOLIST_DIRTY 0x0800
*/ */
enum { enum {
_DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */ _DQUOT_USAGE_ENABLED = 0, /* Track disk usage for users */