diff options
author | Richard Yao <[email protected]> | 2022-09-14 15:51:55 -0400 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2022-09-28 10:35:13 -0700 |
commit | 55816c64dadac5fecd858a88f769184283a4808b (patch) | |
tree | c34de0bd037109aed78698fafb31ee54fe91137b /module | |
parent | 8dcd6af62318a85606d664a3ba99d17b411a5892 (diff) |
FreeBSD: Fix integer conversion for vnlru_free{,_vfsops}()
When reviewing #13875, I noticed that our FreeBSD code has an issue
where it converts from `int64_t` to `int` when calling
`vnlru_free{,_vfsops}()`. The result is that if the int64_t is `1 <<
36`, the int will be 0, since the low bits are 0. Even when some low
bits are set, a value such as `((1 << 36) + 1)` would truncate to 1,
which is wrong.
There is protection against this on 32-bit platforms, but on 64-bit
platforms, there is no check to protect us, so we add a check.
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #13882
Diffstat (limited to 'module')
-rw-r--r-- | module/os/freebsd/zfs/arc_os.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/module/os/freebsd/zfs/arc_os.c b/module/os/freebsd/zfs/arc_os.c index 77af092e1..590d1c04b 100644 --- a/module/os/freebsd/zfs/arc_os.c +++ b/module/os/freebsd/zfs/arc_os.c @@ -161,6 +161,12 @@ arc_prune_task(void *arg) int64_t nr_scan = (intptr_t)arg; arc_reduce_target_size(ptob(nr_scan)); + +#ifndef __ILP32__ + if (nr_scan > INT_MAX) + nr_scan = INT_MAX; +#endif + #if __FreeBSD_version >= 1300139 sx_xlock(&arc_vnlru_lock); vnlru_free_vfsops(nr_scan, &zfs_vfsops, arc_vnlru_marker); |