Unverified Commit a41e8dae authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11574 nilfs2: add missing check for inode numbers on directory entries

parents a0db09dd f79abe9f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -143,6 +143,9 @@ static bool nilfs_check_page(struct page *page)
			goto Enamelen;
		if (((offs + rec_len - 1) ^ offs) & ~(chunk_size-1))
			goto Espan;
		if (unlikely(p->inode &&
			     NILFS_PRIVATE_INODE(le64_to_cpu(p->inode))))
			goto Einumber;
	}
	if (offs != limit)
		goto Eend;
@@ -168,6 +171,9 @@ static bool nilfs_check_page(struct page *page)
	goto bad_entry;
Espan:
	error = "directory entry across blocks";
	goto bad_entry;
Einumber:
	error = "disallowed inode number";
bad_entry:
	nilfs_error(sb,
		    "bad entry in directory #%lu: %s - offset=%lu, inode=%lu, rec_len=%d, name_len=%d",
+5 −0
Original line number Diff line number Diff line
@@ -121,6 +121,11 @@ enum {
	((ino) >= NILFS_FIRST_INO(sb) ||				\
	 ((ino) < NILFS_USER_INO && (NILFS_SYS_INO_BITS & BIT(ino))))

#define NILFS_PRIVATE_INODE(ino) ({					\
	ino_t __ino = (ino);						\
	((__ino) < NILFS_USER_INO && (__ino) != NILFS_ROOT_INO &&	\
	 (__ino) != NILFS_SKETCH_INO); })

/**
 * struct nilfs_transaction_info: context information for synchronization
 * @ti_magic: Magic number