From: Deven Bowers Subject: [RFC PATCH v6 08/11] dm-verity: add bdev_setsecurity hook for root-hash Date: Wed, 29 Jul 2020 17:31:10 -0700 Message-ID: <20200730003113.2561644-9-deven.desai@linux.microsoft.com> References: <20200730003113.2561644-1-deven.desai@linux.microsoft.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20200730003113.2561644-1-deven.desai@linux.microsoft.com> Sender: linux-kernel-owner@vger.kernel.org To: agk@redhat.com, axboe@kernel.dk, snitzer@redhat.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, viro@zeniv.linux.org.uk, paul@paul-moore.com, eparis@redhat.com, jannh@google.com, dm-devel@redhat.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-audit@redhat.com Cc: tyhicks@linux.microsoft.com, linux-kernel@vger.kernel.org, corbet@lwn.net, sashal@kernel.org, jaskarankhurana@linux.microsoft.com, mdsakib@microsoft.com, nramas@linux.microsoft.com, pasha.tatashin@soleen.com List-Id: dm-devel.ids Add a security hook call to set a security property of a block_device in dm-verity with the root-hash that was passed to device-mapper. Signed-off-by: Deven Bowers --- drivers/md/dm-verity-target.c | 8 ++++++++ include/linux/device-mapper.h | 1 + 2 files changed, 9 insertions(+) diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index 9970488e67ed..44914668398d 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c @@ -16,8 +16,10 @@ #include "dm-verity.h" #include "dm-verity-fec.h" #include "dm-verity-verify-sig.h" +#include "dm-core.h" #include #include +#include #define DM_MSG_PREFIX "verity" @@ -1207,6 +1209,12 @@ static int verity_ctr(struct dm_target *ti, unsigned argc, char **argv) ti->per_io_data_size = roundup(ti->per_io_data_size, __alignof__(struct dm_verity_io)); + r = security_bdev_setsecurity(dm_table_get_md(v->ti->table)->bdev, + DM_VERITY_ROOTHASH_SEC_NAME, + v->root_digest, v->digest_size); + if (r) + goto bad; + verity_verify_sig_opts_cleanup(&verify_args); return 0; diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index ab6b8eb0a150..e8ef887e4bae 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -626,5 +626,6 @@ static inline unsigned long to_bytes(sector_t n) } #define DM_VERITY_SIGNATURE_SEC_NAME DM_NAME ".verity-sig" +#define DM_VERITY_ROOTHASH_SEC_NAME DM_NAME ".verity-rh" #endif /* _LINUX_DEVICE_MAPPER_H */ -- 2.27.0