mirror of
https://github.com/versity/scoutfs.git
synced 2026-08-29 04:06:57 +00:00
scoutfs: warn on invalid item counts
We had a bug where a caller was slowly increasing their item count for every transaction they attempted in a loop. Eventually the item count grew to be too large to fit in a segment and they slept indefinitely. Let's warn on invalid and impossibly large item counts as we enter transactions. Signed-off-by: Zach Brown <zab@versity.com>
This commit is contained in:
@@ -346,6 +346,15 @@ int scoutfs_hold_trans(struct super_block *sb, struct scoutfs_item_count *cnt)
|
||||
struct scoutfs_reservation *rsv;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Caller shouldn't provide garbage counts, nor counts that
|
||||
* can't fit in segments by themselves.
|
||||
*/
|
||||
if (WARN_ON_ONCE(cnt->items <= 0 || cnt->keys < 0 || cnt->vals < 0) ||
|
||||
WARN_ON_ONCE(!scoutfs_seg_fits_single(cnt->items, cnt->keys,
|
||||
cnt->vals)))
|
||||
return -EINVAL;
|
||||
|
||||
if (current == sbi->trans_task)
|
||||
return 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user