Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tipc: Use size_add() in calls to struct_size()

If, for any reason, the open-coded arithmetic causes a wraparound,
the protection that `struct_size()` adds against potential integer
overflows is defeated. Fix this by hardening call to `struct_size()`
with `size_add()`.

Fixes: e034c6d23bc4 ("tipc: Use struct_size() helper")
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Gustavo A. R. Silva and committed by
David S. Miller
2506a917 a2713257

+2 -2
+2 -2
net/tipc/link.c
··· 1446 1446 p = (struct tipc_gap_ack_blks *)msg_data(hdr); 1447 1447 sz = ntohs(p->len); 1448 1448 /* Sanity check */ 1449 - if (sz == struct_size(p, gacks, p->ugack_cnt + p->bgack_cnt)) { 1449 + if (sz == struct_size(p, gacks, size_add(p->ugack_cnt, p->bgack_cnt))) { 1450 1450 /* Good, check if the desired type exists */ 1451 1451 if ((uc && p->ugack_cnt) || (!uc && p->bgack_cnt)) 1452 1452 goto ok; ··· 1533 1533 __tipc_build_gap_ack_blks(ga, l, ga->bgack_cnt) : 0; 1534 1534 1535 1535 /* Total len */ 1536 - len = struct_size(ga, gacks, ga->bgack_cnt + ga->ugack_cnt); 1536 + len = struct_size(ga, gacks, size_add(ga->bgack_cnt, ga->ugack_cnt)); 1537 1537 ga->len = htons(len); 1538 1538 return len; 1539 1539 }