Skip to content

Commit

Permalink
tipc: fix message corruption bug for deferred packets
Browse files Browse the repository at this point in the history
If a packet received on a link is out-of-sequence, it will be
placed on a deferred queue and later reinserted in the receive
path once the preceding packets have been processed. The problem
with this is that it will be subject to the buffer adjustment from
link_recv_buf_validate twice. The second adjustment for 20 bytes
header space will corrupt the packet.

We solve this by tagging the deferred packets and bail out from
receive buffer validation for packets that have already been
subjected to this.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Erik Hugne authored and David S. Miller committed Feb 13, 2014
1 parent d15891c commit 64380a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/tipc/core.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ static inline void k_term_timer(struct timer_list *timer)

struct tipc_skb_cb {
void *handle;
bool deferred;
};

#define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
Expand Down
7 changes: 7 additions & 0 deletions net/tipc/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -1391,6 +1391,12 @@ static int link_recv_buf_validate(struct sk_buff *buf)
u32 hdr_size;
u32 min_hdr_size;

/* If this packet comes from the defer queue, the skb has already
* been validated
*/
if (unlikely(TIPC_SKB_CB(buf)->deferred))
return 1;

if (unlikely(buf->len < MIN_H_SIZE))
return 0;

Expand Down Expand Up @@ -1703,6 +1709,7 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
&l_ptr->newest_deferred_in, buf)) {
l_ptr->deferred_inqueue_sz++;
l_ptr->stats.deferred_recv++;
TIPC_SKB_CB(buf)->deferred = true;
if ((l_ptr->deferred_inqueue_sz % 16) == 1)
tipc_link_send_proto_msg(l_ptr, STATE_MSG, 0, 0, 0, 0, 0);
} else
Expand Down

0 comments on commit 64380a0

Please sign in to comment.