diff --git a/security/loadpin/Kconfig b/security/loadpin/Kconfig
index 91be65dec2ab..cf3e6431e02d 100644
--- a/security/loadpin/Kconfig
+++ b/security/loadpin/Kconfig
@@ -18,3 +18,14 @@ config SECURITY_LOADPIN_ENFORCE
 	  If selected, LoadPin will enforce pinning at boot. If not
 	  selected, it can be enabled at boot with the kernel parameter
 	  "loadpin.enforce=1".
+
+config SECURITY_LOADPIN_VERITY
+	bool "Allow reading files from certain other filesystems that use dm-verity"
+	depends on DM_VERITY=y
+	help
+	  If selected LoadPin can allow reading files from filesystems
+	  that use dm-verity. A verity filesystem can be configured as
+	  being trusted by LoadPin by writing its root digest to the
+	  sysctl file 'trusted_verity_root_digests'. The sysctl file
+	  can only be written once (typically at boot) and accepts a
+	  list of comma separated digests.
diff --git a/security/loadpin/loadpin.c b/security/loadpin/loadpin.c
index b12f7d986b1e..b9c174f8687d 100644
--- a/security/loadpin/loadpin.c
+++ b/security/loadpin/loadpin.c
@@ -18,6 +18,8 @@
 #include <linux/path.h>
 #include <linux/sched.h>	/* current */
 #include <linux/string_helpers.h>
