Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1451216 > unrolled thread
| Started by | Alan Curry <rlwinm@sdf.org> |
|---|---|
| First post | 2016-07-27 12:40 +0200 |
| Last post | 2016-07-28 02:40 +0200 |
| Articles | 10 — 5 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Alan Curry <rlwinm@sdf.org> - 2016-07-27 12:40 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) alexmcwhirter@triadic.us - 2016-07-27 20:20 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) alexmcwhirter@triadic.us - 2016-07-28 01:20 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) David Miller <davem@davemloft.net> - 2016-07-28 01:50 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) alexmcwhirter@triadic.us - 2016-07-28 02:40 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Al Viro <viro@ZenIV.linux.org.uk> - 2016-07-28 03:30 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Alan Curry <rlwinm@sdf.org> - 2016-08-03 06:00 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Christian Lamparter <chunkeey@googlemail.com> - 2016-08-03 14:50 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Alan Curry <rlwinm@sdf.org> - 2016-08-04 01:50 +0200
Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) Al Viro <viro@ZenIV.linux.org.uk> - 2016-07-28 02:40 +0200
| From | Alan Curry <rlwinm@sdf.org> |
|---|---|
| Date | 2016-07-27 12:40 +0200 |
| Subject | Re: PROBLEM: network data corruption (bisected to e5a4b0bb803b) |
| Message-ID | <rZupQ-6Bc-23@gated-at.bofh.it> |
Al Viro wrote:
>
> Another thing (and if that works, it's *NOT* a proper fix - it would be
> papering over the problem, but at least it would show where to look for
> it) - try (on top of mainline) the following delta:
I tried it on top of v4.6.4 and on top of the very recent v4.7-2509-g59ebc44
from Linus, and still got corruption.
>
> diff --git a/net/core/datagram.c b/net/core/datagram.c
> index b7de71f..0ee5995 100644
> --- a/net/core/datagram.c
> +++ b/net/core/datagram.c
> @@ -734,7 +734,7 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb,
> if (!chunk)
> return 0;
>
> - if (msg_data_left(msg) < chunk) {
> + if (iov_iter_single_seg_count(&msg->msg_iter) < chunk) {
> if (__skb_checksum_complete(skb))
> goto csum_error;
> if (skb_copy_datagram_msg(skb, hlen, msg, chunk))
>
--
Alan Curry
[toc] | [next] | [standalone]
| From | alexmcwhirter@triadic.us |
|---|---|
| Date | 2016-07-27 20:20 +0200 |
| Message-ID | <rZBAZ-2UQ-1@gated-at.bofh.it> |
| In reply to | #1451216 |
Just to add some more information to this, the corruption seems to effect ssh as well. Using a sun hme interface, occasionally upon an ssh connection it will refuse to authenticate a client with either password or cert authentication. Using wireshark to capture and decrypt the packets between the two machines, the data coming from the server seems good, but the data received by the server from the client is essentially garbage. Note that the client is sending valid data, but the server is corrupting it upon receipt. Closing the connection and starting a new one will remedy the login issue, but you do occasionally see corruption on the server side sporadically. So far this only seems to occur on incoming data, outgoing data seems fine.
[toc] | [prev] | [next] | [standalone]
| From | alexmcwhirter@triadic.us |
|---|---|
| Date | 2016-07-28 01:20 +0200 |
| Message-ID | <rZGhk-667-9@gated-at.bofh.it> |
| In reply to | #1451449 |
On 2016-07-27 14:04, alexmcwhirter@triadic.us wrote: > Just to add some more information to this, the corruption seems to > effect ssh as well. > > Using a sun hme interface, occasionally upon an ssh connection it will > refuse to authenticate a client with either password or cert > authentication. Using wireshark to capture and decrypt the packets > between the two machines, the data coming from the server seems good, > but the data received by the server from the client is essentially > garbage. Note that the client is sending valid data, but the server is > corrupting it upon receipt. Closing the connection and starting a new > one will remedy the login issue, but you do occasionally see > corruption on the server side sporadically. > > So far this only seems to occur on incoming data, outgoing data seems > fine. Also, there is another patch the references this commit on sparc64 at least. https://patchwork.kernel.org/patch/9221895/ I highly expect both my issue and OP's issue to revolve not around commit e5a4b0bb803b specifically, but around other code that no longer behaves as expected because of it.
[toc] | [prev] | [next] | [standalone]
| From | David Miller <davem@davemloft.net> |
|---|---|
| Date | 2016-07-28 01:50 +0200 |
| Message-ID | <rZGKl-6nU-15@gated-at.bofh.it> |
| In reply to | #1451573 |
From: alexmcwhirter@triadic.us Date: Wed, 27 Jul 2016 19:02:40 -0400 > On 2016-07-27 14:04, alexmcwhirter@triadic.us wrote: >> Just to add some more information to this, the corruption seems to >> effect ssh as well. >> Using a sun hme interface, occasionally upon an ssh connection it will >> refuse to authenticate a client with either password or cert >> authentication. Using wireshark to capture and decrypt the packets >> between the two machines, the data coming from the server seems good, >> but the data received by the server from the client is essentially >> garbage. Note that the client is sending valid data, but the server is >> corrupting it upon receipt. Closing the connection and starting a new >> one will remedy the login issue, but you do occasionally see >> corruption on the server side sporadically. >> So far this only seems to occur on incoming data, outgoing data seems >> fine. > > Also, there is another patch the references this commit on sparc64 at > least. > > https://patchwork.kernel.org/patch/9221895/ > > I highly expect both my issue and OP's issue to revolve not around > commit e5a4b0bb803b specifically, but around other code that no longer > behaves as expected because of it. Indeed, and that fault address rounding bug occurs two other times in arch/sparc/lib/user_fixup.c The mentioned patchwork patch should fix the bug and I'll get that into my sparc tree, merged, and queued up for -stable ASAP.
[toc] | [prev] | [next] | [standalone]
| From | alexmcwhirter@triadic.us |
|---|---|
| Date | 2016-07-28 02:40 +0200 |
| Message-ID | <rZHwK-6Xl-7@gated-at.bofh.it> |
| In reply to | #1451585 |
On 2016-07-27 20:31, Al Viro wrote: > On Wed, Jul 27, 2016 at 04:45:43PM -0700, David Miller wrote: > >> > I highly expect both my issue and OP's issue to revolve not around >> > commit e5a4b0bb803b specifically, but around other code that no longer >> > behaves as expected because of it. >> >> Indeed, and that fault address rounding bug occurs two other times >> in arch/sparc/lib/user_fixup.c >> >> The mentioned patchwork patch should fix the bug and I'll get that >> into my sparc tree, merged, and queued up for -stable ASAP. > > Plausible for sparc, but I don't see similar __copy_to_user_inatomic() > bugs in case of x86_64... I'm going to go ahead and say this is where my issue and the op's issue begin to branch apart from one another. He's seeing this on all incoming data, whereas i am only seeing it on ssl data and not on sun4v. At this point i would say data from my issue is only going to cloud this issue as they seem to be two completely different issues revolving around the same commit. If i come across any relevant data for x86_64 ill be sure to post it if this isn't resolved by then, but for now i'm going to refrain from submitting anything sparc related.
[toc] | [prev] | [next] | [standalone]
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Date | 2016-07-28 03:30 +0200 |
| Message-ID | <rZIj7-7ua-1@gated-at.bofh.it> |
| In reply to | #1451602 |
On Wed, Jul 27, 2016 at 08:26:48PM -0400, alexmcwhirter@triadic.us wrote: > I'm going to go ahead and say this is where my issue and the op's issue > begin to branch apart from one another. He's seeing this on all incoming > data, whereas i am only seeing it on ssl data and not on sun4v. > > At this point i would say data from my issue is only going to cloud this > issue as they seem to be two completely different issues revolving around > the same commit. If i come across any relevant data for x86_64 ill be sure > to post it if this isn't resolved by then, but for now i'm going to refrain > from submitting anything sparc related. Which just might mean that we have *three* issues here - (1) buggered __copy_to_user_inatomic() (and friends) on some sparcs (2) your ssl-only corruption (3) Alan's x86_64 corruption on plain TCP read - no ssl *or* sparc anywhere, and no multi-segment recvmsg(). Which would strongly argue in favour of some kind of copy_page_to_iter() breakage triggered when handling a fragmented skb, as in (1). Except that I don't see anything similar in x86_64 uaccess primitives...
[toc] | [prev] | [next] | [standalone]
| From | Alan Curry <rlwinm@sdf.org> |
|---|---|
| Date | 2016-08-03 06:00 +0200 |
| Message-ID | <s1Vvz-5q5-1@gated-at.bofh.it> |
| In reply to | #1451609 |
Al Viro wrote:
>
> Which just might mean that we have *three* issues here -
> (1) buggered __copy_to_user_inatomic() (and friends) on some sparcs
> (2) your ssl-only corruption
> (3) Alan's x86_64 corruption on plain TCP read - no ssl *or* sparc
> anywhere, and no multi-segment recvmsg(). Which would strongly argue in
> favour of some kind of copy_page_to_iter() breakage triggered when handling
> a fragmented skb, as in (1). Except that I don't see anything similar in
> x86_64 uaccess primitives...
>
I think I've solved (3) at least...
Using the twin weapons of printk and stubbornness, I have built a working
theory of the bug. I haven't traced it all the way through, so my explanation
may be partly wrong. I do have a patch that eliminates the symptom in all my
tests though. Here's what happens:
A corrupted packet somehow arrives in skb_copy_and_csum_datagram_msg().
During downloads at reasonably high speed, about 0.1% of my incoming
packets are bad. Probably because the access point is that suspicious
Comcast thing.
skb_copy_and_csum_datagram_msg() does this:
if (skb_copy_and_csum_datagram(skb, hlen, &msg->msg_iter,
chunk, &csum))
goto fault;
if (csum_fold(csum))
goto csum_error;
skb_copy_and_csum_datagram() copies the bad data, computes the checksum,
and *advances the iterator*. The checksum is bad, so it goes to
csum_error, which returns without indicating success to userspace, but the
bad data is in the userspace buffer, and since the iterator has advanced,
the proper data doesn't get written to the proper place when it arrives in a
retransmission. The same iterator is still used because we're still in the
same syscall (I guess - this is one of the parts I didn't check out).
My ugly patch fixes this in the most obvious way: make a local copy of
msg->msg_iter before the call to skb_copy_and_csum_datagram(), and copy it
back if the checksum is bad, just before "goto csum_error;". (I wonder if the
other failure exits from this function might need to do the same thing.)
You can probably reproduce this problem if you deliberately inject some
bad TCP checksums into a stream. Just make sure the receiving machine is
in a blocking read() on the socket when the bad packet arrives. You may
need to resend the offending packet afterward with the checksum corrected.
diff --git a/net/core/datagram.c b/net/core/datagram.c
index b7de71f..574d4bf 100644
--- a/net/core/datagram.c
+++ b/net/core/datagram.c
@@ -730,6 +730,7 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb,
{
__wsum csum;
int chunk = skb->len - hlen;
+ struct iov_iter save_iter;
if (!chunk)
return 0;
@@ -741,11 +742,14 @@ int skb_copy_and_csum_datagram_msg(struct sk_buff *skb,
goto fault;
} else {
csum = csum_partial(skb->data, hlen, skb->csum);
+ memcpy(&save_iter, &msg->msg_iter, sizeof save_iter);
if (skb_copy_and_csum_datagram(skb, hlen, &msg->msg_iter,
chunk, &csum))
goto fault;
- if (csum_fold(csum))
+ if (csum_fold(csum)) {
+ memcpy(&msg->msg_iter, &save_iter, sizeof save_iter);
goto csum_error;
+ }
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE))
netdev_rx_csum_fault(skb->dev);
}
--
Alan Curry
[toc] | [prev] | [next] | [standalone]
| From | Christian Lamparter <chunkeey@googlemail.com> |
|---|---|
| Date | 2016-08-03 14:50 +0200 |
| Message-ID | <s23Mt-2zJ-3@gated-at.bofh.it> |
| In reply to | #1455616 |
On Wednesday, August 3, 2016 3:49:26 AM CEST Alan Curry wrote: > Al Viro wrote: > > > > Which just might mean that we have *three* issues here - > > (1) buggered __copy_to_user_inatomic() (and friends) on some sparcs > > (2) your ssl-only corruption > > (3) Alan's x86_64 corruption on plain TCP read - no ssl *or* sparc > > anywhere, and no multi-segment recvmsg(). Which would strongly argue in > > favour of some kind of copy_page_to_iter() breakage triggered when handling > > a fragmented skb, as in (1). Except that I don't see anything similar in > > x86_64 uaccess primitives... > > > > I think I've solved (3) at least... > > Using the twin weapons of printk and stubbornness, I have built a working > theory of the bug. I haven't traced it all the way through, so my explanation > may be partly wrong. I do have a patch that eliminates the symptom in all my > tests though. Here's what happens: > > A corrupted packet somehow arrives in skb_copy_and_csum_datagram_msg(). > During downloads at reasonably high speed, about 0.1% of my incoming > packets are bad. Probably because the access point is that suspicious > Comcast thing. Thanks for being very persistent with this. I think I'm able to reproduce this now (on any hardware... like r8169 ethernet) as long as the following "traffic policy" is enacted on the HTTP - Server: # tc qdisc add dev eth0 root netem corrupt 0.1% (This needs the "Network Emulation" Sched CONFIG_NET_SCH_NETEM [0].) With your tool (changed to point to my apache local server). I'm seeing corruptions in the "noselect" case. Running it in "select" mode however and the resulting files have no corruptions. About AR9170 corruption issues: I know of one report that the AR9170's Encryption Engine can cause corruptions [1]. In this case outgoing data was corrupted which lead to deauths/disassocs since the AP was basically sending out multicast deauths/disassocs with bad addresses. However, "nohwcrypt" should have made a difference there since the software decryption would discard the faulty package due the message integrety checks. Another source for corruptions could be the USB-PHY (FUSB200) in the AR9170 [2]. I know it's causing problems for the ath9k_htc. However not everyone is affected. One thing I noticed in your previous post is that you "might" not have draft-802.11n enabled. Do you see any "disabling HT/VHT due to WEP/TKIP use." in your dmesg logs? If so, check if you can force your AP to use WPA2 with CCMP/AES only. Regards, Christian [0] <http://www.spinics.net/lists/linux-wireless/msg60104.html> [1] <https://wiki.linuxfoundation.org/networking/netem> [2] <https://github.com/qca/open-ath9k-htc-firmware/wiki/usb-related-issues>
[toc] | [prev] | [next] | [standalone]
| From | Alan Curry <rlwinm@sdf.org> |
|---|---|
| Date | 2016-08-04 01:50 +0200 |
| Message-ID | <s2e5c-U8-23@gated-at.bofh.it> |
| In reply to | #1455785 |
Christian Lamparter wrote: > > One thing I noticed in your previous post is that you "might" not have > draft-802.11n enabled. Do you see any "disabling HT/VHT due to WEP/TKIP use." > in your dmesg logs? If so, check if you can force your AP to use WPA2 > with CCMP/AES only. > Yes, I've had that message. The reason wan't on the AP though. My wpa_supplicant.conf only had TKIP enabled, because that's what was in the sample configuration file I started with. Adding CCMP there worked, and in that mode I'm no longer getting any corrupted packets. If I'd paid attention to the encryption options when setting up this network originally, I would have had CCMP the whole time, with no corrupted packets, and never would have found the iov iterator bug... -- Alan Curry
[toc] | [prev] | [next] | [standalone]
| From | Al Viro <viro@ZenIV.linux.org.uk> |
|---|---|
| Date | 2016-07-28 02:40 +0200 |
| Message-ID | <rZHwK-6Xl-5@gated-at.bofh.it> |
| In reply to | #1451585 |
On Wed, Jul 27, 2016 at 04:45:43PM -0700, David Miller wrote: > > I highly expect both my issue and OP's issue to revolve not around > > commit e5a4b0bb803b specifically, but around other code that no longer > > behaves as expected because of it. > > Indeed, and that fault address rounding bug occurs two other times > in arch/sparc/lib/user_fixup.c > > The mentioned patchwork patch should fix the bug and I'll get that > into my sparc tree, merged, and queued up for -stable ASAP. Plausible for sparc, but I don't see similar __copy_to_user_inatomic() bugs in case of x86_64...
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web