Skip to content

Commit 2dc8e49

Browse files
jgross1opsiff
authored andcommitted
xen/privcmd: add boot control for restricted usage in domU
commit 1613462be621ad5103ec338a7b0ca0746ec4e5f1 upstream. When running in an unprivileged domU under Xen, the privcmd driver is restricted to allow only hypercalls against a target domain, for which the current domU is acting as a device model. Add a boot parameter "unrestricted" to allow all hypercalls (the hypervisor will still refuse destructive hypercalls affecting other guests). Make this new parameter effective only in case the domU wasn't started using secure boot, as otherwise hypercalls targeting the domU itself might result in violating the secure boot functionality. This is achieved by adding another lockdown reason, which can be tested to not being set when applying the "unrestricted" option. This is part of XSA-482 Signed-off-by: Juergen Gross <jgross@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 1dacf6b3718a356428f0e31300fb7b9e5fc6e347) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
1 parent 77fb64f commit 2dc8e49

3 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/xen/privcmd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/miscdevice.h>
3333
#include <linux/moduleparam.h>
3434
#include <linux/notifier.h>
35+
#include <linux/security.h>
3536
#include <linux/wait.h>
3637

3738
#include <asm/xen/hypervisor.h>
@@ -65,6 +66,11 @@ module_param_named(dm_op_buf_max_size, privcmd_dm_op_buf_max_size, uint,
6566
MODULE_PARM_DESC(dm_op_buf_max_size,
6667
"Maximum size of a dm_op hypercall buffer");
6768

69+
static bool unrestricted;
70+
module_param(unrestricted, bool, 0);
71+
MODULE_PARM_DESC(unrestricted,
72+
"Don't restrict hypercalls to target domain if running in a domU");
73+
6874
struct privcmd_data {
6975
domid_t domid;
7076
};
@@ -1301,6 +1307,13 @@ static struct notifier_block xenstore_notifier = {
13011307

13021308
static void __init restrict_driver(void)
13031309
{
1310+
if (unrestricted) {
1311+
if (security_locked_down(LOCKDOWN_XEN_USER_ACTIONS))
1312+
pr_warn("Kernel is locked down, parameter \"unrestricted\" ignored\n");
1313+
else
1314+
return;
1315+
}
1316+
13041317
restrict_wait = true;
13051318

13061319
register_xenstore_notifier(&xenstore_notifier);

include/linux/security.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ enum lockdown_reason {
125125
LOCKDOWN_BPF_WRITE_USER,
126126
LOCKDOWN_DBG_WRITE_KERNEL,
127127
LOCKDOWN_RTAS_ERROR_INJECTION,
128+
LOCKDOWN_XEN_USER_ACTIONS,
128129
LOCKDOWN_INTEGRITY_MAX,
129130
LOCKDOWN_KCORE,
130131
LOCKDOWN_KPROBES,

security/security.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX + 1] = {
6464
[LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM",
6565
[LOCKDOWN_DBG_WRITE_KERNEL] = "use of kgdb/kdb to write kernel RAM",
6666
[LOCKDOWN_RTAS_ERROR_INJECTION] = "RTAS error injection",
67+
[LOCKDOWN_XEN_USER_ACTIONS] = "Xen guest user action",
6768
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
6869
[LOCKDOWN_KCORE] = "/proc/kcore access",
6970
[LOCKDOWN_KPROBES] = "use of kprobes",

0 commit comments

Comments
 (0)