summaryrefslogtreecommitdiff
path: root/drivers/md
diff options
context:
space:
mode:
authorMatthias Kaehlcke <mka@chromium.org>2023-06-27 23:28:01 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-07-23 14:49:43 +0300
commit0a1dc6377afce97143c78e5d1ddccfe93767972f (patch)
treea75b43798d0934f05e84479061cb637ad60849b4 /drivers/md
parent08aaeda414f7bdea360f1ab7d3baa391d788ad43 (diff)
downloadlinux-0a1dc6377afce97143c78e5d1ddccfe93767972f.tar.xz
dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter
commit 47f04616f2c9b2f4f0c9127e30ca515a078db591 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-verity-loadpin.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/md/dm-verity-loadpin.c b/drivers/md/dm-verity-loadpin.c
index 4f78cc55c251..0666699b6858 100644
--- a/drivers/md/dm-verity-loadpin.c
+++ b/drivers/md/dm-verity-loadpin.c
@@ -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;