ext4: avoid declaring fs inconsistent due to invalid file handles
Hello Theodore Ts'o,
The patch 6e74cde1f494: "ext4: avoid declaring fs inconsistent due to invalid file handles" from Dec 19, 2018, leads to the following static checker warning:
fs/ext4/inode.c:4841 __ext4_iget() warn: bitwise AND condition is false here
fs/ext4/inode.c
4825 struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
4826 ext4_iget_flags flags, const char *function,
4827 unsigned int line)
4828 {
4829 struct ext4_iloc iloc;
4830 struct ext4_inode *raw_inode;
4831 struct ext4_inode_info *ei;
4832 struct inode *inode;
4833 journal_t *journal = EXT4_SB(sb)->s_journal;
4834 long ret;
4835 loff_t size;
4836 int block;
4837 uid_t i_uid;
4838 gid_t i_gid;
4839 projid_t i_projid;
4840
4841 if (((flags & EXT4_IGET_NORMAL) &&
^^^^^^^^^^^^^^^^^^^^^^^^EXT4_IGET_NORMAL is zero so this condition is never true. Is this something which will depend on the CONFIG_ options or is it supposed to be flags == EXT4_IGET_NORMAL? I don't know.
4842 (ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)) ||
4843 (ino < EXT4_ROOT_INO) ||
4844 (ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) {
4845 if (flags & EXT4_IGET_HANDLE)
4846 return ERR_PTR(-ESTALE);
4847 __ext4_error(sb, function, line,
4848 "inode #%lu: comm %s: iget: illegal inode #",
4849 ino, current->comm);
4850 return ERR_PTR(-EFSCORRUPTED);
4851 }
4852
4853 inode = iget_locked(sb, ino);
4854 if (!inode)regards,
dan carpenter
Theodore Ts'o
maintainerPATCH 1/1 ext4: fix special inode number checks in __ext4_iget()
The check for special (reserved) inode number checks in __ext4_iget() was broken by commit 8a363970d1dc: ("ext4: avoid declaring fs inconsistent due to invalid file handles"). This was caused by a botched reversal of the sense of the flag now known as EXT4_IGET_SPECIAL (when it was previously named EXT4_IGET_NORMAL). Fix the logic appropriately.
--- fs/ext4/inode.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ext4/inode.c +1 -1
@@ -4834,7 +4834,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,gid_t i_gid;projid_t i_projid; -if (((flags &EXT4_IGET_NORMAL ) && +if ((!(flags &EXT4_IGET_SPECIAL ) && (ino <EXT4_FIRST_INO (sb) && ino !=EXT4_ROOT_INO )) || (ino <EXT4_ROOT_INO ) || (ino >le32_to_cpu (EXT4_SB (sb)->s_es->s_inodes_count))) {
Signature · 1 line
2.19.1