Skip to content

Commit 5c41f75

Browse files
name2965Kent Overstreet
authored andcommitted
bcachefs: fix shift oob in alloc_lru_idx_fragmentation
The size of a.data_type is set abnormally large, causing shift-out-of-bounds. To fix this, we need to add validation on a.data_type in alloc_lru_idx_fragmentation(). Reported-by: [email protected] Fixes: 260af15 ("bcachefs: Kill alloc_v4.fragmentation_lru") Signed-off-by: Jeongjun Park <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 2045fc4 commit 5c41f75

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/bcachefs/alloc_background.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,9 @@ static inline bool data_type_movable(enum bch_data_type type)
168168
static inline u64 alloc_lru_idx_fragmentation(struct bch_alloc_v4 a,
169169
struct bch_dev *ca)
170170
{
171+
if (a.data_type >= BCH_DATA_NR)
172+
return 0;
173+
171174
if (!data_type_movable(a.data_type) ||
172175
!bch2_bucket_sectors_fragmented(ca, a))
173176
return 0;

0 commit comments

Comments
 (0)