From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Gao Feng <gfree.wind@vip.163.com>,
Liu Jianying <jianying.liu@ikuai8.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.12 01/17] ppp: Fix false xmit recursion detect with two ppp devices
Date: Fri, 11 Aug 2017 15:01:20 -0700 [thread overview]
Message-ID: <20170811220035.694552488@linuxfoundation.org> (raw)
In-Reply-To: <20170811220035.638197338@linuxfoundation.org>
4.12-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gao Feng <gfree.wind@vip.163.com>
[ Upstream commit e5dadc65f9e0177eb649bcd9d333f1ebf871223e ]
The global percpu variable ppp_xmit_recursion is used to detect the ppp
xmit recursion to avoid the deadlock, which is caused by one CPU tries to
lock the xmit lock twice. But it would report false recursion when one CPU
wants to send the skb from two different PPP devices, like one L2TP on the
PPPoE. It is a normal case actually.
Now use one percpu member of struct ppp instead of the gloable variable to
detect the xmit recursion of one ppp device.
Fixes: 55454a565836 ("ppp: avoid dealock on recursive xmit")
Signed-off-by: Gao Feng <gfree.wind@vip.163.com>
Signed-off-by: Liu Jianying <jianying.liu@ikuai8.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/net/ppp/ppp_generic.c | 30 +++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -120,6 +120,7 @@ struct ppp {
int n_channels; /* how many channels are attached 54 */
spinlock_t rlock; /* lock for receive side 58 */
spinlock_t wlock; /* lock for transmit side 5c */
+ int *xmit_recursion __percpu; /* xmit recursion detect */
int mru; /* max receive unit 60 */
unsigned int flags; /* control bits 64 */
unsigned int xstate; /* transmit state bits 68 */
@@ -1025,6 +1026,7 @@ static int ppp_dev_configure(struct net
struct ppp *ppp = netdev_priv(dev);
int indx;
int err;
+ int cpu;
ppp->dev = dev;
ppp->ppp_net = src_net;
@@ -1039,6 +1041,15 @@ static int ppp_dev_configure(struct net
INIT_LIST_HEAD(&ppp->channels);
spin_lock_init(&ppp->rlock);
spin_lock_init(&ppp->wlock);
+
+ ppp->xmit_recursion = alloc_percpu(int);
+ if (!ppp->xmit_recursion) {
+ err = -ENOMEM;
+ goto err1;
+ }
+ for_each_possible_cpu(cpu)
+ (*per_cpu_ptr(ppp->xmit_recursion, cpu)) = 0;
+
#ifdef CONFIG_PPP_MULTILINK
ppp->minseq = -1;
skb_queue_head_init(&ppp->mrq);
@@ -1050,11 +1061,15 @@ static int ppp_dev_configure(struct net
err = ppp_unit_register(ppp, conf->unit, conf->ifname_is_set);
if (err < 0)
- return err;
+ goto err2;
conf->file->private_data = &ppp->file;
return 0;
+err2:
+ free_percpu(ppp->xmit_recursion);
+err1:
+ return err;
}
static const struct nla_policy ppp_nl_policy[IFLA_PPP_MAX + 1] = {
@@ -1398,18 +1413,16 @@ static void __ppp_xmit_process(struct pp
ppp_xmit_unlock(ppp);
}
-static DEFINE_PER_CPU(int, ppp_xmit_recursion);
-
static void ppp_xmit_process(struct ppp *ppp)
{
local_bh_disable();
- if (unlikely(__this_cpu_read(ppp_xmit_recursion)))
+ if (unlikely(*this_cpu_ptr(ppp->xmit_recursion)))
goto err;
- __this_cpu_inc(ppp_xmit_recursion);
+ (*this_cpu_ptr(ppp->xmit_recursion))++;
__ppp_xmit_process(ppp);
- __this_cpu_dec(ppp_xmit_recursion);
+ (*this_cpu_ptr(ppp->xmit_recursion))--;
local_bh_enable();
@@ -1903,7 +1916,7 @@ static void __ppp_channel_push(struct ch
read_lock_bh(&pch->upl);
ppp = pch->ppp;
if (ppp)
- __ppp_xmit_process(ppp);
+ ppp_xmit_process(ppp);
read_unlock_bh(&pch->upl);
}
}
@@ -1912,9 +1925,7 @@ static void ppp_channel_push(struct chan
{
local_bh_disable();
- __this_cpu_inc(ppp_xmit_recursion);
__ppp_channel_push(pch);
- __this_cpu_dec(ppp_xmit_recursion);
local_bh_enable();
}
@@ -3055,6 +3066,7 @@ static void ppp_destroy_interface(struct
#endif /* CONFIG_PPP_FILTER */
kfree_skb(ppp->xmit_pending);
+ free_percpu(ppp->xmit_recursion);
free_netdev(ppp->dev);
}
next prev parent reply other threads:[~2017-08-11 22:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-11 22:01 [PATCH 4.12 00/17] 4.12.7-stable review Greg Kroah-Hartman
2017-08-11 22:01 ` Greg Kroah-Hartman [this message]
2017-08-11 22:01 ` [PATCH 4.12 02/17] ppp: fix xmit recursion detection on ppp channels Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 03/17] tcp: avoid setting cwnd to invalid ssthresh after cwnd reduction states Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 04/17] net: fix keepalive code vs TCP_FASTOPEN_CONNECT Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 05/17] ipv6: set rt6i_protocol properly in the route when it is installed Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 06/17] bpf, s390: fix jit branch offset related to ldimm64 Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 07/17] net/mlx4_en: dont set CHECKSUM_COMPLETE on SCTP packets Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 08/17] net: sched: set xt_tgchk_param par.net properly in ipt_init_target Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 09/17] net: sched: set xt_tgchk_param par.nft_compat as 0 " Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 10/17] tcp: fastopen: tcp_connect() must refresh the route Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 12/17] net: avoid skb_warn_bad_offload false positives on UFO Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 13/17] igmp: Fix regression caused by igmp sysctl namespace code Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 14/17] udp: consistently apply ufo or fragmentation Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 15/17] packet: fix tp_reserve race in packet_set_ring Greg Kroah-Hartman
2017-08-11 22:01 ` [PATCH 4.12 16/17] scsi: sg: only check for dxfer_len greater than 256M Greg Kroah-Hartman
2017-08-12 1:55 ` [PATCH 4.12 00/17] 4.12.7-stable review Shuah Khan
2017-08-12 14:30 ` Greg Kroah-Hartman
2017-08-12 12:24 ` Guenter Roeck
2017-08-12 16:07 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170811220035.694552488@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=davem@davemloft.net \
--cc=gfree.wind@vip.163.com \
--cc=jianying.liu@ikuai8.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).