-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add teleport networking
subprocess for port/agent/x11 forwarding
#43756
Conversation
teleport networking
subprocess for port/agent/x11 forwardingteleport networking
subprocess for port/agent/x11 forwarding
teleport networking
subprocess for port/agent/x11 forwardingteleport networking
subprocess for port/agent/x11 forwarding
ed31990
to
a58d9cb
Compare
The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with |
0a5d488
to
7d965f1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib/sshutils/networking would benefit from some package-level docstring to explain the IPC protocol, since socketpairs passed around like this can be a bit confusing for the reader.
lib/srv/reexec.go
Outdated
var err error | ||
err2 := conn.Control(func(descriptor uintptr) { | ||
// Disable address reuse to prevent socket replacement. | ||
err = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is SO_REUSEADDR ever enabled by default?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-tested this and it seems it's only enabled by default for tcp listeners.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? If so, for what? SO_REUSEADDR
allows listeners to be opened on top of sockets in TIME_WAIT
state, opening multiple listeners on the same bind address at the same time is done with SO_REUSEPORT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure, I've preserved this from the remote port forwarding implementation. @atburke is this check necessary for some purpose or can it be removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe SO_REUSEADDR
was added here to prevent some malicious process from being able to hijack the address. You'd probably be able to get a more complete answer from @jentfoo.
d374507
to
8bad5d5
Compare
lib/srv/reexec.go
Outdated
var err error | ||
err2 := conn.Control(func(descriptor uintptr) { | ||
// Disable address reuse to prevent socket replacement. | ||
err = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary? If so, for what? SO_REUSEADDR
allows listeners to be opened on top of sockets in TIME_WAIT
state, opening multiple listeners on the same bind address at the same time is done with SO_REUSEPORT
.
// direct-streamlocal@openssh.com extension, we should revisit this multithreading limitation | ||
// to prevent performance degradation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for future readers: possible options are:
- doing manual async operations with nonblocking
connect
andselect
/epoll
- opening some amount of goroutines that lock the OS thread and open a pam context, and fanning out operations to be done in one of these PAM-enabled threads
lib/srv/reexec.go
Outdated
// There are currently no known issues with tcp listen/dial in a multithreaded PAM context. | ||
go handleNetworkingRequest(ctx, controlConn, req) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Until someone comes along and really wants to use a random pam module that does network namespacing 😬
lib/srv/reexec.go
Outdated
var err error | ||
err2 := conn.Control(func(descriptor uintptr) { | ||
// Disable address reuse to prevent socket replacement. | ||
err = syscall.SetsockoptInt(int(descriptor), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe SO_REUSEADDR
was added here to prevent some malicious process from being able to hijack the address. You'd probably be able to get a more complete answer from @jentfoo.
701712b
to
dabdd1c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still 100% unconvinced about the utility of unsetting SO_REUSEADDR
or of validateListenerSocket
in general.
dabdd1c
to
57fba88
Compare
b9062c7
to
d697c84
Compare
c6b5534
to
386ac4f
Compare
386ac4f
to
9070a43
Compare
…) on reading from the closed process.
@rosstimothy All tests are passing, just needs a flaky test skip. I double checked that |
/excludeflake * |
This PR was not backported because it introduces a lot of changes. It may be backported later, assuming the v17 test plan doesn't surface any issues with the new functionality. |
Add a unified networking subprocess to handle port/agent/x11 forwarding requests. This subprocess is designed to run as the local user being connected to, including any modifications done to that user via the node's PAM stack.
Fixes #17029
Note: this also fixes agent/port forwarding on new auto-provisioned users, which previously failed on the first attempt (or always with
insecure-drop
). This worked with X11 forwarding before with a more intricate solution, which has been replaced with the simpler "run-as-user" method.Closes #44479
Closes #43623