Commit bcba013
committed
fix memory corruption by read from removed items
An item unregistered via procstat_remove may still be reached by fuse_read():
the item itself has refcnt held from fuse_open.
In such case, the owner may have freed the item stat memory,
which is still ok to read.
HOWEVER, writing to this memory is prohibited and may cause memory corruption.
Write is possible only for series (see is_reset() and clear_values_...)
called from e.g. series_u64_read().
The item itself may not be marked as unregistered (refcnt != 0 in item_put_locked),
but since series are removed by directory we can rely on parent
being marked as unregistered by procstat_remove().
Same applies to reads by aggregator_read().
NOTE: after procstat_remove() releases the mutex, changes to the item (flags)
should be observable by fuse_read() and aggregator_read() from other cpus.
- fuse_read() does not take the mutex, so this is suspicious.
- aggregator_read() does, so the protection is clean.
The recommendation is not not read series stats that may be removed
(volumes) unless via an aggregator.
Issue: LBM1-15406
Signed-off-by: Anton Eidelman <anton@lightbitslabs.com>1 parent c09dba2 commit bcba013
1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
549 | 553 | | |
550 | 554 | | |
551 | 555 | | |
| |||
693 | 697 | | |
694 | 698 | | |
695 | 699 | | |
696 | | - | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
697 | 709 | | |
698 | 710 | | |
699 | 711 | | |
| |||
0 commit comments