Skip to content

Commit 9aa422a

Browse files
lmcjomatorvalds
authored andcommitted
tipc: improve size validations for received domain records
The function tipc_mon_rcv() allows a node to receive and process domain_record structs from peer nodes to track their views of the network topology. This patch verifies that the number of members in a received domain record does not exceed the limit defined by MAX_MON_DOMAIN, something that may otherwise lead to a stack overflow. tipc_mon_rcv() is called from the function tipc_link_proto_rcv(), where we are reading a 32 bit message data length field into a uint16. To avert any risk of bit overflow, we add an extra sanity check for this in that function. We cannot see that happen with the current code, but future designers being unaware of this risk, may introduce it by allowing delivery of very large (> 64k) sk buffers from the bearer layer. This potential problem was identified by Eric Dumazet. This fixes CVE-2022-0435 Reported-by: Samuel Page <samuel.page@appgate.com> Reported-by: Eric Dumazet <edumazet@google.com> Fixes: 35c55c9 ("tipc: add neighbor monitoring framework") Signed-off-by: Jon Maloy <jmaloy@redhat.com> Reviewed-by: Xin Long <lucien.xin@gmail.com> Reviewed-by: Samuel Page <samuel.page@appgate.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f4bc5bb commit 9aa422a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

net/tipc/link.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2200,7 +2200,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
22002200
struct tipc_msg *hdr = buf_msg(skb);
22012201
struct tipc_gap_ack_blks *ga = NULL;
22022202
bool reply = msg_probe(hdr), retransmitted = false;
2203-
u16 dlen = msg_data_sz(hdr), glen = 0;
2203+
u32 dlen = msg_data_sz(hdr), glen = 0;
22042204
u16 peers_snd_nxt = msg_next_sent(hdr);
22052205
u16 peers_tol = msg_link_tolerance(hdr);
22062206
u16 peers_prio = msg_linkprio(hdr);
@@ -2214,6 +2214,10 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
22142214
void *data;
22152215

22162216
trace_tipc_proto_rcv(skb, false, l->name);
2217+
2218+
if (dlen > U16_MAX)
2219+
goto exit;
2220+
22172221
if (tipc_link_is_blocked(l) || !xmitq)
22182222
goto exit;
22192223

@@ -2309,7 +2313,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
23092313

23102314
/* Receive Gap ACK blocks from peer if any */
23112315
glen = tipc_get_gap_ack_blks(&ga, l, hdr, true);
2312-
2316+
if(glen > dlen)
2317+
break;
23132318
tipc_mon_rcv(l->net, data + glen, dlen - glen, l->addr,
23142319
&l->mon_state, l->bearer_id);
23152320

net/tipc/monitor.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,8 @@ void tipc_mon_rcv(struct net *net, void *data, u16 dlen, u32 addr,
496496
state->probing = false;
497497

498498
/* Sanity check received domain record */
499+
if (new_member_cnt > MAX_MON_DOMAIN)
500+
return;
499501
if (dlen < dom_rec_len(arrv_dom, 0))
500502
return;
501503
if (dlen != dom_rec_len(arrv_dom, new_member_cnt))

0 commit comments

Comments
 (0)