Skip to content

Commit 1613462

Browse files
committed
xen/privcmd: add boot control for restricted usage in domU
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 <[email protected]> --- V2: - new patch
1 parent 453b8fb commit 1613462

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/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
};
@@ -1708,6 +1714,13 @@ static struct notifier_block xenstore_notifier = {
17081714

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

17131726
register_xenstore_notifier(&xenstore_notifier);

include/linux/security.h

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

security/security.c

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

0 commit comments

Comments
 (0)