Skip to contentSkip to conversation

md/raid5: fix NULL pointer dereference in raid5_has_ppl

PATCH In review Svyatoslav Nikolenko 2 participants 2 messages Sep 22 – Sep 23 MD RAID

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 md/raid5: fix NULL pointer dereference in raid5_has_ppl

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.

---
 drivers/md/raid5-log.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/raid5-log.h +1 -1
index c8332502669e..5a144051b142 100644
@@ -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)
Signature · 1 line
2.47.3
maintainer
#1 lore raw

Hi,

Quoted 9 lines · Svyatoslav Nikolenko

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.

---
  drivers/md/raid5-log.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Looks like this is already fixed by:

https://patch.msgid.link/[email protected]

Quoted 14 lines
drivers/md/raid5-log.h +1 -1
index c8332502669e..5a144051b142 100644
@@ -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)
Signature · 2 lines
Thanks,
Kuai