Dropbear 2014.64
Matt Johnston
matt at ucc.asn.au
Mon Jul 28 23:31:30 WST 2014
On Mon, Jul 28, 2014 at 03:06:14AM +0000, NiLuJe wrote:
> Yup, building master w/ ca86726 reverted does the trick on the machine where
> I'm experiencing this issue...
Could you try with
https://github.com/mkj/dropbear/commit/0e7409c7ff6fc760018fce3d5e8b72247bf782b5
(the same as https://secure.ucc.asn.au/hg/dropbear/rev/36eacc322e00 )
I can sometimes reproduce it here and that patch seems to
solve the problem. I was assuming that all channel state
changes would occur through file descriptors, forgetting
about signal handlers when a process exits.
Thanks,
Matt
# HG changeset patch
# User Matt Johnston <matt at ucc.asn.au>
# Date 1406561029 -28800
# Node ID 36eacc322e00924e511810c519bf5a3f05898cdd
# Parent 356a25a108a3338b58f22a6c5b03336a10cd2bbd
Make sure the check_close() handler runs when a server child process exits
diff -r 356a25a108a3 -r 36eacc322e00 common-channel.c
--- a/common-channel.c Mon Jul 28 22:59:16 2014 +0800
+++ b/common-channel.c Mon Jul 28 23:23:49 2014 +0800
@@ -258,6 +258,12 @@
writechannel(channel, channel->errfd, channel->extrabuf);
do_check_close = 1;
}
+
+ if (ses.channel_signal_pending) {
+ /* SIGCHLD can change channel state for server sessions */
+ do_check_close = 1;
+ ses.channel_signal_pending = 0;
+ }
/* handle any channel closing etc */
if (do_check_close) {
diff -r 356a25a108a3 -r 36eacc322e00 session.h
--- a/session.h Mon Jul 28 22:59:16 2014 +0800
+++ b/session.h Mon Jul 28 23:23:49 2014 +0800
@@ -187,6 +187,7 @@
unsigned int chansize; /* the number of Channel*s allocated for channels */
unsigned int chancount; /* the number of Channel*s in use */
const struct ChanType **chantypes; /* The valid channel types */
+ int channel_signal_pending; /* Flag set by sigchld handler */
/* TCP priority level for the main "port 22" tcp socket */
enum dropbear_prio socket_prio;
diff -r 356a25a108a3 -r 36eacc322e00 svr-chansession.c
--- a/svr-chansession.c Mon Jul 28 22:59:16 2014 +0800
+++ b/svr-chansession.c Mon Jul 28 23:23:49 2014 +0800
@@ -89,6 +89,9 @@
const int saved_errno = errno;
+ /* Make channel handling code look for closed channels */
+ ses.channel_signal_pending = 1;
+
TRACE(("enter sigchld handler"))
while ((pid = waitpid(-1, &status, WNOHANG)) > 0) {
TRACE(("sigchld handler: pid %d", pid))
More information about the Dropbear
mailing list