Skip to contentSkip to conversation

autofs: Add WARN_ON(1) for non dir/link inode case

PATCH In review Tomohiro Kusumi 2 participants 3 messages Jul 4, 2016 – Jul 7, 2016 Kernel automounter

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 autofs: Add WARN_ON(1) for non dir/link inode case

It's invalid if the given mode is neither dir nor link, so warn on else case.

(v2 changed BUG_ON to WARN_ON)

---
 fs/autofs4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/autofs4/inode.c +3 -1
index ad0ee93..89174ec 100644
@@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
 	if (autofs_type_trigger(sbi->type))
 		__managed_dentry_set_managed(root);
 
+	WARN_ON(!root_inode->i_fop || !root_inode->i_op);
 	root_inode->i_fop = &autofs4_root_operations;
 	root_inode->i_op = &autofs4_dir_inode_operations;
 
@@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb, umode_t mode)
 		inode->i_fop = &autofs4_dir_operations;
 	} else if (S_ISLNK(mode)) {
 		inode->i_op = &autofs4_symlink_inode_operations;
-	}
+	} else
+		WARN_ON(1);
 
 	return inode;
 }
Signature · 4 lines
2.5.5

--
To unsubscribe from this list: send the line "unsubscribe autofs" in
maintainer
#1 lore raw
Quoted 2 lines · Tomohiro Kusumi

It's invalid if the given mode is neither dir nor link, so warn on else case.

I've added this too.

But ....

Quoted 13 lines

(v2 changed BUG_ON to WARN_ON)

---
 fs/autofs4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/autofs4/inode.c +0 -0
index ad0ee93..89174ec 100644

fs/autofs4/inode.c int autofs4_fill_super(struct super_block *s, void *data, · line 309

Quoted 5 lines
fs/autofs4/inode.c +1 -0
@@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data,
 int silent)
 	if (autofs_type_trigger(sbi->type))
 		__managed_dentry_set_managed(root);
 
+	WARN_ON(!root_inode->i_fop || !root_inode->i_op);

I'm dropping this.

We know for a fact that this is a directory inode because above it was created with autofs4_get_inode(s, S_IFDIR | 0755) and here the operations are changed to those specific to the root inode.

Quoted 13 lines
fs/autofs4/inode.c +2 -1
 	root_inode->i_fop = &autofs4_root_operations;
 	root_inode->i_op = &autofs4_dir_inode_operations;
@@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb,
 umode_t mode)
 		inode->i_fop = &autofs4_dir_operations;
 	} else if (S_ISLNK(mode)) {
 		inode->i_op = &autofs4_symlink_inode_operations;
-	}
+	} else
+		WARN_ON(1);
 
 	return inode;
Quoted 1 line

}

--
To unsubscribe from this list: send the line "unsubscribe autofs" in

#2 lore raw

Sure, thank you for applying.

2016-07-07 15:09 GMT+09:00 Ian Kent <[email protected]>:

Quoted 45 lines · Tomohiro Kusumi
Quoted 2 lines

It's invalid if the given mode is neither dir nor link, so warn on else case.

I've added this too.

But ....

Quoted 13 lines

(v2 changed BUG_ON to WARN_ON)

---
 fs/autofs4/inode.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/autofs4/inode.c +0 -0
index ad0ee93..89174ec 100644

fs/autofs4/inode.c int autofs4_fill_super(struct super_block *s, void *data, · line 309

Quoted 5 lines
fs/autofs4/inode.c +1 -0
@@ -305,6 +305,7 @@ int autofs4_fill_super(struct super_block *s, void *data,
 int silent)
      if (autofs_type_trigger(sbi->type))
              __managed_dentry_set_managed(root);
 
+     WARN_ON(!root_inode->i_fop || !root_inode->i_op);

I'm dropping this.

We know for a fact that this is a directory inode because above it was created with autofs4_get_inode(s, S_IFDIR | 0755) and here the operations are changed to those specific to the root inode.

Quoted 12 lines
fs/autofs4/inode.c +2 -1
      root_inode->i_fop = &autofs4_root_operations;
      root_inode->i_op = &autofs4_dir_inode_operations;
@@ -368,7 +369,8 @@ struct inode *autofs4_get_inode(struct super_block *sb,
 umode_t mode)
              inode->i_fop = &autofs4_dir_operations;
      } else if (S_ISLNK(mode)) {
              inode->i_op = &autofs4_symlink_inode_operations;
-     }
+     } else
+             WARN_ON(1);
 
Quoted 2 lines
Quoted 2 lines
fs/autofs4/inode.c +0 -0
      return inode;

}

--
To unsubscribe from this list: send the line "unsubscribe autofs" in