mirror of
https://github.com/torvalds/linux.git
synced 2026-09-11 20:13:02 +02:00
quarantine_size tracks the total number of bytes stored in
global_quarantine[]. It is incremented when per-CPU quarantine objects
are moved into the global quarantine and decremented when a global batch
is evicted by kasan_quarantine_reduce().
kasan_quarantine_remove_cache() also removes objects from the global
quarantine. qlist_move_cache() rebuilds the source batch and updates its
.bytes field, but quarantine_size is not adjusted accordingly.
As a result, quarantine_size remains over-counted by the size of the
removed objects. The stale accounting accumulates across cache removals.
Once the inflated value exceeds quarantine_max_size,
kasan_quarantine_reduce() can evict a batch even though the actual number
of bytes in global_quarantine[] is still below quarantine_max_size,
shortening the quarantine window.
Fix the accounting by recording each batch's size before
qlist_move_cache() and subtracting the number of bytes actually removed
from quarantine_size while holding quarantine_lock.
A KUnit reproducer used during testing observed the over-count grow by
4698864 bytes after one kasan_quarantine_remove_cache() call with the fix
reverted. With this change applied, the over-count did not grow.
Link: https://lore.kernel.org/20260811073332.1351893-1-sh_def@163.com
Fixes:
|
||
|---|---|---|
| .. | ||
| common.c | ||
| generic.c | ||
| hw_tags.c | ||
| init.c | ||
| kasan_test_c.c | ||
| kasan_test_rust.rs | ||
| kasan.h | ||
| Makefile | ||
| quarantine.c | ||
| report_generic.c | ||
| report_hw_tags.c | ||
| report_sw_tags.c | ||
| report_tags.c | ||
| report.c | ||
| shadow.c | ||
| sw_tags.c | ||
| tags.c | ||