mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5 RESEND 0/2] Misc fixes for ocfs2_read_blocks
@ 2024-09-02  2:36 Joseph Qi
  2024-09-02  2:36 ` [PATCH v5 1/2] ocfs2: remove unreasonable unlock in ocfs2_read_blocks Joseph Qi
  2024-09-02  2:36 ` [PATCH v5 2/2] ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate Joseph Qi
  0 siblings, 2 replies; 3+ messages in thread
From: Joseph Qi @ 2024-09-02  2:36 UTC (permalink / raw)
  To: Andrew Morton, Lizhi Xu, Heming Zhao
  Cc: ocfs2-devel, linux-kernel, jlbec, mark,
	syzbot+ab134185af9ef88dfed5, syzkaller-bugs

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(-)

-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v5 1/2] ocfs2: remove unreasonable unlock in ocfs2_read_blocks
  2024-09-02  2:36 [PATCH v5 RESEND 0/2] Misc fixes for ocfs2_read_blocks Joseph Qi
@ 2024-09-02  2:36 ` Joseph Qi
  2024-09-02  2:36 ` [PATCH v5 2/2] ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate Joseph Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2024-09-02  2:36 UTC (permalink / raw)
  To: Andrew Morton, Lizhi Xu, Heming Zhao
  Cc: ocfs2-devel, linux-kernel, jlbec, mark,
	syzbot+ab134185af9ef88dfed5, syzkaller-bugs

From: Lizhi Xu <lizhi.xu@windriver.com>

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

Reported-and-tested-by: syzbot+ab134185af9ef88dfed5@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=ab134185af9ef88dfed5
Fixes: cf76c78595ca ("ocfs2: don't put and assigning null to bh allocated outside")
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Cc: stable@vger.kernel.org # 4.20+
Reviewed-by: Heming Zhao <heming.zhao@suse.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
 fs/ocfs2/buffer_head_io.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index cdb9b9bdea1f..e62c7e1de4eb 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -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! */
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v5 2/2] ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate
  2024-09-02  2:36 [PATCH v5 RESEND 0/2] Misc fixes for ocfs2_read_blocks Joseph Qi
  2024-09-02  2:36 ` [PATCH v5 1/2] ocfs2: remove unreasonable unlock in ocfs2_read_blocks Joseph Qi
@ 2024-09-02  2:36 ` Joseph Qi
  1 sibling, 0 replies; 3+ messages in thread
From: Joseph Qi @ 2024-09-02  2:36 UTC (permalink / raw)
  To: Andrew Morton, Lizhi Xu, Heming Zhao
  Cc: ocfs2-devel, linux-kernel, jlbec, mark,
	syzbot+ab134185af9ef88dfed5, syzkaller-bugs

From: Lizhi Xu <lizhi.xu@windriver.com>

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 <heming.zhao@suse.com>
Fixes: cf76c78595ca ("ocfs2: don't put and assigning null to bh allocated outside")
Cc: stable@vger.kernel.org # 4.20+
Signed-off-by: Lizhi Xu <lizhi.xu@windriver.com>
Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
---
 fs/ocfs2/buffer_head_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/buffer_head_io.c b/fs/ocfs2/buffer_head_io.c
index e62c7e1de4eb..8f714406528d 100644
--- a/fs/ocfs2/buffer_head_io.c
+++ b/fs/ocfs2/buffer_head_io.c
@@ -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);
 
-- 
2.39.3


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-02  2:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-02  2:36 [PATCH v5 RESEND 0/2] Misc fixes for ocfs2_read_blocks Joseph Qi
2024-09-02  2:36 ` [PATCH v5 1/2] ocfs2: remove unreasonable unlock in ocfs2_read_blocks Joseph Qi
2024-09-02  2:36 ` [PATCH v5 2/2] ocfs2: Fix possible null-ptr-deref in ocfs2_set_buffer_uptodate Joseph Qi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®