|
|
1d656d |
From 80d90c5c59e9477d8a0c9eb727a0fc1bec2b01ea Mon Sep 17 00:00:00 2001
|
|
|
1d656d |
From: Andrei Vagin <avagin@gmail.com>
|
|
|
1d656d |
Date: Sat, 4 May 2019 20:01:52 -0700
|
|
|
1d656d |
Subject: [PATCH] lsm: don't reset socket contex if SELinux is disabled
|
|
|
1d656d |
|
|
|
1d656d |
Fixes #693
|
|
|
1d656d |
---
|
|
|
1d656d |
criu/lsm.c | 16 ++++++++++++++--
|
|
|
1d656d |
1 file changed, 14 insertions(+), 2 deletions(-)
|
|
|
1d656d |
|
|
|
1d656d |
diff --git a/criu/lsm.c b/criu/lsm.c
|
|
|
1d656d |
index 9c9ac7f80e..5921138392 100644
|
|
|
1d656d |
--- a/criu/lsm.c
|
|
|
1d656d |
+++ b/criu/lsm.c
|
|
|
1d656d |
@@ -134,7 +134,15 @@ static int selinux_get_sockcreate_label(pid_t pid, char **output)
|
|
|
1d656d |
|
|
|
1d656d |
int reset_setsockcreatecon()
|
|
|
1d656d |
{
|
|
|
1d656d |
- return setsockcreatecon_raw(NULL);
|
|
|
1d656d |
+ /* Currently this only works for SELinux. */
|
|
|
1d656d |
+ if (kdat.lsm != LSMTYPE__SELINUX)
|
|
|
1d656d |
+ return 0;
|
|
|
1d656d |
+
|
|
|
1d656d |
+ if (setsockcreatecon_raw(NULL)) {
|
|
|
1d656d |
+ pr_perror("Unable to reset socket SELinux context");
|
|
|
1d656d |
+ return -1;
|
|
|
1d656d |
+ }
|
|
|
1d656d |
+ return 0;
|
|
|
1d656d |
}
|
|
|
1d656d |
|
|
|
1d656d |
int run_setsockcreatecon(FdinfoEntry *e)
|
|
|
1d656d |
@@ -147,7 +155,11 @@ int run_setsockcreatecon(FdinfoEntry *e)
|
|
|
1d656d |
|
|
|
1d656d |
ctx = e->xattr_security_selinux;
|
|
|
1d656d |
/* Writing to the FD using fsetxattr() did not work for some reason. */
|
|
|
1d656d |
- return setsockcreatecon_raw(ctx);
|
|
|
1d656d |
+ if (setsockcreatecon_raw(ctx)) {
|
|
|
1d656d |
+ pr_perror("Unable to set the %s socket SELinux context", ctx);
|
|
|
1d656d |
+ return -1;
|
|
|
1d656d |
+ }
|
|
|
1d656d |
+ return 0;
|
|
|
1d656d |
}
|
|
|
1d656d |
|
|
|
1d656d |
int dump_xattr_security_selinux(int fd, FdinfoEntry *e)
|