]>
Commit | Line | Data |
---|---|---|
1d13e637 AF |
1 | From cf53bff0e8482e35068d8e894af5634a0a9b1399 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 | source3/winbindd/winbindd_cache.c | 8 ++++++-- | |
16 | 1 file changed, 6 insertions(+), 2 deletions(-) | |
17 | ||
18 | diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c | |
19 | index 82c8087..2e983cd 100644 | |
20 | --- a/source3/winbindd/winbindd_cache.c | |
21 | +++ b/source3/winbindd/winbindd_cache.c | |
22 | @@ -3415,7 +3415,7 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const | |
23 | struct winbind_cache *cache = get_cache(domain); | |
24 | NTSTATUS status; | |
25 | int ret; | |
26 | - struct cred_list *cred, *oldest = NULL; | |
27 | + struct cred_list *cred, *next, *oldest = NULL; | |
28 | ||
29 | if (!cache->tdb) { | |
30 | return NT_STATUS_INTERNAL_DB_ERROR; | |
31 | @@ -3484,7 +3484,11 @@ NTSTATUS wcache_remove_oldest_cached_creds(struct winbindd_domain *domain, const | |
32 | status = NT_STATUS_UNSUCCESSFUL; | |
33 | } | |
34 | done: | |
35 | - SAFE_FREE(wcache_cred_list); | |
36 | + for (cred = wcache_cred_list; cred; cred = next) { | |
37 | + next = cred->next; | |
38 | + DLIST_REMOVE(wcache_cred_list, cred); | |
39 | + SAFE_FREE(cred); | |
40 | + } | |
41 | SAFE_FREE(oldest); | |
42 | ||
43 | return status; | |
44 | -- | |
45 | 2.9.0 | |
46 |