Date: Tue, 25 Nov 2025 03:19:31 +0000 From: Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 00e4b169f409 - stable/14 - openssh: Don't attempt to connect to unsupported addresses Message-ID: <69252043.33823.4e15c483@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=00e4b169f4090e3b4bf1454c989df82d94b7d62e commit 00e4b169f4090e3b4bf1454c989df82d94b7d62e Author: Dag-Erling Smørgrav <des@FreeBSD.org> AuthorDate: 2025-11-21 06:28:13 +0000 Commit: Dag-Erling Smørgrav <des@FreeBSD.org> CommitDate: 2025-11-25 03:19:17 +0000 openssh: Don't attempt to connect to unsupported addresses When iterating over known addresses for the requested target host name, skip those that are not supported by the running kernel. MFC after: 1 week PR: 195231 Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D53588 (cherry picked from commit 5818b6ee552b302f5300934f9b8cb94881867a5f) --- crypto/openssh/FREEBSD-upgrade | 7 +++++++ crypto/openssh/sshconnect.c | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/crypto/openssh/FREEBSD-upgrade b/crypto/openssh/FREEBSD-upgrade index efea4cda77b4..d8fc986b71ca 100644 --- a/crypto/openssh/FREEBSD-upgrade +++ b/crypto/openssh/FREEBSD-upgrade @@ -177,6 +177,13 @@ skip setting DISABLE_LASTLOG which we've applied for FreeBSD, but the autoconf machinery really ought to be reworked. Reported upstream at https://lists.mindrot.org/pipermail/openssh-unix-dev/2022-May/040242.html + +11) Protocol selection + + We use the non-portable feature_present(3) API to determine which + internet protocols are supported by the kernel before trying to + connect to the target host. This avoids confusing the user with + spurious error messages. This port was brought to you by (in no particular order) DARPA, NAI diff --git a/crypto/openssh/sshconnect.c b/crypto/openssh/sshconnect.c index 7cf6b638674c..f0c080cb140b 100644 --- a/crypto/openssh/sshconnect.c +++ b/crypto/openssh/sshconnect.c @@ -458,6 +458,8 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, memset(ntop, 0, sizeof(ntop)); memset(strport, 0, sizeof(strport)); + int inet_supported = feature_present("inet"); + int inet6_supported = feature_present("inet6"); for (attempt = 0; attempt < connection_attempts; attempt++) { if (attempt > 0) { /* Sleep a moment before retrying. */ @@ -482,6 +484,13 @@ ssh_connect_direct(struct ssh *ssh, const char *host, struct addrinfo *aitop, errno = oerrno; continue; } + if ((ai->ai_family == AF_INET && !inet_supported) || + (ai->ai_family == AF_INET6 && !inet6_supported)) { + debug2_f("skipping address [%s]:%s: " + "unsupported address family", ntop, strport); + errno = EAFNOSUPPORT; + continue; + } if (options.address_family != AF_UNSPEC && ai->ai_family != options.address_family) { debug2_f("skipping address [%s]:%s: "help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69252043.33823.4e15c483>
