[PATCH v2 04/11] dm-pcache: bound the persisted tail-position offset
Bryam Vargas via B4 Relay <[email protected]> Fri, 17 Jul 2026 06:26:57 -0500
| Newsgroups | dev.linux.lists.dm-devel,org.kernel.feeds.b4-sent,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
From: Bryam Vargas <[email protected]> cache_pos_decode() takes the persisted key_tail and dirty_tail seg_off from the cache device and addresses within the segment with it. A seg_off at or past the segment data_size, controllable by whoever supplies the device (CAP_SYS_ADMIN), reads past the segment data. Reject a decoded seg_off that is not below the segment data_size. Fixes: 1d57628ff95b ("dm-pcache: add persistent cache target in device-mapper") Cc: [email protected] Signed-off-by: Bryam Vargas <[email protected]> --- drivers/md/dm-pcache/cache.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/md/dm-pcache/cache.c b/drivers/md/dm-pcache/cache.c index e4784578b9af..a94eadb7affd 100644 --- a/drivers/md/dm-pcache/cache.c +++ b/drivers/md/dm-pcache/cache.c @@ -122,6 +122,10 @@ int cache_pos_decode(struct pcache_cache *cache, return -EIO; pos->cache_seg = &cache->segments[latest.cache_seg_id]; + + if (latest.seg_off >= pos->cache_seg->segment.data_size) + return -EIO; + pos->seg_off = latest.seg_off; *seq = latest.header.seq; *index = (latest_addr - pos_onmedia); -- 2.43.0