Fix a possible read out of bounds if bch2_ioctl_fs_usage is called when
replica_entries_bytes is set to a value that is smaller than the size
of bch_replicas_usage.
Signed-off-by: Dan Robertson <dan@dlrobertson.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
struct bch_replicas_entry *src_e =
cpu_replicas_entry(&c->replicas, i);
- if (replicas_usage_next(dst_e) > dst_end) {
+ /* check that we have enough space for one replicas entry */
+ if (dst_e + 1 > dst_end) {
ret = -ERANGE;
break;
}