Make sure to return an error when the user requests an LSM profile to be
set while also requesting that elevated LSM privileges are to be used.
Signed-off-by: Maximilian Blenk <Maximilian.Blenk@bmw.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
if (remount_sys_proc)
attach_options.attach_flags |= LXC_ATTACH_REMOUNT_PROC_SYS;
- if (elevated_privileges)
+ if (elevated_privileges) {
+ if ((elevated_privileges & LXC_ATTACH_LSM_EXEC)) {
+ if (selinux_context) {
+ ERROR("Cannot combine elevated LSM privileges while requesting LSM profile");
+ goto out;
+ }
+
+ /*
+ * While most LSM flags are off by default let's still
+ * make sure they are stripped when elevated LSM
+ * privileges are requested.
+ */
+ elevated_privileges |= LXC_ATTACH_LSM;
+ }
+
attach_options.attach_flags &= ~(elevated_privileges);
+ }
if (stdfd_is_pty())
attach_options.attach_flags |= LXC_ATTACH_TERMINAL;