Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43be0ec0 authored by Zhu Yanhai's avatar Zhu Yanhai Committed by Ryusuke Konishi
Browse files

nilfs2: add more check routines in mount process



nilfs2: Add more safeguard routines and protections in mount process,
which also makes nilfs2 report consistency error messages when
checkpoint number is invalid.

Signed-off-by: default avatarZhu Yanhai <zhu.yanhai@gmail.com>
Signed-off-by: default avatarRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
parent a4f0b9c5
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -815,8 +815,10 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno)
	void *kaddr;
	int ret;

	if (cno == 0)
		return -ENOENT; /* checkpoint number 0 is invalid */
	/* CP number is invalid if it's zero or larger than the
	largest	exist one.*/
	if (cno == 0 || cno >= nilfs_mdt_cno(cpfile))
		return -ENOENT;
	down_read(&NILFS_MDT(cpfile)->mi_sem);

	ret = nilfs_cpfile_get_checkpoint_block(cpfile, cno, 0, &bh);
@@ -824,6 +826,9 @@ int nilfs_cpfile_is_snapshot(struct inode *cpfile, __u64 cno)
		goto out;
	kaddr = kmap_atomic(bh->b_page, KM_USER0);
	cp = nilfs_cpfile_block_get_checkpoint(cpfile, cno, bh, kaddr);
	if (nilfs_checkpoint_invalid(cp))
		ret = -ENOENT;
	else
		ret = nilfs_checkpoint_snapshot(cp);
	kunmap_atomic(kaddr, KM_USER0);
	brelse(bh);
+6 −1
Original line number Diff line number Diff line
@@ -792,10 +792,15 @@ nilfs_fill_super(struct super_block *sb, void *data, int silent,

	if (sb->s_flags & MS_RDONLY) {
		if (nilfs_test_opt(sbi, SNAPSHOT)) {
			down_read(&nilfs->ns_segctor_sem);
			err = nilfs_cpfile_is_snapshot(nilfs->ns_cpfile,
						       sbi->s_snapshot_cno);
			if (err < 0)
			up_read(&nilfs->ns_segctor_sem);
			if (err < 0) {
				if (err == -ENOENT)
					err = -EINVAL;
				goto failed_sbi;
			}
			if (!err) {
				printk(KERN_ERR
				       "NILFS: The specified checkpoint is "