Skip to content
/ linux Public

Commit a52e397

Browse files
jgross1gregkh
authored andcommitted
xen/privcmd: add boot control for restricted usage in domU
commit 1613462 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>
1 parent 389bae9 commit a52e397

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

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/virtio_mmio.h>
3637
#include <linux/wait.h>
3738

@@ -72,6 +73,11 @@ module_param_named(dm_op_buf_max_size, privcmd_dm_op_buf_max_size, uint,
7273
MODULE_PARM_DESC(dm_op_buf_max_size,
7374
"Maximum size of a dm_op hypercall buffer");
7475

76+
static bool unrestricted;
77+
module_param(unrestricted, bool, 0);
78+
MODULE_PARM_DESC(unrestricted,
79+
"Don't restrict hypercalls to target domain if running in a domU");
80+
7581
struct privcmd_data {
7682
domid_t domid;
7783
};
@@ -1707,6 +1713,13 @@ static struct notifier_block xenstore_notifier = {
17071713

17081714
static void __init restrict_driver(void)
17091715
{
1716+
if (unrestricted) {
1717+
if (security_locked_down(LOCKDOWN_XEN_USER_ACTIONS))
1718+
pr_warn("Kernel is locked down, parameter \"unrestricted\" ignored\n");
1719+
else
1720+
return;
1721+
}
1722+
17101723
restrict_wait = true;
17111724

17121725
register_xenstore_notifier(&xenstore_notifier);

include/linux/security.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ enum lockdown_reason {
144144
LOCKDOWN_BPF_WRITE_USER,
145145
LOCKDOWN_DBG_WRITE_KERNEL,
146146
LOCKDOWN_RTAS_ERROR_INJECTION,
147+
LOCKDOWN_XEN_USER_ACTIONS,
147148
LOCKDOWN_INTEGRITY_MAX,
148149
LOCKDOWN_KCORE,
149150
LOCKDOWN_KPROBES,

security/security.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const char *const lockdown_reasons[LOCKDOWN_CONFIDENTIALITY_MAX + 1] = {
7878
[LOCKDOWN_BPF_WRITE_USER] = "use of bpf to write user RAM",
7979
[LOCKDOWN_DBG_WRITE_KERNEL] = "use of kgdb/kdb to write kernel RAM",
8080
[LOCKDOWN_RTAS_ERROR_INJECTION] = "RTAS error injection",
81+
[LOCKDOWN_XEN_USER_ACTIONS] = "Xen guest user action",
8182
[LOCKDOWN_INTEGRITY_MAX] = "integrity",
8283
[LOCKDOWN_KCORE] = "/proc/kcore access",
8384
[LOCKDOWN_KPROBES] = "use of kprobes",

0 commit comments

Comments
 (0)