mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-16 00:34:20 +08:00
bcachefs: Fix integer overflow in bch2_disk_reservation_get()
The sectors argument shouldn't have been a u32 - it can be up to U32_MAX (i.e. fallocate creating persistent reservations), and if replication is enabled we'll overflow when we calculate the real number of sectors to reserve. Oops. Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
parent
280249b9d9
commit
cd9f3dfe58
@ -2109,7 +2109,7 @@ int bch2_trans_mark_update(struct btree_trans *trans,
|
||||
#define SECTORS_CACHE 1024
|
||||
|
||||
int bch2_disk_reservation_add(struct bch_fs *c, struct disk_reservation *res,
|
||||
unsigned sectors, int flags)
|
||||
u64 sectors, int flags)
|
||||
{
|
||||
struct bch_fs_pcpu *pcpu;
|
||||
u64 old, v, get;
|
||||
|
@ -282,8 +282,8 @@ static inline void bch2_disk_reservation_put(struct bch_fs *c,
|
||||
#define BCH_DISK_RESERVATION_NOFAIL (1 << 0)
|
||||
|
||||
int bch2_disk_reservation_add(struct bch_fs *,
|
||||
struct disk_reservation *,
|
||||
unsigned, int);
|
||||
struct disk_reservation *,
|
||||
u64, int);
|
||||
|
||||
static inline struct disk_reservation
|
||||
bch2_disk_reservation_init(struct bch_fs *c, unsigned nr_replicas)
|
||||
@ -300,8 +300,7 @@ bch2_disk_reservation_init(struct bch_fs *c, unsigned nr_replicas)
|
||||
|
||||
static inline int bch2_disk_reservation_get(struct bch_fs *c,
|
||||
struct disk_reservation *res,
|
||||
unsigned sectors,
|
||||
unsigned nr_replicas,
|
||||
u64 sectors, unsigned nr_replicas,
|
||||
int flags)
|
||||
{
|
||||
*res = bch2_disk_reservation_init(c, nr_replicas);
|
||||
|
Loading…
Reference in New Issue
Block a user