Skip to content

Commit fd0933f

Browse files
lxinsmb49
authored andcommitted
tipc: do not update mtu if msg_max is too small in mtu negotiation
BugLink: https://bugs.launchpad.net/bugs/2028408 [ Upstream commit 56077b5 ] When doing link mtu negotiation, a malicious peer may send Activate msg with a very small mtu, e.g. 4 in Shuang's testing, without checking for the minimum mtu, l->mtu will be set to 4 in tipc_link_proto_rcv(), then n->links[bearer_id].mtu is set to 4294967228, which is a overflow of '4 - INT_H_SIZE - EMSG_OVERHEAD' in tipc_link_mss(). With tipc_link.mtu = 4, tipc_link_xmit() kept printing the warning: tipc: Too large msg, purging xmit list 1 5 0 40 4! tipc: Too large msg, purging xmit list 1 15 0 60 4! And with tipc_link_entry.mtu 4294967228, a huge skb was allocated in named_distribute(), and when purging it in tipc_link_xmit(), a crash was even caused: general protection fault, probably for non-canonical address 0x2100001011000dd: 0000 [#1] PREEMPT SMP PTI CPU: 0 PID: 0 Comm: swapper/0 Kdump: loaded Not tainted 6.3.0.neta #19 RIP: 0010:kfree_skb_list_reason+0x7e/0x1f0 Call Trace: <IRQ> skb_release_data+0xf9/0x1d0 kfree_skb_reason+0x40/0x100 tipc_link_xmit+0x57a/0x740 [tipc] tipc_node_xmit+0x16c/0x5c0 [tipc] tipc_named_node_up+0x27f/0x2c0 [tipc] tipc_node_write_unlock+0x149/0x170 [tipc] tipc_rcv+0x608/0x740 [tipc] tipc_udp_recv+0xdc/0x1f0 [tipc] udp_queue_rcv_one_skb+0x33e/0x620 udp_unicast_rcv_skb.isra.72+0x75/0x90 __udp4_lib_rcv+0x56d/0xc20 ip_protocol_deliver_rcu+0x100/0x2d0 This patch fixes it by checking the new mtu against tipc_bearer_min_mtu(), and not updating mtu if it is too small. Fixes: ed193ec ("tipc: simplify link mtu negotiation") Reported-by: Shuang Li <[email protected]> Signed-off-by: Xin Long <[email protected]> Acked-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Stefan Bader <[email protected]>
1 parent 3e3c546 commit fd0933f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

net/tipc/link.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,7 +2199,7 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
21992199
struct tipc_msg *hdr = buf_msg(skb);
22002200
struct tipc_gap_ack_blks *ga = NULL;
22012201
bool reply = msg_probe(hdr), retransmitted = false;
2202-
u32 dlen = msg_data_sz(hdr), glen = 0;
2202+
u32 dlen = msg_data_sz(hdr), glen = 0, msg_max;
22032203
u16 peers_snd_nxt = msg_next_sent(hdr);
22042204
u16 peers_tol = msg_link_tolerance(hdr);
22052205
u16 peers_prio = msg_linkprio(hdr);
@@ -2238,6 +2238,9 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
22382238
switch (mtyp) {
22392239
case RESET_MSG:
22402240
case ACTIVATE_MSG:
2241+
msg_max = msg_max_pkt(hdr);
2242+
if (msg_max < tipc_bearer_min_mtu(l->net, l->bearer_id))
2243+
break;
22412244
/* Complete own link name with peer's interface name */
22422245
if_name = strrchr(l->name, ':') + 1;
22432246
if (sizeof(l->name) - (if_name - l->name) <= TIPC_MAX_IF_NAME)
@@ -2282,8 +2285,8 @@ static int tipc_link_proto_rcv(struct tipc_link *l, struct sk_buff *skb,
22822285
l->peer_session = msg_session(hdr);
22832286
l->in_session = true;
22842287
l->peer_bearer_id = msg_bearer_id(hdr);
2285-
if (l->mtu > msg_max_pkt(hdr))
2286-
l->mtu = msg_max_pkt(hdr);
2288+
if (l->mtu > msg_max)
2289+
l->mtu = msg_max;
22872290
break;
22882291

22892292
case STATE_MSG:

0 commit comments

Comments
 (0)