Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp715213ybz; Wed, 15 Apr 2020 17:21:14 -0700 (PDT) X-Google-Smtp-Source: APiQypKNPUbZIMZGZxAWQ50mcdrGgVrw4/RDiGNvzRW/kg0zOx56HvBmVjK6OTaeg9KfZWo1igyV X-Received: by 2002:a05:6402:b49:: with SMTP id bx9mr19446799edb.24.1586996474071; Wed, 15 Apr 2020 17:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586996474; cv=none; d=google.com; s=arc-20160816; b=lkJTh+RYTPRdAl6gDgOTh/j/OpEL0jP5kc1BEIYK5OerovGbQR54AeJFyvxvd+5nPf jAXtH0R51/HM51mTcHkx3Q6ToVHEec+ohcxN4gBDONf3A0N+D/e63d2cgh6bnk4TpprV WJO96QDlLXuy90SVyLAw+cpXwN/Z1lXb0nGYgCrccLJKCAzshPsOPOaRasbJmZXJo+6K 9uj3DOBUQd8FY9bM9KTgJMxGo+Y0NSyfEOhV+IQdHMrLi7xK4D0XVOspbhmd85j4w8R0 +fqLJYFfEy06lBAMnXpjPpl+ElM9QH2l85rSc/LXbCrieQMPDzf2LBzR1UL0F0SbFVDo HEHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=anQ6E0aFLZwDN9nkUCo5hOpKc11Wy+x5k5bgghP0y+A=; b=OAgTVBl5B6jRGcYiMrBoNWkXrBRWzAHxT9WM3UAaXm4CNPP4PQf/zR1b/zJm2/v7tK ZnL0gCZ4tDsyA2rrO6Zn5sWNHalDUtLZOJDnxf7HbrP2MMe/UKGLu8mVx8jGkidESCYz 3W89SvF4sQ/asE61in5cArUDTbR5P/qkBizv0pQSKKfRPPTlc/LP3WGnylYmWjUqdRiS Zky6Terth0bAnN6tXny77OKGoHPCNyhRF4CSNWM1MXLWI2jjkGaSSEVR2bMV03QJFEPR acK+MBeifWA1CbyBmSaMStK0+k0rChRlNqxnPEFAMPhZUQAi/kS8JX+c3K6iez7JmvcS Eq6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ntLg4VEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si9253384edx.557.2020.04.15.17.20.50; Wed, 15 Apr 2020 17:21:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=ntLg4VEQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1415924AbgDOQ1g (ORCPT + 99 others); Wed, 15 Apr 2020 12:27:36 -0400 Received: from linux.microsoft.com ([13.77.154.182]:49196 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1415798AbgDOQ0E (ORCPT ); Wed, 15 Apr 2020 12:26:04 -0400 Received: from dede-linux.corp.microsoft.com (unknown [131.107.147.242]) by linux.microsoft.com (Postfix) with ESMTPSA id 0C3C7207295D; Wed, 15 Apr 2020 09:25:58 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0C3C7207295D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1586967958; bh=anQ6E0aFLZwDN9nkUCo5hOpKc11Wy+x5k5bgghP0y+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ntLg4VEQeguJcdHXNjBDZn0n++fVX5909E2/n+WLoUruERmc6hlHiwA9w1Ud6M6UQ xcJrB4sfE2CY7wXm5XW7VLtchZG5lzQkSxePDVqRdxAOYfAHYxDccYZ3WFECOF3kuV NsS521rDliq4p62I4zPnU5UHis6i1zJCe5sa229g= From: deven.desai@linux.microsoft.com To: agk@redhat.com, axboe@kernel.dk, snitzer@redhat.com, jmorris@namei.org, serge@hallyn.com, zohar@linux.ibm.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, dm-devel@redhat.com, linux-block@vger.kernel.org, jannh@google.com Cc: tyhicks@linux.microsoft.com, pasha.tatashin@soleen.com, sashal@kernel.org, jaskarankhurana@linux.microsoft.com, nramas@linux.microsoft.com, mdsakib@linux.microsoft.com, linux-kernel@vger.kernel.org, corbet@lwn.net Subject: [RFC PATCH v3 09/12] dm-verity: add bdev_setsecurity hook for root-hash Date: Wed, 15 Apr 2020 09:25:47 -0700 Message-Id: <20200415162550.2324-10-deven.desai@linux.microsoft.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200415162550.2324-1-deven.desai@linux.microsoft.com> References: <20200415162550.2324-1-deven.desai@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Deven Bowers Add a security hook call to set a security property of a block_device in dm-verity with the root-hash that was verified to match the merkel-tree. 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 c507f3a4e237..225f67ab378d 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" @@ -530,6 +532,12 @@ static int verity_verify_io(struct dm_verity_io *io) return -EIO; } + r = security_bdev_setsecurity(dm_table_get_md(v->ti->table)->bdev, + DM_VERITY_ROOTHASH_SEC_NAME, + v->root_digest, v->digest_size); + if (unlikely(r < 0)) + return r; + /* * At this point, the merkel tree has finished validating. * if signature was specified, validate the signature here. diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h index 61c26443783c..0c274546c515 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -628,5 +628,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.26.0