<div dir="ltr"><font face="monospace, monospace"><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​​</div>Hi all.<br><br>I have a custom daemon<div class="gmail_default" style="display:inline">​ in C​</div>, that connect to unbound (remove control)<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​​</div> and get stats<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​​</div>, using stat_noreset.<br><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​Using this </div>I can create real<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​-​</div>time stats, in interface, like <div class="gmail_default" style="display:inline">​</div><div class="gmail_default" style="display:inline">​<a href="http://prntscr.com/d5cecc">http://prntscr.com/d5cecc</a></div></font><div><font face="monospace, monospace"><div class="gmail_default" style="display:inline">​</div><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​So, a</div>fter unbound 1.5.8 (eg: 1.5.9, 1.5.10)<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​, using calls like unbound-control does,​</div> the use of CPU increase significantly.<br><br>And, it's increase de CPU of both daemons unbound and my daemon.<br><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​I was thinking this is because SSL. Because I was using 1.0.1, and unbound in ports (freebrs), force to install openssl 1.0.2.<br></div><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​But, s</div>ince I'm in loopback (localhost), <div class="gmail_default" style="font-family:monospace,monospace;display:inline">​and, ​</div>I'm using<br><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​</div></font><span style="color:rgb(27,113,89);font-weight:bolder;font-size:13.3333px">control-use-cert</span><span style="font-family:monospace,monospace">: no</span><br><font face="monospace, monospace"><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​</div><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​I think this problem was introduced after the version i was using before (1.5.3).​</div><br><br>After some research, <div class="gmail_default" style="font-family:monospace,monospace;display:inline">​reinstall​</div> openSSL<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ (this is hard, because i need to recompile a lot of daemons after this)​</div>,<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ my daemon (of course), </div>use another machine, etc.<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ ​</div>I found<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ this​</div>:<br><br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">- ​</div>[bugzilla: 770 ]<br><div class="gmail_default" style="font-family:monospace,monospace;display:inline">- ​F​</div>ix Small subgroup attack on DH used in unix pipe on localhost if unbound<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ ​</div>control uses a unix local named pipe.<br><br>So, i get the source of 1.5.10, and make some changes to do like before, in 1.5.8.<br><br>I put back in daemon/remote.c the get_dh1024()<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​ function ​</div><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​(​</div>With some changes, if/else like in source of 1.5.10<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​)​</div>.<br><br>Then, is work well, the cpu is 0%, with the daemon calling stat_noreset each second.<br><br>You can try this, calling unbound-anchor stats_noreset, more than you call, more the CPU get high.<br><br>This change<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​, in ​</div>bugzilla 770<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​,​</div> is really necessary?<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​</div><div class="gmail_default" style="font-family:monospace,monospace;display:inline"><br><br>I also ready the last comment.<br></div></font><pre class="gmail-bz_comment_text" style="white-space:pre-wrap;width:50em;color:rgb(0,0,0)"><div class="gmail_default" style="font-family:monospace,monospace;display:inline">​- ​</div>This is not a security issue.  The control socket is intended to be protected only by Unix file and directory permissions.  The only reason why the connection is encrypted is that there is no clean separation in the code and adding support for an unencrypted control connection would have required a huge amount of refactoring.</pre><font face="monospace, monospace"><div class="gmail_default" style="font-family:monospace,monospace;display:inline">Since this is not a secure issue, and this can increase CPU without need.<br><br></div></font><div class="gmail_default" style="font-family:monospace,monospace;display:inline">The daemon and unbound are in the same machine, in a custom release, where the user can't have access, and can't do anything.</div><br style="font-family:monospace,monospace"><div class="gmail_default" style="font-family:monospace,monospace;display:inline"><br>Maybe a change in unbound, to get a new unbound.conf, to not use SSL at all (i know this is hard to be done) or make it to consume less CPU, alternates to use between 1024 or 2048. This is the first time I am reading unbound source, and I not know much about libssl.<br></div><font face="monospace, monospace"><div class="gmail_default" style="font-family:monospace,monospace;display:inline"><br>But, in this case, i need a way to chose between security and performance.<br><br>​ps, </div>I also recommend to do a if before calling SSL_CTX_set_tmp_dh<div class="gmail_default" style="font-family:monospace,monospace;display:inline">​, to check if get_dh is called right.​</div><br><br><div class="gmail_default" style="display:inline">​<div class="gmail_default" style="display:inline">​</div>    ​</div>dh = <div class="gmail_default" style="display:inline">​</div>get_dh1024();<br><div class="gmail_default" style="display:inline">​​</div>    <div class="gmail_default" style="display:inline">​​</div>if (dh == NULL) {<br>        <div class="gmail_default" style="font-family:monospace,monospace;display:inline">​</div>log_crypto_err("Failed to get DH params");<br>        <div class="gmail_default" style="font-family:monospace,monospace;display:inline">​</div>daemon_remote_delete(rc);<br>        return NULL;<br><div class="gmail_default" style="display:inline">​​</div>    }<br><br></font><div class="gmail_default"><font face="monospace, monospace"><div class="gmail_default" style="display:inline">​</div>    if(!SSL_CTX_set_tmp_dh(rc->ctx, dh)) {​</font></div><font face="monospace, monospace"><br><br><br><br><br></font><div class="gmail_default"><font face="monospace, monospace">​​</font></div><font face="monospace, monospace"><br><br><br></font><br></div></div>