mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-27 12:57:53 +00:00
landlock: Warn once if a Landlock action is requested while disabled
[ Upstream commit782191c748
] Because sandboxing can be used as an opportunistic security measure, user space may not log unsupported features. Let the system administrator know if an application tries to use Landlock but failed because it isn't enabled at boot time. This may be caused by boot loader configurations with outdated "lsm" kernel's command-line parameter. Cc: stable@vger.kernel.org Fixes:265885daf3
("landlock: Add syscall implementations") Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Günther Noack <gnoack3000@gmail.com> Link: https://lore.kernel.org/r/20240227110550.3702236-2-mic@digikod.net Signed-off-by: Mickaël Salaün <mic@digikod.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
6203f20d66
commit
a6c13d23d9
1 changed files with 15 additions and 3 deletions
|
@ -32,6 +32,18 @@
|
||||||
#include "ruleset.h"
|
#include "ruleset.h"
|
||||||
#include "setup.h"
|
#include "setup.h"
|
||||||
|
|
||||||
|
static bool is_initialized(void)
|
||||||
|
{
|
||||||
|
if (likely(landlock_initialized))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
pr_warn_once(
|
||||||
|
"Disabled but requested by user space. "
|
||||||
|
"You should enable Landlock at boot time: "
|
||||||
|
"https://docs.kernel.org/userspace-api/landlock.html#boot-time-configuration\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* copy_min_struct_from_user - Safe future-proof argument copying
|
* copy_min_struct_from_user - Safe future-proof argument copying
|
||||||
*
|
*
|
||||||
|
@ -165,7 +177,7 @@ SYSCALL_DEFINE3(landlock_create_ruleset,
|
||||||
/* Build-time checks. */
|
/* Build-time checks. */
|
||||||
build_check_abi();
|
build_check_abi();
|
||||||
|
|
||||||
if (!landlock_initialized)
|
if (!is_initialized())
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (flags) {
|
if (flags) {
|
||||||
|
@ -311,7 +323,7 @@ SYSCALL_DEFINE4(landlock_add_rule, const int, ruleset_fd,
|
||||||
struct landlock_ruleset *ruleset;
|
struct landlock_ruleset *ruleset;
|
||||||
int res, err;
|
int res, err;
|
||||||
|
|
||||||
if (!landlock_initialized)
|
if (!is_initialized())
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
/* No flag for now. */
|
/* No flag for now. */
|
||||||
|
@ -402,7 +414,7 @@ SYSCALL_DEFINE2(landlock_restrict_self, const int, ruleset_fd, const __u32,
|
||||||
struct landlock_cred_security *new_llcred;
|
struct landlock_cred_security *new_llcred;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (!landlock_initialized)
|
if (!is_initialized())
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue