<div dir="ltr"><div>Sorry, I somehow messed up linebreaks in the original patch. Here&#39;s the fixed one.                                                                                                                                                                                                                                                                                           </div><div><br></div><div><br></div><div>From: Radoslaw Burny &lt;rburny at <a href="http://google.com">google.com</a>&gt;</div><div><br></div><div>Subject: [PATCH] Fix UB in choose_service_fd_base.</div><div><br></div><div>Signed-off-by: Radoslaw Burny &lt;rburny at <a href="http://google.com">google.com</a>&gt;</div><div><br></div><div>---</div><div> criu/util.c | 4 ++--</div><div> 1 file changed, 2 insertions(+), 2 deletions(-)</div><div><br></div><div>diff --git a/criu/util.c b/criu/util.c</div><div>index b19bf517..48ba09a8 100644</div><div>--- a/criu/util.c</div><div>+++ b/criu/util.c</div><div>@@ -588,9 +588,9 @@ static int choose_service_fd_base(struct pstree_item *me)</div><div>        nr += 16; /* Safety pad */</div><div>        real_nr = nr;</div><div> </div><div>-       nr /= (1024 / sizeof(void *));</div><div>+       /* Align nr to the power of 2 for easier debugging */</div><div>+       BUG_ON(nr &lt;= 0);</div><div>        nr = 1 &lt;&lt; (32 - __builtin_clz(nr));</div><div>-       nr *= (1024 / sizeof(void *));</div><div> </div><div>        if (nr &gt; service_fd_rlim_cur) {</div><div>                /* Right border is bigger, than rlim. OK, then just aligned value is enough */</div><div>-- </div><div>2.17.0.484.g0c8726318c-goog</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 9, 2018 at 5:13 PM, Patchwork <span dir="ltr">&lt;<a href="mailto:criupatchwork@gmail.com" target="_blank">criupatchwork@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">== Series Details ==<br>
<br>
Series: Fix UB in choose_service_fd_base due to calling __builtin_clz(0)<br>
URL   : <a href="https://patchwork.criu.org/series/2463/" rel="noreferrer" target="_blank">https://patchwork.criu.org/<wbr>series/2463/</a><br>
State : failure<br>
<br>
== Logs ==<br>
<br>
For more details see: <a href="https://ci.openvz.org/job/CRIU/job/criu-patchwork/1812//console" rel="noreferrer" target="_blank">https://ci.openvz.org/job/<wbr>CRIU/job/criu-patchwork/1812//<wbr>console</a><br>
</blockquote></div><br></div>