From nobody Mon Nov 09 13:25:35 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jNVsC4cyBz6yVqT for ; Mon, 09 Nov 2026 13:25:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jNVsC3lfYz4HTR for ; Mon, 09 Nov 2026 13:25:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794230735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7Tc0396MVt4+q4rSxexKdegFxic/Vw4se2xY5up6bb0=; b=Og3wbnTRqS8YZO37T+eY40PQyv+FxqoJ5XF+D4fGF4tlwgGM36DVGoH35KRf1fMaNhoQP1 026P3xr9H4Xr0+eEhBlBSumi8McRUuRQL7iJUzOKFNO0S3G0sXdOkm+xObpfgwluCrwZxx eSJA8I7mDljaMvBycef1ddG9rBY6h7R2v6LPnuBcIvMaKfiH1euf3S2+QYtHe3rMkFAhDy YGmKbvjazNpivRM3a7Xfdwq9ErqCv5Y1+IIRlTII8+2SHP98pg7po82ODkvJ/wqPfbwDVR YAlmf382cIjmdFAY2YPxfIRfGw6oq904pYwtqNiGTkTJxD2R31HE2HT5DNQcUQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794230735; b=ItVxcqAynZYVyia1gFRVBIcSOkMezhix3kjXjERUk3eCROb58KwXjxTKKQSiOZ7EvU5p+c VFOMOM6A5bYjk0IaldkEadGa50rwSVIY8sRNrmssn3jrS72BuaeVF2ReG+46S4yWvF5DmB +jlo9iTDPqcCAh6q2NRyKZEDoLCKMDeAz9dj6v4lztfPrZNuilhKXIud5BQao+IfK5Jko7 E2wwuzVLM6EIzqjmc6B/lW2sVgtIKohJW6DKK71pGlavCZ8I6xWuMIh1R73Ur+Tu9Y4fDp +6xaGJFFUZWNJaUBCjyumzadahQhXYJOE4fH0Mc8+IgMO6XTjZ/kgek0apLhDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794230735; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=7Tc0396MVt4+q4rSxexKdegFxic/Vw4se2xY5up6bb0=; b=yAETOJVX3bstS/X0r77kVK+MZNRcPpDJaxZue/vRWKpIDtS9rgB3w2laCc21GiPGdylNfp B2NVfx6nQG+PbSsIJacsistgu9p31JIXv0qf/lzMiAkY7E+TlNEeuxHBEf8Rz5TqIUteTH qqmO1WiwsWGzXpmp/eeVSBBWqP/n6u9q/bIeWVrCZLe8Fn9p0gCKySe0IysCPQyYEiIRtQ DWgdC3yA0rWS9y3Vb3YPmqX9eAD2xIr4b7C9c7b4XSaf8Y6KjiWlygDRNafSI6/YSg672H XrtEbYSwmkJDz13+tL53rxxk35nhsUtZCpMi/3lWONyZqvUECTSMZ3+gyzQj5w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jNVsC3PW2zhSZ for ; Mon, 09 Nov 2026 13:25:35 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id f7cb by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 09 Nov 2026 13:25:35 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aymeric Wibo Subject: git: dbeadd4326a0 - main - linux: Allow connect() with destination port 0 List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obiwac X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: dbeadd4326a05d6a972e6e319a580944e136f931 Auto-Submitted: auto-generated Date: Mon, 09 Nov 2026 13:25:35 +0000 Message-Id: <6af1c9cf.f7cb.1fbbc288@gitrepo.freebsd.org> The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=dbeadd4326a05d6a972e6e319a580944e136f931 commit dbeadd4326a05d6a972e6e319a580944e136f931 Author: Aymeric Wibo AuthorDate: 2026-09-25 13:20:19 +0000 Commit: Aymeric Wibo CommitDate: 2026-11-09 13:25:21 +0000 linux: Allow connect() with destination port 0 Linux allows connect() with destination port 0, but FreeBSD returns EADDRNOTAVAIL in in_pcbconnect() and in6_pcbladdr(). Some Linux programs (e.g. the new Android CLI tool) rely on this for routability checks, however. Add an SV_CONN_PORT0 flag to sv_flags which is set in the Linux sysvecs, allowing the port 0 guard in the connect paths to be bypassed. Reviewed by: glebius, kib Differential Revision: https://reviews.freebsd.org/D60659 --- sys/i386/linux/linux_sysvec.c | 4 ++-- sys/netinet/in_pcb.c | 3 ++- sys/netinet6/in6_pcb.c | 4 +++- sys/sys/sysent.h | 5 +++-- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c index 5153de5a442d..29de0ca9d2eb 100644 --- a/sys/i386/linux/linux_sysvec.c +++ b/sys/i386/linux/linux_sysvec.c @@ -596,8 +596,8 @@ struct sysentvec linux_sysvec = { .sv_setregs = linux_exec_setregs, .sv_fixlimit = NULL, .sv_maxssiz = NULL, - .sv_flags = SV_ABI_LINUX | SV_AOUT | SV_ILP32 | - SV_SIG_DISCIGN | SV_SIG_WAITNDQ | SV_PERSISTENT_CTTY, + .sv_flags = SV_ABI_LINUX | SV_AOUT | SV_ILP32 | SV_SIG_DISCIGN | + SV_SIG_WAITNDQ | SV_PERSISTENT_CTTY | SV_CONN_PORT0, .sv_set_syscall_retval = linux_set_syscall_retval, .sv_fetch_syscall_args = linux_fetch_syscall_args, .sv_syscallnames = linux_syscallnames, diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index d72fb4cce587..5d2ea6ea3f4d 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include @@ -1150,7 +1151,7 @@ in_pcbconnect(struct inpcb *inp, struct sockaddr_in *sin, struct ucred *cred) KASSERT(sin->sin_len == sizeof(*sin), ("%s: invalid address length for %p", __func__, sin)); - if (sin->sin_port == 0) + if (sin->sin_port == 0 && !SV_CURPROC_FLAG(SV_CONN_PORT0)) return (EADDRNOTAVAIL); anonport = (inp->inp_lport == 0); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 05c04be5dd80..754925b177cf 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -87,6 +87,7 @@ #include #include #include +#include #include @@ -398,7 +399,8 @@ in6_pcbladdr(struct inpcb *inp, struct sockaddr_in6 *sin6, NET_EPOCH_ASSERT(); INP_WLOCK_ASSERT(inp); - if (sin6->sin6_port == 0) + if (sin6->sin6_port == 0 && + !SV_CURPROC_FLAG(SV_CONN_PORT0)) return (EADDRNOTAVAIL); if (sin6->sin6_scope_id == 0 && !V_ip6_use_defzone) diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h index 05c1074fde70..b250ec1f7a70 100644 --- a/sys/sys/sysent.h +++ b/sys/sys/sysent.h @@ -175,7 +175,8 @@ struct sysentvec { #define SV_SIG_DISCIGN 0x00200000 /* Do not discard ignored signals */ #define SV_SIG_WAITNDQ 0x00400000 /* Wait does not dequeue SIGCHLD */ #define SV_DSO_SIG 0x00800000 /* Signal trampoline packed in dso */ -#define SV_PERSISTENT_CTTY 0x01000000 /* Keep ctty after the last close */ +#define SV_PERSISTENT_CTTY 0x01000000 /* Keep ctty after the last close */ +#define SV_CONN_PORT0 0x02000000 /* Allow connect() with port 0 */ #define SV_ABI_MASK 0xff #define SV_PROC_FLAG(p, x) ((p)->p_sysent->sv_flags & (x)) @@ -190,7 +191,7 @@ struct sysentvec { #define SV_ABI_FREEBSD_FLAGS (SV_ABI_FREEBSD | SV_ASLR | SV_SHP | \ SV_TIMEKEEP | SV_RNG_SEED_VER | SV_SIGSYS) #define SV_ABI_LINUX_FLAGS (SV_ABI_LINUX | SV_SHP | SV_SIG_DISCIGN | \ - SV_SIG_WAITNDQ | SV_TIMEKEEP | SV_PERSISTENT_CTTY) + SV_SIG_WAITNDQ | SV_TIMEKEEP | SV_PERSISTENT_CTTY | SV_CONN_PORT0) /* sv_coredump flags */ #define SVC_PT_COREDUMP 0x00000001 /* dump requested by ptrace(2) */