Unverified Commit f07d1dc4 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!11027 landlock: Don't lose track of restrictions on cred_transfer

parents e9437292 7ff17f55
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@
#include "ruleset.h"
#include "setup.h"

static int hook_cred_prepare(struct cred *const new,
		const struct cred *const old, const gfp_t gfp)
static void hook_cred_transfer(struct cred *const new,
			       const struct cred *const old)
{
	struct landlock_ruleset *const old_dom = landlock_cred(old)->domain;

@@ -23,6 +23,12 @@ static int hook_cred_prepare(struct cred *const new,
		landlock_get_ruleset(old_dom);
		landlock_cred(new)->domain = old_dom;
	}
}

static int hook_cred_prepare(struct cred *const new,
			     const struct cred *const old, const gfp_t gfp)
{
	hook_cred_transfer(new, old);
	return 0;
}

@@ -36,6 +42,7 @@ static void hook_cred_free(struct cred *const cred)

static struct security_hook_list landlock_hooks[] __lsm_ro_after_init = {
	LSM_HOOK_INIT(cred_prepare, hook_cred_prepare),
	LSM_HOOK_INIT(cred_transfer, hook_cred_transfer),
	LSM_HOOK_INIT(cred_free, hook_cred_free),
};