Skip to contentSkip to conversation

f2fs: avoid stale fi->gdirty_list pointer

PATCH In review Jaegeuk Kim 3 participants 5 messages Oct 13, 2017 – Oct 17, 2017

Subsystems (2)
lore
Share & tools
lore

Jaegeuk Kim

author maintainer
#0 lore raw

PATCH 1/1 f2fs: avoid stale fi->gdirty_list pointer

When doing fault injection test, f2fs_evict_inode() didn't remove gdirty_list which incurs a kernel panic due to wrong pointer access.

---
 fs/f2fs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inode.c +2 -0
index f6db9d533ca4..1ae5396c97d6 100644
@@ -535,6 +535,8 @@ void f2fs_evict_inode(struct inode *inode)
 
 	if (!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
 		f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
+	else
+		f2fs_inode_synced(inode);
 
 	/* ino == 0, if f2fs_new_inode() was failed t*/
 	if (inode->i_ino)
Signature · 1 line
2.14.0.rc1.383.gd1ce394fe2-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Jaegeuk Kim

When doing fault injection test, f2fs_evict_inode() didn't remove gdirty_list which incurs a kernel panic due to wrong pointer access.

Minor thing, how about reverting judgment condition for readability?

if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG))

	f2fs_inode_synced()
else
	f2fs_bug_on()

Thanks,

Quoted 18 lines
---
 fs/f2fs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inode.c +2 -0
index f6db9d533ca4..1ae5396c97d6 100644
@@ -535,6 +535,8 @@ void f2fs_evict_inode(struct inode *inode)
 
 	if (!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
 		f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
+	else
+		f2fs_inode_synced(inode);
 
 	/* ino == 0, if f2fs_new_inode() was failed t*/
 	if (inode->i_ino)
author maintainer
#2 lore raw
Quoted 4 lines · Chao Yu
Quoted 3 lines · Jaegeuk Kim

When doing fault injection test, f2fs_evict_inode() didn't remove gdirty_list which incurs a kernel panic due to wrong pointer access.

Quoted 8 lines
Quoted 1 line

Minor thing, how about reverting judgment condition for readability?

if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG))

	f2fs_inode_synced()

We don't need to expect such the errored corner case first. ;)

Quoted 23 lines

else

	f2fs_bug_on()

Thanks,

Quoted 18 lines
---
 fs/f2fs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inode.c +2 -0
index f6db9d533ca4..1ae5396c97d6 100644
@@ -535,6 +535,8 @@ void f2fs_evict_inode(struct inode *inode)
 
 	if (!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
 		f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
+	else
+		f2fs_inode_synced(inode);
 
 	/* ino == 0, if f2fs_new_inode() was failed t*/
 	if (inode->i_ino)
maintainer
#3 lore raw
Quoted 7 lines · Jaegeuk Kim
Quoted 6 lines · Chao Yu
Quoted 4 lines · Jaegeuk Kim

When doing fault injection test, f2fs_evict_inode() didn't remove gdirty_list which incurs a kernel panic due to wrong pointer access.

Quoted 8 lines
Quoted 6 lines

Minor thing, how about reverting judgment condition for readability?

if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG))

	f2fs_inode_synced()

We don't need to expect such the errored corner case first. ;)

Alright, making compiler being aware of this by using {un,}likely? :)

Thanks,

Quoted 33 lines
Quoted 16 lines

else

	f2fs_bug_on()

Thanks,

Quoted 10 lines
---
 fs/f2fs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inode.c +0 -0
index f6db9d533ca4..1ae5396c97d6 100644
@@ -535,6 +535,8 @@ void f2fs_evict_inode(struct inode *inode)
 
Quoted 8 lines

fs/f2fs/inode.c void f2fs_evict_inode(struct inode *inode) · line 542

Quoted 8 lines
fs/f2fs/inode.c +2 -0
 	if (!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
 		f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
+	else
+		f2fs_inode_synced(inode);
 
 	/* ino == 0, if f2fs_new_inode() was failed t*/
 	if (inode->i_ino)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

author maintainer
#4 lore raw
Quoted 10 lines · Chao Yu
Quoted 9 lines · Jaegeuk Kim
Quoted 8 lines · Chao Yu
Quoted 4 lines · Jaegeuk Kim

When doing fault injection test, f2fs_evict_inode() didn't remove gdirty_list which incurs a kernel panic due to wrong pointer access.

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

Minor thing, how about reverting judgment condition for readability?

if (is_set_ckpt_flags(sbi, CP_ERROR_FLAG))

	f2fs_inode_synced()

We don't need to expect such the errored corner case first. ;)

Alright, making compiler being aware of this by using {un,}likely? :)

Yup, added. ;)

Quoted 36 lines

Thanks,

Quoted 33 lines
Quoted 16 lines

else

	f2fs_bug_on()

Thanks,

Quoted 10 lines
---
 fs/f2fs/inode.c | 2 ++
 1 file changed, 2 insertions(+)
fs/f2fs/inode.c +0 -0
index f6db9d533ca4..1ae5396c97d6 100644
@@ -535,6 +535,8 @@ void f2fs_evict_inode(struct inode *inode)
 
Quoted 8 lines

fs/f2fs/inode.c void f2fs_evict_inode(struct inode *inode) · line 542

Quoted 8 lines
fs/f2fs/inode.c +2 -0
 	if (!is_set_ckpt_flags(sbi, CP_ERROR_FLAG))
 		f2fs_bug_on(sbi, is_inode_flag_set(inode, FI_DIRTY_INODE));
+	else
+		f2fs_inode_synced(inode);
 
 	/* ino == 0, if f2fs_new_inode() was failed t*/
 	if (inode->i_ino)

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel