Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3757009ybb; Mon, 6 Apr 2020 15:15:53 -0700 (PDT) X-Google-Smtp-Source: APiQypKREgvEovY9bdq5iHLlawxZLUkINP3VuW882Z9D2Sn2+wyMvS+pEy4Wz3AsZYVnm15OkzIu X-Received: by 2002:a4a:2fc6:: with SMTP id p189mr1121378oop.40.1586211353158; Mon, 06 Apr 2020 15:15:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586211353; cv=none; d=google.com; s=arc-20160816; b=BqP6hZnkOrX1JjzvNQRl+nP369i9tMuI7Y4QSXFjJE3LzUmj1EEzs5x9lMeA5xRmB4 u0OyNa3aipLkTmwhDb/rtm4oGn+lePX7vScZTfEILuIgcPsUSL/p3sag3RfPxs8flMBc PODiCcAqW1i71BYuNThBKXAwPV0ouXn++Qf3vU57nVqlAIUve4VXGYlXtSv0spJ3/mrb 2TKKPjQH/M02SlYOuHC3k3l/pZfQEoAmfhTW0o91yxlWqq6SQO5mK/9alZntLKoFdTso ecF3G3lpYbla1CUBDhYhkdB575mUh9cNxFQ1Z4KIYupoa3bu83tyzhZY3FWKsURqtWKv E5Pg== 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=vtS7tZDadPt65wOWMS99/Fu0/Y/o77wsMAmWG3vccKc=; b=BU7tNGFFahTLC2SUXezdVmFwz6fV0GniLP8iVMHAVc8KKQ1Vi4YuLz3IwFV8Ny1mJe f2sQIK2PjEIq+S3ZE9yOx7PDUctv8mBe+8D6Y3eg4Uv+AjT7GvrNSjig0trd6NCQAUB9 1HFaKWrNxwZPziJWFciEOZM8jLmRB3eGV8lmG4SfEvs7K8wvLmhzAUdM++3YbRiNdIpm RPw7h/aNCy9mwJPCqvDnqNd0dmUxQbjyaRTxsXgjOQZlUFagshFe7X7k9csBFX/B1Fe6 gCHqEYvzbUruoXeHbYHIyu3QpX/NerVTHfAa0cLIJxhLGDfaxPFb+TzcM5609fvWp0Vd fNqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Za+87sx4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id u3si430319oth.152.2020.04.06.15.15.41; Mon, 06 Apr 2020 15:15:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=Za+87sx4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726610AbgDFWOy (ORCPT + 99 others); Mon, 6 Apr 2020 18:14:54 -0400 Received: from linux.microsoft.com ([13.77.154.182]:58672 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726481AbgDFWOw (ORCPT ); Mon, 6 Apr 2020 18:14:52 -0400 Received: from dede-linux.corp.microsoft.com (unknown [131.107.147.242]) by linux.microsoft.com (Postfix) with ESMTPSA id D9FD4207295C; Mon, 6 Apr 2020 15:14:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com D9FD4207295C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1586211289; bh=vtS7tZDadPt65wOWMS99/Fu0/Y/o77wsMAmWG3vccKc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Za+87sx4it9lXflcDR643xZamIdKSRNW/GYBWvhRnJY/lwsO6L9cUb4fldBG+L0eu I70hwphAqelfOGA5PDk87j/F5H8srGusw7HpbcL3e9aQ6phKfyrYld39BRzHwHWthl nm7+OpOibz+6WWUVY9WYu2CS1KumKIhu2DVpA1oo= 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 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 Subject: [RFC PATCH v2 09/12] dm-verity: add bdev_setsecurity hook for root-hash Date: Mon, 6 Apr 2020 15:14:36 -0700 Message-Id: <20200406221439.1469862-10-deven.desai@linux.microsoft.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200406221439.1469862-1-deven.desai@linux.microsoft.com> References: <20200406221439.1469862-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 6bd49aa48186..467db44de194 100644 --- a/include/linux/device-mapper.h +++ b/include/linux/device-mapper.h @@ -625,5 +625,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