Forwarded: [PATCH] md/raid5: fix NULL pointer dereference in raid5_has_ppl

syzbot posted 1 patch 2 days, 3 hours ago
drivers/md/raid5-log.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Forwarded: [PATCH] md/raid5: fix NULL pointer dereference in raid5_has_ppl
Posted by syzbot 2 days, 3 hours ago
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com.

***

Subject: [PATCH] md/raid5: fix NULL pointer dereference in raid5_has_ppl
Author: nsvatoslav515@gmail.com

Check if conf->mddev is non-NULL in raid5_has_ppl() before testing flags to
prevent a KASAN null-ptr-deref during free_conf() cleanup paths.

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git f0100363d8c3

Signed-off-by: Svyatoslav Nikolenko <nsvatoslav515@gmail.com>
---
 drivers/md/raid5-log.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/md/raid5-log.h b/drivers/md/raid5-log.h
index c8332502669e..5a144051b142 100644
--- a/drivers/md/raid5-log.h
+++ b/drivers/md/raid5-log.h
@@ -51,7 +51,7 @@ static inline bool raid5_has_log(struct r5conf *conf)
 
 static inline bool raid5_has_ppl(struct r5conf *conf)
 {
-	return test_bit(MD_HAS_PPL, &conf->mddev->flags);
+	return conf->mddev && test_bit(MD_HAS_PPL, &conf->mddev->flags);
 }
 
 static inline int log_stripe(struct stripe_head *sh, struct stripe_head_state *s)
-- 
2.47.3