diff options
author | Xiyu Yang <xiyuyang19@fudan.edu.cn> | 2020-04-23 08:13:03 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-05-02 18:24:17 +0300 |
commit | 62d3d1d4ff9e6090e3e79f62e0d21493b9b73170 (patch) | |
tree | 8ff8399c9b7a520e9be707d393ae063b1412ba23 /net/x25/x25_dev.c | |
parent | b8a15c1b91bb2e1a7feafa7ce6b0db6a8b762179 (diff) | |
download | linux-62d3d1d4ff9e6090e3e79f62e0d21493b9b73170.tar.xz |
net/x25: Fix x25_neigh refcnt leak when receiving frame
[ Upstream commit f35d12971b4d814cdb2f659d76b42f0c545270b6 ]
x25_lapb_receive_frame() invokes x25_get_neigh(), which returns a
reference of the specified x25_neigh object to "nb" with increased
refcnt.
When x25_lapb_receive_frame() returns, local variable "nb" becomes
invalid, so the refcount should be decreased to keep refcount balanced.
The reference counting issue happens in one path of
x25_lapb_receive_frame(). When pskb_may_pull() returns false, the
function forgets to decrease the refcnt increased by x25_get_neigh(),
causing a refcnt leak.
Fix this issue by calling x25_neigh_put() when pskb_may_pull() returns
false.
Fixes: cb101ed2c3c7 ("x25: Handle undersized/fragmented skbs")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/x25/x25_dev.c')
-rw-r--r-- | net/x25/x25_dev.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/x25/x25_dev.c b/net/x25/x25_dev.c index 39231237e1c3..30f71620d4e3 100644 --- a/net/x25/x25_dev.c +++ b/net/x25/x25_dev.c @@ -120,8 +120,10 @@ int x25_lapb_receive_frame(struct sk_buff *skb, struct net_device *dev, goto drop; } - if (!pskb_may_pull(skb, 1)) + if (!pskb_may_pull(skb, 1)) { + x25_neigh_put(nb); return 0; + } switch (skb->data[0]) { |