]> git.baikalelectronics.ru Git - kernel.git/commit
tipc: fix skb truesize/datasize ratio control
authorHoang Le <hoang.h.le@dektek.com.au>
Thu, 8 Feb 2018 16:16:25 +0000 (17:16 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 8 Feb 2018 20:30:40 +0000 (15:30 -0500)
commitee7090a516038df692ad8f19a70840017ea4077c
tree540f61caa564a39a197d6980c0a244f1cd93a807
parentfd996c4331fbfb045e704fd0e00b73e9c8da2d8b
tipc: fix skb truesize/datasize ratio control

In commit f511a1b94251 ("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>
net/tipc/msg.c