summaryrefslogtreecommitdiff
path: root/rust/kernel/alloc
diff options
context:
space:
mode:
authorMing-Hung Tsai <mtsai@redhat.com>2026-11-06 19:59:22 +0100
committerMikulas Patocka <mpatocka@redhat.com>2026-11-06 20:41:03 +0100
commitc834161ded1a141a58d5f03b24f6894291222c96 (patch)
treee3c2bcac6e2f5fba8e38fff83ca3c081ee4ad0f1 /rust/kernel/alloc
parentb27523a0781aae0b51ac13f29dc65373d14b8434 (diff)
dm: fix use-after-free when dm_get_device() widens the open mode
There's an UAF bug in dm_get_device(): when a table construction calls dm_get_device() on the same device twice with widen access mode (e.g., read-only first then read-write), the second dm_get_device() calls upgrade_mode(), which reopens the device in upgraded mode, making previously returned dm_dev* a stale pointer. Fixing approaches: - Add per-mode views (dm_dev_ref) from a per-device dm_dev_internal to multiple table_devices. - Keep reusing the dm_dev_ref when the requested mode is included, i.e., a read-only reference can reuse the read-write opened device within a table. - Maintain a canonical block_device pointer in dm_dev_internal for handling the DM_TABLE_DEPS ioctl. Also tweak the way of mode sharing check in find_ref() to "(x & mask) == mask". The result stays the same to the previous upgrade_mode() guard "(x | mask) == x". Pros: keep the relationship between dm_dev_internal and table_device: one dm_dev_internal per device, regardless the mode, so the output of DMM_TABLE_DEPS ioctl unchanged. Cons: extra dm_dev_ref allocation. Note that now the table_device's count not necessarily mean the number tables referecing this <dev, mode> pair, since we're allowing multiple references within a table. Signed-off-by: Ming Hung Tsai <mtsai@redhat.com> Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Fixes: 86f1152b117a ("dm: allow active and inactive tables to share dm_devs") Cc: stable@vger.kernel.org
Diffstat (limited to 'rust/kernel/alloc')
0 files changed, 0 insertions, 0 deletions