|
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>
|
@@ -1598,11 +1599,14 @@ static int ppp_fill_forward_path(struct net_device_path_ctx *ctx,
|
1598 | 1599 | if (ppp->flags & SC_MULTILINK)
|
1599 | 1600 | return -EOPNOTSUPP;
|
1600 | 1601 |
|
1601 |
| - if (list_empty(&ppp->channels)) |
| 1602 | + pch = list_first_or_null_rcu(&ppp->channels, struct channel, clist); |
| 1603 | + if (!pch) |
| 1604 | + return -ENODEV; |
| 1605 | + |
| 1606 | + chan = READ_ONCE(pch->chan); |
| 1607 | + if (!chan) |
1602 | 1608 | return -ENODEV;
|
1603 | 1609 |
|
1604 |
| - pch = list_first_entry(&ppp->channels, struct channel, clist); |
1605 |
| - chan = pch->chan; |
1606 | 1610 | if (!chan->ops->fill_forward_path)
|
1607 | 1611 | return -EOPNOTSUPP;
|
1608 | 1612 |
|
@@ -2994,7 +2998,7 @@ ppp_unregister_channel(struct ppp_channel *chan)
|
2994 | 2998 | */
|
2995 | 2999 | down_write(&pch->chan_sem);
|
2996 | 3000 | spin_lock_bh(&pch->downl);
|
2997 |
| - pch->chan = NULL; |
| 3001 | + WRITE_ONCE(pch->chan, NULL); |
2998 | 3002 | spin_unlock_bh(&pch->downl);
|
2999 | 3003 | up_write(&pch->chan_sem);
|
3000 | 3004 | ppp_disconnect_channel(pch);
|
@@ -3515,7 +3519,7 @@ ppp_connect_channel(struct channel *pch, int unit)
|
3515 | 3519 | hdrlen = pch->file.hdrlen + 2; /* for protocol bytes */
|
3516 | 3520 | if (hdrlen > ppp->dev->hard_header_len)
|
3517 | 3521 | ppp->dev->hard_header_len = hdrlen;
|
3518 |
| - list_add_tail(&pch->clist, &ppp->channels); |
| 3522 | + list_add_tail_rcu(&pch->clist, &ppp->channels); |
3519 | 3523 | ++ppp->n_channels;
|
3520 | 3524 | pch->ppp = ppp;
|
3521 | 3525 | refcount_inc(&ppp->file.refcnt);
|
@@ -3545,10 +3549,11 @@ ppp_disconnect_channel(struct channel *pch)
|
3545 | 3549 | if (ppp) {
|
3546 | 3550 | /* remove it from the ppp unit's list */
|
3547 | 3551 | ppp_lock(ppp);
|
3548 |
| - list_del(&pch->clist); |
| 3552 | + list_del_rcu(&pch->clist); |
3549 | 3553 | if (--ppp->n_channels == 0)
|
3550 | 3554 | wake_up_interruptible(&ppp->file.rwait);
|
3551 | 3555 | ppp_unlock(ppp);
|
| 3556 | + synchronize_net(); |
3552 | 3557 | if (refcount_dec_and_test(&ppp->file.refcnt))
|
3553 | 3558 | ppp_destroy_interface(ppp);
|
3554 | 3559 | err = 0;
|
|
0 commit comments