[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240515014720.2482142-1-cam.alvarez.i@gmail.com>
Date: Tue, 14 May 2024 21:47:22 -0400
From: Camila Alvarez <cam.alvarez.i@...il.com>
To: Kent Overstreet <kent.overstreet@...ux.dev>
Cc: Brian Foster <bfoster@...hat.com>,
linux-bcachefs@...r.kernel.org,
linux-kernel@...r.kernel.org,
Camila Alvarez <cam.alvarez.i@...il.com>,
syzbot+249018ea545364f78d04@...kaller.appspotmail.com
Subject: [PATCH] guard against unknown r->data_type in bch2_sb_dev_has_data()
Shift is perfomed only when the data type makes sense.
Fix a missing guard on r->data_type being known.
Reported-by: syzbot+249018ea545364f78d04@...kaller.appspotmail.com
Signed-off-by: Camila Alvarez <cam.alvarez.i@...il.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
Powered by blists - more mailing lists