diff options
author | Benjamin Marzinski <bmarzins@redhat.com> | 2023-02-01 00:22:57 +0300 |
---|---|---|
committer | Mike Snitzer <snitzer@kernel.org> | 2023-02-12 18:20:56 +0300 |
commit | d1c0e1587e6874cec3e3615097b907a9186505c8 (patch) | |
tree | d93603f706cbc7767739a9cb2ff4d1bf35c2dcdf | |
parent | efdd3c3375aa09dd52284b645cbf0eb367f0e258 (diff) | |
download | linux-d1c0e1587e6874cec3e3615097b907a9186505c8.tar.xz |
dm table: check that a dm device doesn't reference itself
If a DM device's table references itself, it will crash the kernel with an
infinite recursion. Check for a self-reference in dm_get_device(). This
is a quick check, but it won't catch more complicated circular references.
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@kernel.org>
-rw-r--r-- | drivers/md/dm-table.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index 8541d5688f3a..24ad42b385c1 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c @@ -364,6 +364,8 @@ int dm_get_device(struct dm_target *ti, const char *path, fmode_t mode, if (!dev) return -ENODEV; } + if (dev == disk_devt(t->md->disk)) + return -EINVAL; dd = find_device(&t->devices, dev); if (!dd) { |