mirror of
https://github.com/torvalds/linux.git
synced 2026-09-23 13:14:02 +02:00
dm-pcache: clamp the tail kset read to the segment data region
The tail-kset read in cache_replay(), the writeback worker and the GC
worker bounds its length by PCACHE_SEG_SIZE - seg_off, the raw segment
size rather than the data region. A tail near the segment end reads past
the segment data into the following control area.
Clamp the read to cache_seg_remain(), the data region.
Fixes: 1d57628ff9 ("dm-pcache: add persistent cache target in device-mapper")
Cc: stable@vger.kernel.org
Signed-off-by: Bryam Vargas <hexlabsecurity@proton.me>
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
This commit is contained in:
parent
97fc4b53db
commit
becf07e2b0
|
|
@ -37,7 +37,7 @@ static bool need_gc(struct pcache_cache *cache, struct pcache_cache_pos *dirty_t
|
|||
|
||||
kset_onmedia = (struct pcache_cache_kset_onmedia *)cache->gc_kset_onmedia_buf;
|
||||
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - key_tail->seg_off);
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(key_tail));
|
||||
ret = copy_mc_to_kernel(kset_onmedia, key_addr, to_copy);
|
||||
if (ret) {
|
||||
pcache_dev_err(pcache, "error to read kset: %d", ret);
|
||||
|
|
|
|||
|
|
@ -794,7 +794,7 @@ int cache_replay(struct pcache_cache *cache)
|
|||
__set_bit(pos->cache_seg->cache_seg_id, cache->seg_map);
|
||||
|
||||
while (true) {
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - pos->seg_off);
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(pos));
|
||||
ret = copy_mc_to_kernel(kset_onmedia, cache_pos_addr(pos), to_copy);
|
||||
if (ret) {
|
||||
ret = -EIO;
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static inline bool is_cache_clean(struct pcache_cache *cache, struct pcache_cach
|
|||
addr = cache_pos_addr(dirty_tail);
|
||||
kset_onmedia = (struct pcache_cache_kset_onmedia *)cache->wb_kset_onmedia_buf;
|
||||
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, PCACHE_SEG_SIZE - dirty_tail->seg_off);
|
||||
to_copy = min(PCACHE_KSET_ONMEDIA_SIZE_MAX, cache_seg_remain(dirty_tail));
|
||||
ret = copy_mc_to_kernel(kset_onmedia, addr, to_copy);
|
||||
if (ret) {
|
||||
pcache_dev_err(pcache, "error to read kset: %d", ret);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user