Skip to content

Commit 1f00bad

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 78432d8 commit 1f00bad

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
};
@@ -1727,6 +1733,13 @@ static struct notifier_block xenstore_notifier = {
17271733

17281734
static void __init restrict_driver(void)
17291735
{
1736+
if (unrestricted) {
1737+
if (security_locked_down(LOCKDOWN_XEN_USER_ACTIONS))
1738+
pr_warn("Kernel is locked down, parameter \"unrestricted\" ignored\n");
1739+
else
1740+
return;
1741+
}
1742+
17301743
restrict_wait = true;
17311744

17321745
register_xenstore_notifier(&xenstore_notifier);

include/linux/security.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ enum lockdown_reason {
140140
LOCKDOWN_BPF_WRITE_USER,
141141
LOCKDOWN_DBG_WRITE_KERNEL,
142142
LOCKDOWN_RTAS_ERROR_INJECTION,
143+
LOCKDOWN_XEN_USER_ACTIONS,
143144
LOCKDOWN_INTEGRITY_MAX,
144145
LOCKDOWN_KCORE,
145146
LOCKDOWN_KPROBES,

security/security.c

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

0 commit comments

Comments
 (0)