dm-verity: fix dm_is_verity_target() when dm-verity is builtin
Subsystems (3)
PATCH 1/1 dm-verity: fix dm_is_verity_target() when dm-verity is builtin
From: Eric Biggers <[email protected]>
When CONFIG_DM_VERITY=y, dm_is_verity_target() returned true for any builtin dm target, not just dm-verity. Fix this by checking for verity_target instead of THIS_MODULE (which is NULL for builtin code).
Fixes b6c1c5745ccc ("dm: Add verity helpers for LoadPin")
Cc Matthias Kaehlcke <[email protected]>
Cc Kees Cook <[email protected]>
Signed-off-by Eric Biggers <[email protected]>
--- drivers/md/dm-verity-target.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/md/dm-verity-target.c +8 -8
@@ -1519,18 +1519,10 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv)verity_dtr (ti);return r; } -/* -* Check whether a DM target is a verity target. -*/ -bool dm_is_verity_target (struct dm_target *ti) -{ -return ti->type->module ==THIS_MODULE ; -} -/* * Get the verity mode (error behavior) of a verity target. * * Returns the verity mode of the target, or -EINVAL if 'ti' is not a verity * target.
@@ -1580,10 +1572,18 @@ static struct target_type verity_target = { .iterate_devices = verity_iterate_devices, .io_hints = verity_io_hints, };module_dm (verity); +/* +* Check whether a DM target is a verity target. +*/ +bool dm_is_verity_target (struct dm_target *ti) +{ +return ti->type == &verity_target; +} +MODULE_AUTHOR ("Mikulas Patocka <[email protected]>" );MODULE_AUTHOR ("Mandeep Baines <[email protected]>" );MODULE_AUTHOR ("Will Drewry <[email protected]>" );MODULE_DESCRIPTION (DM_NAME " target for transparent disk integrity checking" );MODULE_LICENSE ("GPL" );
base-commit: ed28fe59c042e9b5bf3b15050aa6ee67834dc852
Signature · 1 line
2.45.2
Quoted 11 lines · Eric Biggers
From: Eric Biggers <[email protected]>
When
CONFIG_DM_VERITY=y,dm_is_verity_target()returned true for any builtin dm target, not just dm-verity. Fix this by checking forverity_targetinstead ofTHIS_MODULE(which is NULL for builtin code).Fixes b6c1c5745ccc ("dm: Add verity helpers for LoadPin")Cc Matthias Kaehlcke <[email protected]>Cc Kees Cook <[email protected]>Signed-off-by Eric Biggers <[email protected]>
Ah! Nice catch.
Reviewed-by Kees Cook <[email protected]>
Signature · 1 line
Kees Cook