+#include <linux/device-mapper.h>
+#include <linux/dm-verity-loadpin.h>
 
 static void report_load(const char *origin, struct file *file, char *operation)
 {
@@ -43,6 +45,10 @@ static char *exclude_read_files[READING_MAX_ID];
 static int ignore_read_file_id[READING_MAX_ID] __ro_after_init;
 static struct super_block *pinned_root;
 static DEFINE_SPINLOCK(pinned_root_spinlock);
+#ifdef CONFIG_SECURITY_LOADPIN_VERITY
+static bool verity_digests_set;
+static LIST_HEAD(trusted_verity_root_digests);
+#endif
 
 #ifdef CONFIG_SYSCTL
 
@@ -65,6 +71,144 @@ static struct ctl_table loadpin_sysctl_table[] = {
 	{ }
 };
 
+#ifdef CONFIG_SECURITY_LOADPIN_VERITY
+
+static int proc_verity_root_digests(struct ctl_table *table, int write,
+				    void *buffer, size_t *lenp, loff_t *ppos)
+{
+	struct trusted_root_digest *trd;
+	char *buf;
+	int rc;
+
+	if (write) {
+		struct ctl_table tbl = *table;
+		char *p, *d;
+
+		if (*ppos)
+			return -EINVAL;
+
+		if (verity_digests_set)
+			return -EPERM;
+
+		buf = kzalloc(tbl.maxlen, GFP_KERNEL);
+		if (!buf)
+			return -ENOMEM;
+
+		tbl.data = buf;
+
+		rc = proc_dostring(&tbl, write, buffer, lenp, ppos);
+		if (rc) {
+			kfree(buf);
+			return rc;
+		}
+
+		if (strlen(buf) == 0) {
+			verity_digests_set = true;
+			return false;
+		}
+
+		p = buf;
+		while ((d = strsep(&p, ",")) != NULL) {
+			int len = strlen(d);
+
+			if (len % 2) {
+				rc = -EINVAL;
+				goto err;
+			}
+
+			len /= 2;
+
+			trd = kzalloc(sizeof(*trd), GFP_KERNEL);
+			if (!trd) {
+				rc = -ENOMEM;
+				goto err;
+			}
+
+			list_add_tail(&trd->node, &trusted_verity_root_digests);
+
+			trd->data = kzalloc(len, GFP_KERNEL);
+			if (!trd->data) {
+				rc = -ENOMEM;
+				goto err;
+			}
+
+			if (hex2bin(trd->data, d, len)) {
+				rc = -EINVAL;
+				goto err;
+			}
+
+			trd->len = len;
+		}
+
+		kfree(buf);
+
+		if (!list_empty(&trusted_verity_root_digests)) {
+			dm_verity_loadpin_set_trusted_root_digests(&trusted_verity_root_digests);
+			verity_digests_set = true;
+		}
+	} else {
+		struct ctl_table tbl = { .maxlen = 0 };
+		size_t off = 0;
+
+		list_for_each_entry(trd, &trusted_verity_root_digests, node) {
+			/* two ASCII characters per byte and a comma / '\0' */
+			tbl.maxlen += (trd->len * 2) + 1;
+		}
+
+		tbl.data = kzalloc(tbl.maxlen, GFP_KERNEL);
+
+		list_for_each_entry(trd, &trusted_verity_root_digests, node) {
+			int i;
+
+			if (off > 0) {
+				snprintf(tbl.data + off, tbl.maxlen - off, ",");
+				off++;
+			}
+
+			for (i = 0; i < trd->len; i++) {
+				snprintf(tbl.data + off, tbl.maxlen - off, "%02x", trd->data[i]);
+				off += 2;
+			}
+		}
+
+		proc_dostring(&tbl, write, buffer, lenp, ppos);
+		kfree(tbl.data);
+	}
+
+	return 0;
+
+err:
+	kfree(buf);
+
+	{
+		struct trusted_root_digest *tmp;
+
+		list_for_each_entry_safe(trd, tmp, &trusted_verity_root_digests, node) {
+			kfree(trd->data);
+			list_del(&trd->node);
+			kfree(trd);
+		}
+	}
+
+	return rc;
+}
+
+static struct ctl_table loadpin_sysctl_table_verity[] = {
+	{
+		.procname       = "trusted_verity_root_digests",
+		.maxlen         = SZ_4K,
+		.mode           = 0644,
+		.proc_handler   = proc_verity_root_digests,
+	},
+
+	{ }
+};
+#else
+
+static struct ctl_table loadpin_sysctl_table_verity[] = {};
+
+#endif /* CONFIG_SECURITY_LOADPIN_VERITY */
+
 /*
  * This must be called after early kernel init, since then the rootdev
  * is available.
@@ -118,6 +262,20 @@ static void loadpin_sb_free_security(struct super_block *mnt_sb)
 	}
 }
 
+static bool loadpin_is_fs_trusted(struct super_block *sb)
+{
+	struct mapped_device *md = dm_get_md(sb->s_bdev->bd_dev);
+	bool trusted;
+
+	if (!md)
+		return false;
+
+	trusted = dm_verity_loadpin_is_md_trusted(md);
+	dm_put(md);
+
+	return trusted;
+}
+
 static int loadpin_read_file(struct file *file, enum kernel_read_file_id id,
 			     bool contents)
 {
@@ -174,7 +332,8 @@ static int loadpin_read_file(struct file *file, enum kernel_read_file_id id,
 		spin_unlock(&pinned_root_spinlock);
 	}
 
-	if (IS_ERR_OR_NULL(pinned_root) || load_root != pinned_root) {
+	if (IS_ERR_OR_NULL(pinned_root) ||
+	    ((load_root != pinned_root) && !loadpin_is_fs_trusted(load_root))) {
 		if (unlikely(!enforce)) {
 			report_load(origin, file, "pinning-ignored");
 			return 0;
@@ -240,6 +399,13 @@ static int __init loadpin_init(void)
 		enforce ? "" : "not ");
 	parse_exclude();
 	security_add_hooks(loadpin_hooks, ARRAY_SIZE(loadpin_hooks), "loadpin");
+
+	if (IS_ENABLED(CONFIG_SECURITY_LOADPIN_VERITY)) {
+		if (!register_sysctl_paths(loadpin_sysctl_path,
+					   loadpin_sysctl_table_verity))
+			pr_notice("sysctl registration failed!\n");
+	}
+
 	return 0;
 }
 
