|
33 | 33 | #include <linux/ppp_channel.h> |
34 | 34 | #include <linux/ppp-comp.h> |
35 | 35 | #include <linux/skbuff.h> |
| 36 | +#include <linux/rculist.h> |
36 | 37 | #include <linux/rtnetlink.h> |
37 | 38 | #include <linux/if_arp.h> |
38 | 39 | #include <linux/ip.h> |
@@ -1612,11 +1613,14 @@ static int ppp_fill_forward_path(struct net_device_path_ctx *ctx, |
1612 | 1613 | if (ppp->flags & SC_MULTILINK) |
1613 | 1614 | return -EOPNOTSUPP; |
1614 | 1615 |
|
1615 | | - if (list_empty(&ppp->channels)) |
| 1616 | + pch = list_first_or_null_rcu(&ppp->channels, struct channel, clist); |
| 1617 | + if (!pch) |
| 1618 | + return -ENODEV; |
| 1619 | + |
| 1620 | + chan = READ_ONCE(pch->chan); |
| 1621 | + if (!chan) |
1616 | 1622 | return -ENODEV; |
1617 | 1623 |
|
1618 | | - pch = list_first_entry(&ppp->channels, struct channel, clist); |
1619 | | - chan = pch->chan; |
1620 | 1624 | if (!chan->ops->fill_forward_path) |
1621 | 1625 | return -EOPNOTSUPP; |
1622 | 1626 |
|
@@ -2999,7 +3003,7 @@ ppp_unregister_channel(struct ppp_channel *chan) |
2999 | 3003 | */ |
3000 | 3004 | down_write(&pch->chan_sem); |
3001 | 3005 | spin_lock_bh(&pch->downl); |
3002 | | - pch->chan = NULL; |
| 3006 | + WRITE_ONCE(pch->chan, NULL); |
3003 | 3007 | spin_unlock_bh(&pch->downl); |
3004 | 3008 | up_write(&pch->chan_sem); |
3005 | 3009 | ppp_disconnect_channel(pch); |
@@ -3509,7 +3513,7 @@ ppp_connect_channel(struct channel *pch, int unit) |
3509 | 3513 | hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */ |
3510 | 3514 | if (hdrlen > ppp->dev->hard_header_len) |
3511 | 3515 | ppp->dev->hard_header_len = hdrlen; |
3512 | | - list_add_tail(&pch->clist, &ppp->channels); |
| 3516 | + list_add_tail_rcu(&pch->clist, &ppp->channels); |
3513 | 3517 | ++ppp->n_channels; |
3514 | 3518 | pch->ppp = ppp; |
3515 | 3519 | refcount_inc(&ppp->file.refcnt); |
@@ -3539,10 +3543,11 @@ ppp_disconnect_channel(struct channel *pch) |
3539 | 3543 | if (ppp) { |
3540 | 3544 | /* remove it from the ppp unit's list */ |
3541 | 3545 | ppp_lock(ppp); |
3542 | | - list_del(&pch->clist); |
| 3546 | + list_del_rcu(&pch->clist); |
3543 | 3547 | if (--ppp->n_channels == 0) |
3544 | 3548 | wake_up_interruptible(&ppp->file.rwait); |
3545 | 3549 | ppp_unlock(ppp); |
| 3550 | + synchronize_net(); |
3546 | 3551 | if (refcount_dec_and_test(&ppp->file.refcnt)) |
3547 | 3552 | ppp_destroy_interface(ppp); |
3548 | 3553 | err = 0; |
|
0 commit comments