diff options
author | Hoang Le <hoang.h.le@dektek.com.au> | 2018-02-08 11:16:25 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-02-08 15:30:40 -0500 |
commit | 55b3280d1e471795c08dbbe17325720a843e104c (patch) | |
tree | 540f61caa564a39a197d6980c0a244f1cd93a807 /net/tipc/msg.c | |
parent | eb53f7af6f15285e2f6ada97285395343ce9f433 (diff) |
tipc: fix skb truesize/datasize ratio control
In commit d618d09a68e4 ("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 <jon.maloy@ericsson.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/msg.c')
-rw-r--r-- | net/tipc/msg.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 55d8ba92291d..4e1c6f6450bb 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
@@ -208,8 +208,8 @@ bool tipc_msg_validate(struct sk_buff **_skb) | |||
208 | int msz, hsz; | 208 | int msz, hsz; |
209 | 209 | ||
210 | /* Ensure that flow control ratio condition is satisfied */ | 210 | /* Ensure that flow control ratio condition is satisfied */ |
211 | if (unlikely(skb->truesize / buf_roundup_len(skb) > 4)) { | 211 | if (unlikely(skb->truesize / buf_roundup_len(skb) >= 4)) { |
212 | skb = skb_copy(skb, GFP_ATOMIC); | 212 | skb = skb_copy_expand(skb, BUF_HEADROOM, 0, GFP_ATOMIC); |
213 | if (!skb) | 213 | if (!skb) |
214 | return false; | 214 | return false; |
215 | kfree_skb(*_skb); | 215 | kfree_skb(*_skb); |