Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nix/ssh-tunnel: Prevent IPv6 address generation #508

Merged
merged 1 commit into from Dec 13, 2016

Conversation

aszlig
Copy link
Member

@aszlig aszlig commented Sep 22, 2016

This should fix encryptedLinksTo for kernels with version 4.5 and later. I've tested this in production but currently I can't test tests.functional.test_encrypted_links, because I don't have (nor use) VirtualBox anymore.

So to anybody who's running VirtualBox, can you please run the following command in the checked out source tree of this branch and report success/failure back here?

./dev-shell --command 'python tests.py tests.functional.test_encrypted_links'

Thanks a lot. Reviews are also welcome of course :-)

Cc: @rbvermaa

This is a regression with kernel versions 4.5 or later which causes a
SSH tunnel to drop packets within the receiving end of the OpenSSH
server loop, more exactly: They don't get reinserted into the tun device
after being received via the encrypted stream.

A strace of two ICMPv4 packets coming in (FD 3 is the encrypted socket):

read(3, "Mp-\v[\t\300"..., 16384) = 124
select(14, [3 5 8], [], NULL, NULL)     = 1 (in [3])
read(3, "jm\17t\222"..., 16384) = 124
select(14, [3 5 8], [], NULL, NULL)     = 1 (in [3])

I haven't found the exact culprit on why OpenSSH doesn't send the packet
back into the tun device, but after countless hours of debugging and
doing a bisect against the kernel, I found that the commit which causes
the regression is torvalds/linux@cc9da6c.

The bug has already been reported upstream at:

https://bugzilla.kernel.org/show_bug.cgi?id=121131

While the final fix for this issue is still not clear on the kernel
front, we can do our own part to mitigate this:

We don't use IPv6 for SSH tunnels anyway, so we can safely disable IPv6
address autogeneration for them.

I've switched to iproute instead of nettools because it allows for more
fine-grained control (setting addrgenmode with ifconfing is not possible
AFAIK).

Also, I've linked the commands via && instead of using semicolons to
ensure that we get a unit failure if one of the commands along the chain
should fail.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@aszlig aszlig added the bug label Sep 22, 2016
@aszlig aszlig self-assigned this Sep 22, 2016
@aszlig aszlig added this to the 1.4.1 milestone Sep 22, 2016
@domenkozar
Copy link
Member

@aszlig I fail to see the correlation between ipv6 adress generation and encryptedLinksTo. Can you explain why this fixes it?

@aszlig
Copy link
Member Author

aszlig commented Oct 10, 2016

@domenkozar: See the commit message for a detailed explanation. The tunnel device gets an IPv4 address assigned and also implicitly an IPv6 address since kernel 4.5, which causes a mismatch in the packet length for the user space process (in this case OpenSSH).

aszlig added a commit to openlab-aux/vuizvui that referenced this pull request Oct 27, 2016
This includes a small patch coming from NixOS/nixops#508 for fixing
peer-to-peer tunneling for kernel versions >= 4.5.

In addition, I'm patching out the Python sqlite3 module as this also
doesn't exist anymore since
NixOS/nixpkgs@bee4392.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
@rbvermaa
Copy link
Member

@edolstra Could you look at this PR?

@rbvermaa rbvermaa merged commit 322e85f into NixOS:master Dec 13, 2016
aszlig added a commit to openlab-aux/vuizvui that referenced this pull request Apr 19, 2017
We can now safely drop the patch for NixOS/nixops#508, because it has
long been applied to master and also partially reverted as well in
NixOS/nixops@4bbceb2.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants