mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data()
@ 2024-05-15  1:47 Camila Alvarez
  2024-05-19 23:48 ` Kent Overstreet
  0 siblings, 1 reply; 2+ messages in thread
From: Camila Alvarez @ 2024-05-15  1:47 UTC (permalink / raw)
  To: Kent Overstreet
  Cc: Brian Foster, linux-bcachefs, linux-kernel, Camila Alvarez,
	syzbot+249018ea545364f78d04

Shift is perfomed only when the data type makes sense.

Fix a missing guard on r->data_type being known.

Reported-by: syzbot+249018ea545364f78d04@syzkaller.appspotmail.com
Signed-off-by: Camila Alvarez <cam.alvarez.i@gmail.com>
---
 fs/bcachefs/replicas.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/bcachefs/replicas.c b/fs/bcachefs/replicas.c
index 678b9c20e251..0fa91d0bf951 100644
--- a/fs/bcachefs/replicas.c
+++ b/fs/bcachefs/replicas.c
@@ -1006,14 +1006,14 @@ unsigned bch2_sb_dev_has_data(struct bch_sb *sb, unsigned dev)
 
 		for_each_replicas_entry(replicas, r)
 			for (i = 0; i < r->nr_devs; i++)
-				if (r->devs[i] == dev)
+				if (r->devs[i] == dev && r->data_type < BCH_DATA_NR)
 					data_has |= 1 << r->data_type;
 	} else if (replicas_v0) {
 		struct bch_replicas_entry_v0 *r;
 
 		for_each_replicas_entry_v0(replicas_v0, r)
 			for (i = 0; i < r->nr_devs; i++)
-				if (r->devs[i] == dev)
+				if (r->devs[i] == dev && r->data_type < BCH_DATA_NR)
 					data_has |= 1 << r->data_type;
 	}
 
-- 
2.34.1


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

end of thread, other threads:[~2024-05-19 23:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-15  1:47 [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data() Camila Alvarez
2024-05-19 23:48 ` Kent Overstreet

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®