-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On Tue, Feb 07, 2023 at 10:21:40PM -0600, Benjamin Marzinski wrote: > If a dm device 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@xxxxxxxxxx> > --- > drivers/md/dm-table.c | 2 ++ > 1 file changed, 2 insertions(+) > > 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) { > -- > 2.30.2 I like this! More generally, should the kernel fail with -ELOOP if devices are stacked too deeply? - -- Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEdodNnxM2uiJZBxxxsoi1X/+cIsEFAmPjJhYACgkQsoi1X/+c IsHwnRAAsJgax1pLhHw0jvXgbwb+XGM+j2bHwg/9DsmTakxAlJgDYAUGhC4wIu3n bWzs0TY0ON0h6BAVm4+xUFBCpQpSZTf2Z95YCHHvhj2ImEdSYrbk+ccnZaXhaP5f mUFEG7PmBA6Zl/xJvAwZgG4V/Szp73UdlSe+Ph3qcjNf/+n2EznZBFjXpO45PGaL xvd7D7QcqEbhiH5kDVvZibX4Np2xWecbIYNoGuiCf+tnUVM+QyFIMiLZhWS+nZ4y QOzcn7gG5543dSlwnKJJXKmW/LBXqNAzyLvhqxWX/5ExwENQxEQ5fQ/w1EcuIgLq EaNCm7yCabgG11d6En4er2etUB9Q2mowugSvdzryblF01x0GMz2aqFQ12Ogbag9t 8t1sHx+ohk03H4vjbT3NJZnqDsTmAYVV7v/nxCKYot3EcylB0R9b3BIeRoKYiFK0 f/1ap8MfvHE/Nc4hyVapD6DOQ3Gn9ZK5Y6eNrpzlG6C5JVjWJjB8tCoON8upgj3t 5P77sFVVczj2/Uu8T+1uhYQ9XSnFREsQGSEULZoA60MAwRktyhQVGTMwTLnX/BVg kHpCeaFnEN1IZ1R5PFZXoPPztPcnZG1ZjMjrpqjKqd1Udokqti+i9vf3sAI7mfo3 mvB4XyxH6PdLz2UD1GvTvF2DKKyJeE2W4ezCxSBSNHhrMIwaPvE= =Kzsf -----END PGP SIGNATURE----- -- dm-devel mailing list dm-devel@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/dm-devel