UBUNTU: SAUCE: (lockdown) security: lockdown: expose a hook to lock the kernel down

In order to automatically lock down kernels running on UEFI machines
booted in Secure Boot mode, expose the lock_kernel_down() hook.

Upstream Status: RHEL only
Signed-off-by: Jeremy Cline <jcline@redhat.com>
(cherry picked from commit 72223fd1241cc5c70b96a491db14d54c83beadd8 from https://gitlab.com/cki-project/kernel-ark)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
[ arighi: context adjustments for 6.4-rc1 ]
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
This commit is contained in:
Jeremy Cline
2019-09-30 21:22:47 +00:00
committed by Paolo Pisati
parent d7e68fb408
commit 1cdab98f59
4 changed files with 14 additions and 0 deletions
+2
View File
@@ -411,6 +411,8 @@ LSM_HOOK(void, LSM_RET_VOID, bpf_prog_free_security, struct bpf_prog_aux *aux)
#endif /* CONFIG_BPF_SYSCALL */
LSM_HOOK(int, 0, locked_down, enum lockdown_reason what)
LSM_HOOK(int, 0, lock_kernel_down, const char *where, enum lockdown_reason level)
#ifdef CONFIG_PERF_EVENTS
LSM_HOOK(int, 0, perf_event_open, struct perf_event_attr *attr, int type)
+5
View File
@@ -494,6 +494,7 @@ int security_inode_notifysecctx(struct inode *inode, void *ctx, u32 ctxlen);
int security_inode_setsecctx(struct dentry *dentry, void *ctx, u32 ctxlen);
int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);
int security_locked_down(enum lockdown_reason what);
int security_lock_kernel_down(const char *where, enum lockdown_reason level);
int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, size_t *uctx_len,
void *val, size_t val_len, u64 id, u64 flags);
#else /* CONFIG_SECURITY */
@@ -1433,6 +1434,10 @@ static inline int security_locked_down(enum lockdown_reason what)
{
return 0;
}
static inline int security_lock_kernel_down(const char *where, enum lockdown_reason level)
{
return 0;
}
static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx,
size_t *uctx_len, void *val, size_t val_len,
u64 id, u64 flags)
+1
View File
@@ -74,6 +74,7 @@ static int lockdown_is_locked_down(enum lockdown_reason what)
static struct security_hook_list lockdown_hooks[] __ro_after_init = {
LSM_HOOK_INIT(locked_down, lockdown_is_locked_down),
LSM_HOOK_INIT(lock_kernel_down, lock_kernel_down),
};
const struct lsm_id lockdown_lsmid = {
+6
View File
@@ -5515,6 +5515,12 @@ int security_locked_down(enum lockdown_reason what)
}
EXPORT_SYMBOL(security_locked_down);
int security_lock_kernel_down(const char *where, enum lockdown_reason level)
{
return call_int_hook(lock_kernel_down, 0, where, level);
}
EXPORT_SYMBOL(security_lock_kernel_down);
#ifdef CONFIG_PERF_EVENTS
/**
* security_perf_event_open() - Check if a perf event open is allowed