Skip to content

Commit 55b3280

Browse files
Hoang Ledavem330
authored andcommitted
tipc: fix skb truesize/datasize ratio control
In commit d618d09 ("tipc: enforce valid ratio between skb truesize and contents") we introduced a test for ensuring that the condition truesize/datasize <= 4 is true for a received buffer. Unfortunately this test has two problems. - Because of the integer arithmetics the test if (skb->truesize / buf_roundup_len(skb) > 4) will miss all ratios [4 < ratio < 5], which was not the intention. - The buffer returned by skb_copy() inherits skb->truesize of the original buffer, which doesn't help the situation at all. In this commit, we change the ratio condition and replace skb_copy() with a call to skb_copy_expand() to finally get this right. Acked-by: Jon Maloy <[email protected]> Signed-off-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent eb53f7a commit 55b3280

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/tipc/msg.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ bool tipc_msg_validate(struct sk_buff **_skb)
208208
int msz, hsz;
209209

210210
/* Ensure that flow control ratio condition is satisfied */
211-
if (unlikely(skb->truesize / buf_roundup_len(skb) > 4)) {
212-
skb = skb_copy(skb, GFP_ATOMIC);
211+
if (unlikely(skb->truesize / buf_roundup_len(skb) >= 4)) {
212+
skb = skb_copy_expand(skb, BUF_HEADROOM, 0, GFP_ATOMIC);
213213
if (!skb)
214214
return false;
215215
kfree_skb(*_skb);

0 commit comments

Comments
 (0)