dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter
authorMatthias Kaehlcke <mka@chromium.org>
Tue, 27 Jun 2023 20:28:01 +0000 (20:28 +0000)
committerKees Cook <keescook@chromium.org>
Wed, 28 Jun 2023 17:43:04 +0000 (10:43 -0700)
Add a NULL check for the 'bdev' parameter of
dm_verity_loadpin_is_bdev_trusted(). The function is called
by loadpin_check(), which passes the block device that
corresponds to the super block of the file system from which
a file is being loaded. Generally a super_block structure has
an associated block device, however that is not always the
case (e.g. tmpfs).

Cc: stable@vger.kernel.org # v6.0+
Fixes: b6c1c5745ccc ("dm: Add verity helpers for LoadPin")
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Link: https://lore.kernel.org/r/20230627202800.1.Id63f7f59536d20f1ab83e1abdc1fda1471c7d031@changeid
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/md/dm-verity-loadpin.c

index 4f78cc55c2514e6329d9780939d320e53faa743d..0666699b6858166227131e17a0da99e5ae22a4c2 100644 (file)
@@ -58,6 +58,9 @@ bool dm_verity_loadpin_is_bdev_trusted(struct block_device *bdev)
        int srcu_idx;
        bool trusted = false;
 
+       if (bdev == NULL)
+               return false;
+
        if (list_empty(&dm_verity_loadpin_trusted_root_digests))
                return false;