Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1347513

[PATCH 4.4 014/342] tcp: beware of alignments in tcp_get_info()

Path csiph.com!news.freedyn.net!aioe.org!bofh.it!news.nic.it!robomod
From Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject [PATCH 4.4 014/342] tcp: beware of alignments in tcp_get_info()
Date Wed, 02 Mar 2016 02:40:03 +0100
Message-ID <r83VF-sE-45@gated-at.bofh.it> (permalink)
References <r82mS-7Ml-9@gated-at.bofh.it>
Dkim-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; s=mandrill; d=linuxfoundation.org; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Date:MIME-Version:Content-Type:Content-Transfer-Encoding; i=gregkh@linuxfoundation.org; bh=adbjQgC84X6HAf7CnH771XDuqtI=; b=N851cvYIhQjAaUSRvIsqcbC9DcOcwAw5O9azgyGbfuwx+hPBwRadndo3eWW1ZK0FKOaONu91siLJ bqlQet9k6vl1/7HVWpzO7SnEFwc4eWnZUn6U4JLuv+Sy7RGsm+DzDHfBPHEDAXgbzhS8xMxos/FY ieYWn35yY9laNZ9kCSc=
Domainkey-Signature a=rsa-sha1; c=nofws; q=dns; s=mandrill; d=linuxfoundation.org; b=OqthLu6/vW0aHtAcJvc7pcN2e3l1aweKZiQF295bcBuR+BQ2kvtiKAg6oLEDj975zWRXnH3EWt7y UbmX9CswxlshmfA+JZyLYkG1Q3wcXnwGFCQd74UPv3KSPwqcIM4f2jgBWIu5H6oqE69G9XG07Uj8 WHsrFgyqkclW0VAt7EA=;
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; i=@mandrillapp.com; q=dns/txt; s=mandrill; t=1456876427; h=From : Subject : To : Cc : Message-Id : In-Reply-To : References : Date : MIME-Version : Content-Type : Content-Transfer-Encoding : From : Subject : Date : X-Mandrill-User : List-Unsubscribe; bh=ntAUlPCZL0ANM8IyOAHR83spQmefqkD5ZCbf2CK2+bw=; b=LDXzh7JZ/eNVTvhNJ4s8WR3O/q6EFLA16fvtxpn3cMDq4i5BZywxRUX/+uUzpYrQD04scT vkcLazRDKyoUXmjxqXFrDh5+wJYctTlIsHs77SxcLy1C7PUJSidh9ui1H/UY1HQ4vFXkP2js RGeTVc/eYoHsVaBcVB+of/tHNYRNs=
X-Mailer git-send-email 2.7.2
X-Report-Abuse Please forward a copy of this message, including all headers, to abuse@mandrill.com
X-Report-Abuse You can also report abuse here: http://mandrillapp.com/contact/abuse?id=30481620.b1962776674f448c9362636eca23a065
X-Mandrill-User md_30481620
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 66
Organization linux.* mail to news gateway
X-Original-Cc Greg Kroah-Hartman <gregkh@linuxfoundation.org>, <stable@vger.kernel.org>, Eric Dumazet <edumazet@google.com>, "David S. Miller" <davem@davemloft.net>
X-Original-Date Tue, 01 Mar 2016 23:53:47 +0000
X-Original-Message-ID <20160301234528.440311312@linuxfoundation.org>
X-Original-References <20160301234527.990448862@linuxfoundation.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1347513

Show key headers only | View raw


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

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

From: Eric Dumazet <edumazet@google.com>

[ Upstream commit ff5d749772018602c47509bdc0093ff72acd82ec ]

With some combinations of user provided flags in netlink command,
it is possible to call tcp_get_info() with a buffer that is not 8-bytes
aligned.

It does matter on some arches, so we need to use put_unaligned() to
store the u64 fields.

Current iproute2 package does not trigger this particular issue.

Fixes: 0df48c26d841 ("tcp: add tcpi_bytes_acked to tcp_info")
Fixes: 977cb0ecf82e ("tcp: add pacing_rate information into tcp_info")
Signed-off-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.c |   12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -279,6 +279,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/ioctls.h>
+#include <asm/unaligned.h>
 #include <net/busy_poll.h>
 
 int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
@@ -2637,6 +2638,7 @@ void tcp_get_info(struct sock *sk, struc
 	const struct inet_connection_sock *icsk = inet_csk(sk);
 	u32 now = tcp_time_stamp;
 	unsigned int start;
+	u64 rate64;
 	u32 rate;
 
 	memset(info, 0, sizeof(*info));
@@ -2702,15 +2704,17 @@ void tcp_get_info(struct sock *sk, struc
 	info->tcpi_total_retrans = tp->total_retrans;
 
 	rate = READ_ONCE(sk->sk_pacing_rate);
-	info->tcpi_pacing_rate = rate != ~0U ? rate : ~0ULL;
+	rate64 = rate != ~0U ? rate : ~0ULL;
+	put_unaligned(rate64, &info->tcpi_pacing_rate);
 
 	rate = READ_ONCE(sk->sk_max_pacing_rate);
-	info->tcpi_max_pacing_rate = rate != ~0U ? rate : ~0ULL;
+	rate64 = rate != ~0U ? rate : ~0ULL;
+	put_unaligned(rate64, &info->tcpi_max_pacing_rate);
 
 	do {
 		start = u64_stats_fetch_begin_irq(&tp->syncp);
-		info->tcpi_bytes_acked = tp->bytes_acked;
-		info->tcpi_bytes_received = tp->bytes_received;
+		put_unaligned(tp->bytes_acked, &info->tcpi_bytes_acked);
+		put_unaligned(tp->bytes_received, &info->tcpi_bytes_received);
 	} while (u64_stats_fetch_retry_irq(&tp->syncp, start));
 	info->tcpi_segs_out = tp->segs_out;
 	info->tcpi_segs_in = tp->segs_in;

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

[PATCH 4.4 014/342] tcp: beware of alignments in tcp_get_info() Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-03-02 02:40 +0100

csiph-web