Skip to content

Commit

Permalink
rose: Fix Null pointer dereference in rose_send_frame()
Browse files Browse the repository at this point in the history
rose_send_frame() dereferences `neigh->dev` when called from
rose_transmit_clear_request(), and the first occurrence of the
`neigh` is in rose_loopback_timer() as `rose_loopback_neigh`,
and it is initialized in rose_add_loopback_neigh() as NULL.
i.e when `rose_loopback_neigh` used in rose_loopback_timer()
its `->dev` was still NULL and rose_loopback_timer() was calling
rose_rx_call_request() without checking for NULL.

- net/rose/rose_link.c
This bug seems to get triggered in this line:

rose_call = (ax25_address *)neigh->dev->dev_addr;

Fix it by adding NULL checking for `rose_loopback_neigh->dev`
in rose_loopback_timer().

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Suggested-by: Jakub Kicinski <[email protected]>
Reported-by: [email protected]
Tested-by: [email protected]
Link: https://syzkaller.appspot.com/bug?id=9d2a7ca8c7f2e4b682c97578dfa3f236258300b3
Signed-off-by: Anmol Karn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
codetronaut authored and kuba-moo committed Nov 20, 2020
1 parent f46e79a commit 3b3fd06
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions net/rose/rose_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ static void rose_loopback_timer(struct timer_list *unused)
}

if (frametype == ROSE_CALL_REQUEST) {
if ((dev = rose_dev_get(dest)) != NULL) {
if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0)
kfree_skb(skb);
} else {
if (!rose_loopback_neigh->dev) {
kfree_skb(skb);
continue;
}

dev = rose_dev_get(dest);
if (!dev) {
kfree_skb(skb);
continue;
}

if (rose_rx_call_request(skb, dev, rose_loopback_neigh, lci_o) == 0) {
dev_put(dev);
kfree_skb(skb);
}
} else {
Expand Down

0 comments on commit 3b3fd06

Please sign in to comment.