[CRIU] [Patch] Fix UB in choose_service_fd_base due to calling __builtin_clz(0)
Radoslaw Burny
rburny at google.com
Mon Apr 9 17:57:55 MSK 2018
From: Radoslaw Burny <rburny at google.com>
Subject: [PATCH] Fix UB in choose_service_fd_base.
Signed-off-by: Radoslaw Burny <rburny at google.com>
---
criu/util.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/criu/util.c b/criu/util.c
index b19bf517..48ba09a8 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -588,9 +588,9 @@ static int choose_service_fd_base(struct pstree_item
*me)
nr += 16; /* Safety pad */
real_nr = nr;
- nr /= (1024 / sizeof(void *));
+ /* Align nr to the power of 2 for easier debugging */
+ BUG_ON(nr <= 0);
nr = 1 << (32 - __builtin_clz(nr));
- nr *= (1024 / sizeof(void *));
if (nr > service_fd_rlim_cur) {
/* Right border is bigger, than rlim. OK, then just aligned
value is enough */
--
2.17.0.484.g0c8726318c-goog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openvz.org/pipermail/criu/attachments/20180409/94dcd95f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4843 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.openvz.org/pipermail/criu/attachments/20180409/94dcd95f/attachment.p7s>
More information about the CRIU
mailing list