From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org,
linux-rt-users <linux-rt-users@vger.kernel.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Carsten Emde <C.Emde@osadl.org>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
John Kacur <jkacur@redhat.com>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
<stable-rt@vger.kernel.org>
Subject: [PATCH RT 05/10] net: add back the missing serialization in ip_send_unicast_reply()
Date: Thu, 22 Sep 2016 22:49:32 -0400 [thread overview]
Message-ID: <20160923024938.487010640@goodmis.org> (raw)
In-Reply-To: 20160923024927.685936218@goodmis.org
[-- Attachment #1: 0005-net-add-back-the-missing-serialization-in-ip_send_un.patch --]
[-- Type: text/plain, Size: 3535 bytes --]
3.14.79-rt85-rc1 stable review patch.
If anyone has any objections, please let me know.
------------------
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Some time ago Sami Pietikainen reported a crash on -RT in
ip_send_unicast_reply() which was later fixed by Nicholas Mc Guire
(v3.12.8-rt11). Later (v3.18.8) the code was reworked and I dropped the
patch. As it turns out it was mistake.
I have reports that the same crash is possible with a similar backtrace.
It seems that vanilla protects access to this_cpu_ptr() via
local_bh_disable(). This does not work the on -RT since we can have
NET_RX and NET_TX running in parallel on the same CPU.
This is brings back the old locks.
|Unable to handle kernel NULL pointer dereference at virtual address 00000010
|PC is at __ip_make_skb+0x198/0x3e8
|[<c04e39d8>] (__ip_make_skb) from [<c04e3ca8>] (ip_push_pending_frames+0x20/0x40)
|[<c04e3ca8>] (ip_push_pending_frames) from [<c04e3ff0>] (ip_send_unicast_reply+0x210/0x22c)
|[<c04e3ff0>] (ip_send_unicast_reply) from [<c04fbb54>] (tcp_v4_send_reset+0x190/0x1c0)
|[<c04fbb54>] (tcp_v4_send_reset) from [<c04fcc1c>] (tcp_v4_do_rcv+0x22c/0x288)
|[<c04fcc1c>] (tcp_v4_do_rcv) from [<c0474364>] (release_sock+0xb4/0x150)
|[<c0474364>] (release_sock) from [<c04ed904>] (tcp_close+0x240/0x454)
|[<c04ed904>] (tcp_close) from [<c0511408>] (inet_release+0x74/0x7c)
|[<c0511408>] (inet_release) from [<c0470728>] (sock_release+0x30/0xb0)
|[<c0470728>] (sock_release) from [<c0470abc>] (sock_close+0x1c/0x24)
|[<c0470abc>] (sock_close) from [<c0115ec4>] (__fput+0xe8/0x20c)
|[<c0115ec4>] (__fput) from [<c0116050>] (____fput+0x18/0x1c)
|[<c0116050>] (____fput) from [<c0058138>] (task_work_run+0xa4/0xb8)
|[<c0058138>] (task_work_run) from [<c0011478>] (do_work_pending+0xd0/0xe4)
|[<c0011478>] (do_work_pending) from [<c000e740>] (work_pending+0xc/0x20)
|Code: e3530001 8a000001 e3a00040 ea000011 (e5973010)
Cc: stable-rt@vger.kernel.org
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
net/ipv4/tcp_ipv4.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 1b2a53e625cc..ded5b34eba27 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -62,6 +62,7 @@
#include <linux/init.h>
#include <linux/times.h>
#include <linux/slab.h>
+#include <linux/locallock.h>
#include <net/net_namespace.h>
#include <net/icmp.h>
@@ -573,6 +574,7 @@ void tcp_v4_send_check(struct sock *sk, struct sk_buff *skb)
}
EXPORT_SYMBOL(tcp_v4_send_check);
+static DEFINE_LOCAL_IRQ_LOCK(tcp_sk_lock);
/*
* This routine will send an RST to the other tcp.
*
@@ -691,9 +693,12 @@ static void tcp_v4_send_reset(struct sock *sk, struct sk_buff *skb)
net = dev_net(skb_dst(skb)->dev);
arg.tos = ip_hdr(skb)->tos;
+
+ local_lock(tcp_sk_lock);
ip_send_unicast_reply(*this_cpu_ptr(net->ipv4.tcp_sk),
skb, ip_hdr(skb)->saddr,
ip_hdr(skb)->daddr, &arg, arg.iov[0].iov_len);
+ local_unlock(tcp_sk_lock);
TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
TCP_INC_STATS_BH(net, TCP_MIB_OUTRSTS);
@@ -775,9 +780,11 @@ static void tcp_v4_send_ack(struct sk_buff *skb, u32 seq, u32 ack,
if (oif)
arg.bound_dev_if = oif;
arg.tos = tos;
+ local_lock(tcp_sk_lock);
ip_send_unicast_reply(*this_cpu_ptr(net->ipv4.tcp_sk),
skb, ip_hdr(skb)->saddr,
ip_hdr(skb)->daddr, &arg, arg.iov[0].iov_len);
+ local_unlock(tcp_sk_lock);
TCP_INC_STATS_BH(net, TCP_MIB_OUTSEGS);
}
--
2.8.1
next prev parent reply other threads:[~2016-09-23 2:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-23 2:49 [PATCH RT 00/10] Linux 3.14.79-rt85-rc1 Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 01/10] timers: wakeup all timer waiters Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 02/10] timers: wakeup all timer waiters without holding the base lock Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 03/10] sched: lazy_preempt: avoid a warning in the !RT case Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 04/10] scsi/fcoe: Fix get_cpu()/put_cpu_light() imbalance in fcoe_recv_frame() Steven Rostedt
2016-09-23 2:49 ` Steven Rostedt [this message]
2016-09-23 2:49 ` [PATCH RT 06/10] net: add a lock around icmp_sk() Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 07/10] fs/dcache: resched/chill only if we make no progress Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 08/10] x86/preempt-lazy: fixup should_resched() Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 09/10] fs/dcache: incremental fixup of the retry routine Steven Rostedt
2016-09-23 2:49 ` [PATCH RT 10/10] Linux 3.14.79-rt85-rc1 Steven Rostedt
-- strict thread matches above, loose matches on Subject: below --
2016-09-22 23:17 [PATCH RT 00/10] Linux 3.18.42-rt45-rc1 Steven Rostedt
2016-09-22 23:17 ` [PATCH RT 05/10] net: add back the missing serialization in ip_send_unicast_reply() Steven Rostedt
2016-09-22 21:57 [PATCH RT 00/10] Linux 4.1.33-rt38-rc1 Steven Rostedt
[not found] ` <20160922215834.076247330@goodmis.org>
2016-09-22 22:04 ` [PATCH RT 05/10] net: add back the missing serialization in ip_send_unicast_reply() Steven Rostedt
2016-09-22 21:47 [PATCH RT 00/10] Linux 4.4.21-rt31-rc1 Steven Rostedt
[not found] ` <20160922214817.564751063@goodmis.org>
2016-09-22 21:52 ` [PATCH RT 05/10] net: add back the missing serialization in ip_send_unicast_reply() Steven Rostedt
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=20160923024938.487010640@goodmis.org \
--to=rostedt@goodmis.org \
--cc=C.Emde@osadl.org \
--cc=bigeasy@linutronix.de \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=stable-rt@vger.kernel.org \
--cc=tglx@linutronix.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.