Bug 9000 - winbindd hangs when disconnect domain connection
Summary: winbindd hangs when disconnect domain connection
Status: RESOLVED FIXED
Alias: None
Product: Samba 3.5
Classification: Unclassified
Component: Winbind (show other bugs)
Version: 3.5.15
Hardware: All All
: P5 critical
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-18 04:49 UTC by Tsukasa HAMANO
Modified: 2012-06-22 17:50 UTC (History)
2 users (show)

See Also:


Attachments
patch for samba-3.5.15 (1.02 KB, patch)
2012-06-18 04:51 UTC, Tsukasa HAMANO
no flags Details
patch for 3.5.15 (1.02 KB, patch)
2012-06-18 05:04 UTC, Tsukasa HAMANO
no flags Details
patch for samba-3.5.15 (1.02 KB, patch)
2012-06-18 05:13 UTC, Tsukasa HAMANO
no flags Details
Patch from bug 8409 ported to 3.5 (2.34 KB, patch)
2012-06-18 12:29 UTC, Volker Lendecke
obnox: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tsukasa HAMANO 2012-06-18 04:49:16 UTC
winbindd go into infinity loop when disconnect connection with windows server.
service unavailable after windows server back and cannot restart winbindd.

busy loop was caused by circularly children list at folloing code:
source3/winbindd/winbindd_dual.c:

void winbind_child_died(pid_t pid)
{
    struct winbindd_child *child;

    for (child = children; child != NULL; child = child->next) {
        if (child->pid == pid) {
            break;
        }
    }

circularly list was make by DLIST_ADD(children, child) in fork_domain_child()
When already added child in children, second operation will make circularly list.
(see DLIST_ADD definition)
Anyway, We need to avoid infinity loop.
Comment 1 Tsukasa HAMANO 2012-06-18 04:51:38 UTC
Created attachment 7653 [details]
patch for samba-3.5.15

patch for samba-3.5.15
Comment 2 Tsukasa HAMANO 2012-06-18 05:04:40 UTC
Created attachment 7654 [details]
patch for 3.5.15
Comment 3 Tsukasa HAMANO 2012-06-18 05:13:29 UTC
Created attachment 7655 [details]
patch for samba-3.5.15
Comment 4 Tsukasa HAMANO 2012-06-18 05:17:48 UTC
Comment on attachment 7653 [details]
patch for samba-3.5.15

>diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
>index 360f1b2..ebda52a 100644
>--- a/source3/winbindd/winbindd_dual.c
>+++ b/source3/winbindd/winbindd_dual.c
>@@ -1305,6 +1305,7 @@ static bool fork_domain_child(struct winbindd_child *child)
> 	struct winbindd_request request;
> 	struct winbindd_response response;
> 	struct winbindd_domain *primary_domain = NULL;
>+	struct winbindd_child *c;
> 
> 	if (child->domain) {
> 		DEBUG(10, ("fork_domain_child called for domain '%s'\n",
>@@ -1336,8 +1337,18 @@ static bool fork_domain_child(struct winbindd_child *child)
> 		/* Parent */
> 		close(fdpair[0]);
> 		child->next = child->prev = NULL;
>-		DLIST_ADD(children, child);
> 		child->sock = fdpair[1];
>+		/*
>+		 * We need to check duplicate element before
>+		 * DLIST_ADD. Otherwise, childlen list be circularly.
>+		 */
>+		for (c = children; c != NULL; c = c->next) {
>+			if (c == child) {
>+				DEBUG(5, ("Already added child in children\n"));
>+				return True;
>+			}
>+		}
>+		DLIST_ADD(children, child);
> 		return True;
> 	}
>
Comment 5 Volker Lendecke 2012-06-18 11:14:48 UTC
Isn't this a duplicate of Bug 8409? I had thought that 3.5 is not affected by that, but I might have been wrong.
Comment 6 Tsukasa HAMANO 2012-06-18 12:15:42 UTC
Yes! I'm sure the bug is duplicate of Bug 8409.
We need to apply your patch to 3.5 too.
and I hope anyone does not to write more "child->sock = -1"...
Thank you.
Comment 7 Volker Lendecke 2012-06-18 12:29:39 UTC
Created attachment 7658 [details]
Patch from bug 8409 ported to 3.5
Comment 8 Michael Adam 2012-06-22 10:34:38 UTC
Comment on attachment 7658 [details]
Patch from bug 8409 ported to 3.5

ACK
Comment 9 Michael Adam 2012-06-22 10:35:09 UTC
==> Karo for inclusion into 3.5.next
Comment 10 Karolin Seeger 2012-06-22 17:50:09 UTC
Pushed to v3-5-test.
Closing out bug report.

Thanks!