Skip to contentSkip to conversation

Misc fixes for ocfs2_read_blocks

PATCH RESEND Applied Joseph Qi 1 participant 3 messages Sep 2, 2024 OCFS2

lore
Share & tools
lore

Joseph Qi

author maintainer
#0 lore raw

v5 cover Misc fixes for ocfs2_read_blocks

This series contains 2 fixes for ocfs2_read_blocks().
The first patch fix the issue reported by syzbot, which detects bad unlock balance in ocfs2_read_blocks().
The second patch fix an issue reported by Heming Zhao when reviewing above fix.

Lizhi Xu (2):
ocfs2: remove unreasonable unlock in ocfs2_read_blocks
ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate

 fs/ocfs2/buffer_head_io.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.39.3
author maintainer
#1 lore raw

PATCH v5 1/2 ocfs2: remove unreasonable unlock in ocfs2_read_blocks

From: Lizhi Xu <[email protected]>

There was a lock release before exiting, so remove the unreasonable unlock.

Reported-and-tested-by [email protected]
Fixes cf76c78595ca ("ocfs2: don't put and assigning null to bh allocated outside")
---
 fs/ocfs2/buffer_head_io.c | 1 -
 1 file changed, 1 deletion(-)
fs/ocfs2/buffer_head_io.c +0 -1
index cdb9b9bdea1f..e62c7e1de4eb 100644
@@ -235,7 +235,6 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
 		if (bhs[i] == NULL) {
 			bhs[i] = sb_getblk(sb, block++);
 			if (bhs[i] == NULL) {
-				ocfs2_metadata_cache_io_unlock(ci);
 				status = -ENOMEM;
 				mlog_errno(status);
 				/* Don't forget to put previous bh! */
Signature · 1 line
2.39.3
author maintainer
#2 lore raw

PATCH v5 2/2 ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate

In reply to Joseph Qi

From: Lizhi Xu <[email protected]>

When doing cleanup, if flags without OCFS2_BH_READAHEAD, it may trigger NULL pointer dereference in the following ocfs2_set_buffer_uptodate() if bh is NULL.

Reported-and-suggested-by Heming Zhao <[email protected]>
Fixes cf76c78595ca ("ocfs2: don't put and assigning null to bh allocated outside")
---
 fs/ocfs2/buffer_head_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
fs/ocfs2/buffer_head_io.c +2 -1
index e62c7e1de4eb..8f714406528d 100644
@@ -388,7 +388,8 @@ int ocfs2_read_blocks(struct ocfs2_caching_info *ci, u64 block, int nr,
 		/* Always set the buffer in the cache, even if it was
 		 * a forced read, or read-ahead which hasn't yet
 		 * completed. */
-		ocfs2_set_buffer_uptodate(ci, bh);
+		if (bh)
+			ocfs2_set_buffer_uptodate(ci, bh);
 	}
 	ocfs2_metadata_cache_io_unlock(ci);
 
Signature · 1 line
2.39.3