|
|
bb7cd1 |
From 3a07827a3722fd2166b94af1f5790273fbac01eb Mon Sep 17 00:00:00 2001
|
|
|
bb7cd1 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
bb7cd1 |
Date: Mon, 3 Apr 2017 12:56:01 +0200
|
|
|
bb7cd1 |
Subject: [PATCH 97/99] responders: do not leak selinux context on clients
|
|
|
bb7cd1 |
destruction
|
|
|
bb7cd1 |
MIME-Version: 1.0
|
|
|
bb7cd1 |
Content-Type: text/plain; charset=UTF-8
|
|
|
bb7cd1 |
Content-Transfer-Encoding: 8bit
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
The SELinux context created in get_client_cred is not talloc bound and
|
|
|
bb7cd1 |
we were leaking it if available with each client's destruction.
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
Resolves:
|
|
|
bb7cd1 |
https://pagure.io/SSSD/sssd/issue/3360
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
|
|
|
bb7cd1 |
(cherry picked from commit 05c2c3047912fca1c1a35ab1c8d3157b05383495)
|
|
|
bb7cd1 |
---
|
|
|
bb7cd1 |
src/responder/common/responder_common.c | 20 +++++++++++++++++++-
|
|
|
bb7cd1 |
1 file changed, 19 insertions(+), 1 deletion(-)
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c
|
|
|
bb7cd1 |
index 154d7dc7718c437d10e152fcba98161e2034fb14..67e1deefdfde19c95a68029b11099579d851513f 100644
|
|
|
bb7cd1 |
--- a/src/responder/common/responder_common.c
|
|
|
bb7cd1 |
+++ b/src/responder/common/responder_common.c
|
|
|
bb7cd1 |
@@ -97,7 +97,7 @@ static errno_t get_client_cred(struct cli_ctx *cctx)
|
|
|
bb7cd1 |
SEC_CTX secctx;
|
|
|
bb7cd1 |
int ret;
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
- cctx->creds = talloc(cctx, struct cli_creds);
|
|
|
bb7cd1 |
+ cctx->creds = talloc_zero(cctx, struct cli_creds);
|
|
|
bb7cd1 |
if (!cctx->creds) return ENOMEM;
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
#ifdef HAVE_UCRED
|
|
|
bb7cd1 |
@@ -464,6 +464,22 @@ static void client_fd_handler(struct tevent_context *ev,
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
static errno_t setup_client_idle_timer(struct cli_ctx *cctx);
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
+static int cli_ctx_destructor(struct cli_ctx *cctx)
|
|
|
bb7cd1 |
+{
|
|
|
bb7cd1 |
+ if (cctx->creds == NULL) {
|
|
|
bb7cd1 |
+ return 0;
|
|
|
bb7cd1 |
+ }
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
+ if (cctx->creds->selinux_ctx == NULL) {
|
|
|
bb7cd1 |
+ return 0;
|
|
|
bb7cd1 |
+ }
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
+ SELINUX_context_free(cctx->creds->selinux_ctx);
|
|
|
bb7cd1 |
+ cctx->creds->selinux_ctx = NULL;
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
+ return 0;
|
|
|
bb7cd1 |
+}
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
struct accept_fd_ctx {
|
|
|
bb7cd1 |
struct resp_ctx *rctx;
|
|
|
bb7cd1 |
bool is_private;
|
|
|
bb7cd1 |
@@ -520,6 +536,8 @@ static void accept_fd_handler(struct tevent_context *ev,
|
|
|
bb7cd1 |
return;
|
|
|
bb7cd1 |
}
|
|
|
bb7cd1 |
|
|
|
bb7cd1 |
+ talloc_set_destructor(cctx, cli_ctx_destructor);
|
|
|
bb7cd1 |
+
|
|
|
bb7cd1 |
len = sizeof(cctx->addr);
|
|
|
bb7cd1 |
cctx->cfd = accept(fd, (struct sockaddr *)&cctx->addr, &len;;
|
|
|
bb7cd1 |
if (cctx->cfd == -1) {
|
|
|
bb7cd1 |
--
|
|
|
bb7cd1 |
2.9.3
|
|
|
bb7cd1 |
|