<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi,<div class=""><br class=""></div><div class="">I think this problem should be solved by the commit</div><div class=""><a href="https://secure.ucc.asn.au/hg/dropbear/rev/432b0a030fd6" class="">https://secure.ucc.asn.au/hg/dropbear/rev/432b0a030fd6</a></div><div class=""><br class=""></div><div class="">Thank you for the detailed report.</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Matt</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Wed 20/4/2016, at 2:44 pm, ZHANG Hui P &lt;<a href="mailto:Hui.P.Zhang@alcatel-sbell.com.cn" class="">Hui.P.Zhang@alcatel-sbell.com.cn</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="WordSection1" style="page: WordSection1; font-family: Helvetica; font-size: 13px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">Hi:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; text-align: justify; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I am a software engineer of Alcatel-Lucent. In our product we use dropbear v071 under the OS: Linux version 3.4.24. At most time it works perfectly, but recently we got a problem: sometimes a child-process of dropbear occupied nearly 100% CPU (we use ARM1176, single-core). After I investigated it ,I found it is cause by a misuse of KEX_REKEY_TIMEOUT.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif; text-indent: 21pt;" class=""><span lang="EN-US" class="">KEX_REKEY_TIMEOUT is defined as 8hours. that means when a session lasts more than 8 hours, the server and client will re-exchange their KEY for security reason. The timestamp of last-time KEY-EXCHANGED is recorded in variable "ses.kexstate.lastkextime".<span class="Apple-converted-space">&nbsp;</span><o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif; text-indent: 21pt;" class=""><span lang="EN-US" class="">&nbsp;The child dropbear process decides the "timeout" parameter of "select" function by calling "select_timeout". we can see it checks the timeout-events like KEX_REKEY_TIMEOUT, AUTH_TIMEOUT, keepalive_secs. If there is a timeout occurs, the "update_timeout" function returns a negative value, then "select_timeout" modifies it to ZREO by this:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">/* clamp negative timeouts to zero - event has already triggered */<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return MAX(timeout, 0);<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&nbsp;&nbsp; if "select_timeout" returns ZERO, the next "select" call (in "session_loop") will return immediately. Then it will check timeout events by this:<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">/* check for auth timeout, rekeying required etc */<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; checktimeouts();<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&nbsp;&nbsp; in the function " checktimeouts ", when it find the timeout is reached or to many data has been sent, it will send a SSH_MSG_KEXINIT message to peer. Normally this message will trigger a new KEY-EXCHANGE. However, when there is a network problem that the peer can't receive the message , this bug occurs: the timestamp ses.kexstate.lastkextime is only updated by calling&nbsp; "switch_keys"--&gt;" kexinitialise ", unfortunately this calling sequence is driven by ssh-messages, either SSH_MSG_KEXDH_INIT or SSH_MSG_NEWKEYS. When there is no ssh-message received , the child dropbear process enters dead-loop "select" with ZERO-timeout parameter caused by KEX_REKEY_TIMEOUT.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class="">&gt; &nbsp;&nbsp;&nbsp;&nbsp; So there is a very simple way to reproduce this bug: first define the KEX_REKEY_TIMEOUT as small as possible( I set it to 8 seconds), then start a ssh-session , the child dropbear process is forked. then plug out the network wire, after 8 seconds the child dropbear thread will occupy 100% CPU. Could you kindly check it? thanks.<o:p class=""></o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif;" class=""><span lang="EN-US" class=""><o:p class="">&nbsp;</o:p></span></div><div style="margin: 0cm 0cm 0.0001pt; font-size: 10.5pt; font-family: Calibri, sans-serif; text-indent: 21pt;" class=""><span lang="EN-US" class="">Best regards</span></div></div></div></blockquote></div><br class=""></div></body></html>