2023-06-27 20:47:19

by Matthias Kaehlcke

[permalink] [raw]
Subject: [PATCH] dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter

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: [email protected] # v6.0+
Fixes: b6c1c5745ccc ("dm: Add verity helpers for LoadPin")
Signed-off-by: Matthias Kaehlcke <[email protected]>
---

drivers/md/dm-verity-loadpin.c | 3 +++
1 file changed, 3 insertions(+)

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;

--
2.41.0.255.g8b1d071c50-goog



2023-06-28 18:02:50

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH] dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter


On Tue, 27 Jun 2023 20:28:01 +0000, Matthias Kaehlcke wrote:
> 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).
>
> [...]

Applied, thanks!

[1/1] dm: verity-loadpin: Add NULL pointer check for 'bdev' parameter
https://git.kernel.org/kees/c/47f04616f2c9

Best regards,
--
Kees Cook