Skip to content

Commit

Permalink
net: x25: Increase refcnt of "struct x25_neigh" in x25_rx_call_request
Browse files Browse the repository at this point in the history
The x25_disconnect function in x25_subr.c would decrease the refcount of
"x25->neighbour" (struct x25_neigh) and reset this pointer to NULL.

However, the x25_rx_call_request function in af_x25.c, which is called
when we receive a connection request, does not increase the refcount when
it assigns the pointer.

Fix this issue by increasing the refcount of "struct x25_neigh" in
x25_rx_call_request.

This patch fixes frequent kernel crashes when using AF_X25 sockets.

Fixes: 4becb7e ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect")
Cc: Martin Schiller <[email protected]>
Signed-off-by: Xie He <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Xie He authored and kuba-moo committed Nov 13, 2020
1 parent baee199 commit 4ee18c1
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions net/x25/af_x25.c
Original file line number Diff line number Diff line change
Expand Up @@ -1050,6 +1050,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
makex25->lci = lci;
makex25->dest_addr = dest_addr;
makex25->source_addr = source_addr;
x25_neigh_hold(nb);
makex25->neighbour = nb;
makex25->facilities = facilities;
makex25->dte_facilities= dte_facilities;
Expand Down

0 comments on commit 4ee18c1

Please sign in to comment.