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