linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Michal Kubecek <mkubecek@suse.cz>,
	Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 3.10 03/31] tcp: prevent fetching dst twice in early demux code
Date: Sun, 26 Apr 2015 15:46:23 +0200	[thread overview]
Message-ID: <20150426134209.399311869@linuxfoundation.org> (raw)
In-Reply-To: <20150426134209.255099785@linuxfoundation.org>

3.10-stable review patch.  If anyone has any objections, please let me know.

------------------

From: =?UTF-8?q?Michal=20Kube=C4=8Dek?= <mkubecek@suse.cz>

[ Upstream commit d0c294c53a771ae7e84506dfbd8c18c30f078735 ]

On s390x, gcc 4.8 compiles this part of tcp_v6_early_demux()

        struct dst_entry *dst = sk->sk_rx_dst;

        if (dst)
                dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);

to code reading sk->sk_rx_dst twice, once for the test and once for
the argument of ip6_dst_check() (dst_check() is inline). This allows
ip6_dst_check() to be called with null first argument, causing a crash.

Protect sk->sk_rx_dst access by ACCESS_ONCE() both in IPv4 and IPv6
TCP early demux code.

Fixes: 41063e9dd119 ("ipv4: Early TCP socket demux.")
Fixes: c7109986db3c ("ipv6: Early TCP socket demux")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Acked-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 net/ipv4/tcp_ipv4.c |    2 +-
 net/ipv6/tcp_ipv6.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1901,7 +1901,7 @@ void tcp_v4_early_demux(struct sk_buff *
 		skb->sk = sk;
 		skb->destructor = sock_edemux;
 		if (sk->sk_state != TCP_TIME_WAIT) {
-			struct dst_entry *dst = sk->sk_rx_dst;
+			struct dst_entry *dst = ACCESS_ONCE(sk->sk_rx_dst);
 
 			if (dst)
 				dst = dst_check(dst, 0);
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1616,7 +1616,7 @@ static void tcp_v6_early_demux(struct sk
 		skb->sk = sk;
 		skb->destructor = sock_edemux;
 		if (sk->sk_state != TCP_TIME_WAIT) {
-			struct dst_entry *dst = sk->sk_rx_dst;
+			struct dst_entry *dst = ACCESS_ONCE(sk->sk_rx_dst);
 
 			if (dst)
 				dst = dst_check(dst, inet6_sk(sk)->rx_dst_cookie);



  parent reply	other threads:[~2015-04-26 13:59 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-26 13:46 [PATCH 3.10 00/31] 3.10.76-stable review Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 01/31] conditionally define U32_MAX Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 02/31] remove extra definitions of U32_MAX Greg Kroah-Hartman
2015-04-26 13:46 ` Greg Kroah-Hartman [this message]
2015-04-26 13:46 ` [PATCH 3.10 04/31] ipv6: Dont reduce hop limit for an interface Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 05/31] tcp: fix FRTO undo on cumulative ACK of SACKed range Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 06/31] tcp: tcp_make_synack() should clear skb->tstamp Greg Kroah-Hartman
2015-04-27  4:02   ` Willy Tarreau
2015-04-27  4:23     ` Eric Dumazet
2015-04-27  4:45     ` David Miller
2015-04-26 13:46 ` [PATCH 3.10 07/31] 8139cp: Call dev_kfree_skby_any instead of kfree_skb Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 08/31] 8139too: Call dev_kfree_skby_any instead of dev_kfree_skb Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 09/31] r8169: " Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 10/31] bnx2: " Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 11/31] tg3: " Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 12/31] ixgb: " Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 13/31] benet: Call dev_kfree_skby_any instead of kfree_skb Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 14/31] serial: 8250_dw: Fix deadlock in LCR workaround Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 15/31] jfs: fix readdir regression Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 16/31] splice: Apply generic position and size checks to each write Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 17/31] mm: Fix NULL pointer dereference in madvise(MADV_WILLNEED) support Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 18/31] Bluetooth: Enable Atheros 0cf3:311e for firmware upload Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 19/31] Bluetooth: Add firmware update for Atheros 0cf3:311f Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 20/31] Bluetooth: btusb: Add IMC Networks (Broadcom based) Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 21/31] Bluetooth: Add support for Intel bootloader devices Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 22/31] Bluetooth: Ignore isochronous endpoints for Intel USB bootloader Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 23/31] netfilter: conntrack: disable generic tracking for known protocols Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 24/31] KVM: x86: SYSENTER emulation is broken Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 26/31] move d_rcu from overlapping d_child to overlapping d_alias Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 27/31] deal with deadlock in d_walk() Greg Kroah-Hartman
2015-04-27  1:20   ` Ben Hutchings
2015-04-27  7:53     ` Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 28/31] vm: add VM_FAULT_SIGSEGV handling support Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 29/31] vm: make stack guard page errors return VM_FAULT_SIGSEGV rather than SIGBUS Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 30/31] x86: mm: move mmap_sem unlock from mm_fault_error() to caller Greg Kroah-Hartman
2015-04-26 13:46 ` [PATCH 3.10 31/31] sb_edac: avoid INTERNAL ERROR message in EDAC with unspecified channel Greg Kroah-Hartman
2015-04-26 15:15 ` [PATCH 3.10 00/31] 3.10.76-stable review Guenter Roeck
2015-04-26 17:12   ` Greg Kroah-Hartman
2015-04-26 17:14     ` Guenter Roeck
2015-04-26 20:01 ` Guenter Roeck
2015-04-27 17:19 ` Shuah Khan

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=20150426134209.399311869@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkubecek@suse.cz \
    --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).