[Bug 3913] New: X11 DISPLAY can be reused since X11 listeners set SO_REUSEADDR

bugzilla-daemon at mindrot.org bugzilla-daemon at mindrot.org
Tue Jan 27 05:02:59 AEDT 2026


https://bugzilla.mindrot.org/show_bug.cgi?id=3913

            Bug ID: 3913
           Summary: X11 DISPLAY can be reused since X11 listeners set
                    SO_REUSEADDR
           Product: Portable OpenSSH
           Version: 8.0p1
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P5
         Component: ssh
          Assignee: unassigned-bugs at mindrot.org
          Reporter: spencerbaugh at gmail.com

Some X11-using programs (such as Emacs) can connect to multiple X
servers, and identify them via DISPLAY.  Since ssh sets SO_REUSEADDR,
DISPLAY numbers are very aggressively reused, which can confuse these
programs.

For example:

1. Program P starts, connected to no X server.
2. Session A opens; it successfully binds to localhost:6010, so its
DISPLAY is localhost:10
3. Session A tells program P to make a window on localhost:10.
4. Program P connects to localhost:6010 and makes a window.
5. Session A closes; program P is still connected to localhost:10, but
the listener socket on port 6010 is now closed.
6. Session B opens; since SO_REUSEADDR was set on the socket which
Sesssion A bound to localhost:6010, it is able to successfully bind to
localhost:6010.  So its DISPLAY is also localhost:10.
7. Session B tells program P to make a window on localhost:10.
8. Program P sees that it is already connected to localhost:10, and
makes the window in *Sesssion A*.

This can cause windows to display on a completely wrong X server.

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list