mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 10:02:02 +02:00
ipe/stable-7.3 PR 20260925
-----BEGIN PGP SIGNATURE-----
iHUEABYIAB0WIQQzmBmZPBN6m/hUJmnyomI6a/yO7QUCarbccwAKCRDyomI6a/yO
7YKCAQDsDhTU3Rq7HCUgCkGYpZnsTAqXo3JeDP66Ku6Y0bOJjAEAhyRelXr+tKFW
aYpuOn3qF+tihTJ52RWzAhQzEQ1BRQY=
=QEqL
-----END PGP SIGNATURE-----
Merge tag 'ipe-pr-20260925' of git://git.kernel.org/pub/scm/linux/kernel/git/wufan/ipe
Pull IPE fixes from Fan Wu:
"Two fixes for use-after-free issues found by recent LLM-assisted code
analysis.
- move successful policy load auditing under the new policy
directory's inode lock, preventing a concurrent policy deletion
from freeing the policy while it is still being audited
- protect the dm-verity root hash with RCU, preventing policy
evaluation from racing with root hash replacement during preresume"
* tag 'ipe-pr-20260925' of git://git.kernel.org/pub/scm/linux/kernel/git/wufan/ipe:
ipe: protect the dm-verity root hash with RCU
ipe: fix use-after-free when auditing a newly loaded policy
This commit is contained in:
commit
75467f60a3
|
|
@ -134,10 +134,14 @@ static bool evaluate_boot_verified(const struct ipe_eval_ctx *const ctx)
|
|||
static bool evaluate_dmv_roothash(const struct ipe_eval_ctx *const ctx,
|
||||
struct ipe_prop *p)
|
||||
{
|
||||
return !!ctx->ipe_bdev &&
|
||||
!!ctx->ipe_bdev->root_hash &&
|
||||
ipe_digest_eval(p->value,
|
||||
ctx->ipe_bdev->root_hash);
|
||||
const struct digest_info *root_hash;
|
||||
|
||||
if (!ctx->ipe_bdev)
|
||||
return false;
|
||||
|
||||
root_hash = rcu_dereference(ctx->ipe_bdev->root_hash);
|
||||
|
||||
return root_hash && ipe_digest_eval(p->value, root_hash);
|
||||
}
|
||||
#else
|
||||
static bool evaluate_dmv_roothash(const struct ipe_eval_ctx *const ctx,
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ struct ipe_bdev {
|
|||
#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE
|
||||
bool dm_verity_signed;
|
||||
#endif /* CONFIG_IPE_PROP_DM_VERITY_SIGNATURE */
|
||||
struct digest_info *root_hash;
|
||||
struct digest_info __rcu *root_hash;
|
||||
};
|
||||
#endif /* CONFIG_IPE_PROP_DM_VERITY */
|
||||
|
||||
|
|
|
|||
|
|
@ -159,18 +159,16 @@ static ssize_t new_policy(struct file *f, const char __user *data,
|
|||
}
|
||||
|
||||
rc = ipe_new_policyfs_node(p);
|
||||
if (rc)
|
||||
goto out;
|
||||
|
||||
out:
|
||||
kfree(copy);
|
||||
if (rc < 0) {
|
||||
ipe_free_policy(p);
|
||||
ipe_audit_policy_load(ERR_PTR(rc));
|
||||
} else {
|
||||
ipe_audit_policy_load(p);
|
||||
return rc;
|
||||
}
|
||||
return (rc < 0) ? rc : len;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
static const struct file_operations np_fops = {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <linux/binfmts.h>
|
||||
#include <linux/mman.h>
|
||||
#include <linux/blk_types.h>
|
||||
#include <linux/rcupdate.h>
|
||||
|
||||
#include "ipe.h"
|
||||
#include "hooks.h"
|
||||
|
|
@ -232,7 +233,20 @@ void ipe_bdev_free_security(struct block_device *bdev)
|
|||
{
|
||||
struct ipe_bdev *blob = ipe_bdev(bdev);
|
||||
|
||||
ipe_digest_free(blob->root_hash);
|
||||
ipe_digest_free(rcu_access_pointer(blob->root_hash));
|
||||
}
|
||||
|
||||
static void ipe_set_dmverity_roothash(struct ipe_bdev *blob,
|
||||
struct digest_info *info)
|
||||
{
|
||||
struct digest_info *old;
|
||||
|
||||
/* Protected by device-mapper's md->suspend_lock */
|
||||
old = rcu_replace_pointer(blob->root_hash, info, true);
|
||||
if (old) {
|
||||
synchronize_rcu();
|
||||
ipe_digest_free(old);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE
|
||||
|
|
@ -280,8 +294,7 @@ int ipe_bdev_setintegrity(struct block_device *bdev, enum lsm_integrity_type typ
|
|||
return -EINVAL;
|
||||
|
||||
if (!value) {
|
||||
ipe_digest_free(blob->root_hash);
|
||||
blob->root_hash = NULL;
|
||||
ipe_set_dmverity_roothash(blob, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -301,8 +314,7 @@ int ipe_bdev_setintegrity(struct block_device *bdev, enum lsm_integrity_type typ
|
|||
|
||||
info->digest_len = digest->digest_len;
|
||||
|
||||
ipe_digest_free(blob->root_hash);
|
||||
blob->root_hash = info;
|
||||
ipe_set_dmverity_roothash(blob, info);
|
||||
|
||||
return 0;
|
||||
err:
|
||||
|
|
|
|||
|
|
@ -481,6 +481,9 @@ int ipe_new_policyfs_node(struct ipe_policy *p)
|
|||
inode_lock(root);
|
||||
p->policyfs = policyfs;
|
||||
root->i_private = p;
|
||||
/* Only audit signed policies from userspace */
|
||||
if (p->pkcs7)
|
||||
ipe_audit_policy_load(p);
|
||||
inode_unlock(root);
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user