1 |
From f8d4a51b02abd2f7bb4c5a874d8d83f4dedc7a6a Mon Sep 17 00:00:00 2001 |
2 |
From: Andreas Schneider <asn@samba.org> |
3 |
Date: Wed, 29 Jun 2016 13:38:19 +0200 |
4 |
Subject: [PATCH] s3-winbind: Fix memory leak with each cached credential login |
5 |
|
6 |
When we allow offline logon and have a lot of logins, windbind will leak |
7 |
4k of memory which each log in. On systems with heavy load this can grow |
8 |
quickly and the OOM killer will kill Winbind. |
9 |
|
10 |
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11999 |
11 |
|
12 |
Signed-off-by: Andreas Schneider <asn@samba.org> |
13 |
Reviewed-by: Guenther Deschner <gd@samba.org> |
14 |
|
15 |
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> |
16 |
Autobuild-Date(master): Wed Jun 29 19:03:53 CEST 2016 on sn-devel-144 |
17 |
|
18 |
(cherry picked from commit 826f61960ec74deedc9d556a3b8fe04d9178dcd8) |
19 |
--- |
20 |
source3/winbindd/winbindd_cache.c | 8 ++++++-- |
21 |
1 file changed, 6 insertions(+), 2 deletions(-) |
22 |
|
23 |
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c |
24 |
index cf3ed71..5dd9f4f 100644 |
25 |
--- a/source3/winbindd/winbindd_cache.c |
26 |
+++ b/source3/winbindd/winbindd_cache.c |
27 |
@@ -3471,7 +3471,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const |
28 |
struct winbind_cache *cache = get_cache(domain); |
29 |
NTSTATUS status; |
30 |
int ret; |
31 |
- struct cred_list *cred, *oldest = NULL; |
32 |
+ struct cred_list *cred, *next, *oldest = NULL; |
33 |
|
34 |
if (!cache->tdb) { |
35 |
return NT_STATUS_INTERNAL_DB_ERROR; |
36 |
@@ -3540,7 +3540,11 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const |
37 |
status = NT_STATUS_UNSUCCESSFUL; |
38 |
} |
39 |
done: |
40 |
- SAFE_FREE(wcache_cred_list); |
41 |
+ for (cred = wcache_cred_list; cred; cred = next) { |
42 |
+ next = cred->next; |
43 |
+ DLIST_REMOVE(wcache_cred_list, cred); |
44 |
+ SAFE_FREE(cred); |
45 |
+ } |
46 |
SAFE_FREE(oldest); |
47 |
|
48 |
return status; |
49 |
-- |
50 |
2.9.0 |
51 |
|