From nobody Tue May 28 20:13:17 2024 X-Original-To: dev-commits-src-main@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 4VpkGk118Nz5L3rx; Tue, 28 May 2024 20:13:18 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VpkGk0SVHz4Xys; Tue, 28 May 2024 20:13:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716927198; 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=qif750Lq6BD0fwCFL3nRHnn0SrL+dba7YaPjmmfUKzw=; b=MPnFBlGyerC04y+9ZG+TDS/I7MKY5+Z2JjNxwMXT49REQDNv0dLJz28NedEsdes9oeH0l+ UKwn6Fb4Gc8uGTP4+QILBPzZwveWWYi3OdLBKWEXctj17lZHsybBN7QAeJYlTY1dkZHUY6 RLpXoEgQ2alynoFHPs9X650LDNUtkkVVOVuzYQwN1PTDQBtyMQWP3EvFoPnpSeMnpnhg1p GpTVEnnh26PIO85EK41eyOBg+tmn/jlJPx15X7wHEjYZJZZ6sZMp6UMMf0KHPTw0OF/Fsr ZYH/FB386CNbYbyUs+9+5mzCPaRqIwa1jfZLFSlf6T6ozDCM0nRT5Wj38ZAJ/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716927198; a=rsa-sha256; cv=none; b=SxdanQ3p5kVpVaGr1Fk7ZQu9h+/7C2/O7ILEsYt7g5DCSyD/np6vwrtEhLdowsFs6E1Vm9 47LPpklrniZHmmEJFr4Asua9tgkE8QQQU9IXO3RByb6fOQLl9WgqpHOsJDvUZtwnYogL9G F07sTvAYph3HQFHMh3Cxv+bU17Mwqlni77Foy+soIfjYAjejFfkvSnK4awo7NvSo8I5zV6 AIZMSqsjj0A9LGp0ZFDY3Jxbp4PJtFwXQxgTVxIck7AAV+IXEqQWDR71FMFDGf795smW9C SwlUDFRVQvyvHVBJcWMvBQKoiwBH09RXNAzyNGP6I0aQpd98KzOln9/PXfbPUw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716927198; 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=qif750Lq6BD0fwCFL3nRHnn0SrL+dba7YaPjmmfUKzw=; b=fKxrILbCEAuJ+D0SCQVld7FdsAF17YP2cAXgO1NSfaFD2EoHzOjw12D+fzTIQYNg2P17le 0sqF+whbnDIPE5OVNlSoWSsQC+8Wz82DeH3pkEKJTPu13gcPObvi0U7dFkExZ2Pqn7shus TH5j4dWdvo6chbZRYL/zJbRXahvP5aL4GqwOye1PZy0+CQyyM/3XacYjMPIPV2+cEZBpGI ET0R46VDJu5/Q+so76cc8EnuB5EzZk4n8a/h/R9kxvLneSKeCAU9eFrJR4rCVpeBgBiItG Y3PN366BLLKxA65hpwpYclsyqKZt/kW4N9Zawctm3mqFuWZiPn9Usb/6sqsuTw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VpkGk03gFzRKD; Tue, 28 May 2024 20:13:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44SKDHWE031382; Tue, 28 May 2024 20:13:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44SKDHtp031379; Tue, 28 May 2024 20:13:17 GMT (envelope-from git) Date: Tue, 28 May 2024 20:13:17 GMT Message-Id: <202405282013.44SKDHtp031379@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 2780e5f43d5b - main - linux: allow RTM_GETADDR without full ifaddrmsg argument List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2780e5f43d5b0e8b155472300ee63816a660780e Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=2780e5f43d5b0e8b155472300ee63816a660780e commit 2780e5f43d5b0e8b155472300ee63816a660780e Author: Gleb Smirnoff AuthorDate: 2024-05-28 20:13:08 +0000 Commit: Gleb Smirnoff CommitDate: 2024-05-28 20:13:08 +0000 linux: allow RTM_GETADDR without full ifaddrmsg argument Even modern glibc uses truncated argument for RTM_GETADDR when it wants to list all addresses in a system. See sysdeps/unix/sysv/linux/ifaddrs.c:__netlink_sendreq(). It sends a one char payload. Linux kernel allows that as long as given socket is not marked as a 'strict'. We have a similar flag in the general netlink code and it is checked in sys/netlink/netlink_message_parser.h:nl_parse_header(). If the flag is not present, parser will allocate a temporary zeroed buffer to make the message correct. The checks added in b977dd1ea5fb blocked such message before the parser. My reading of glibc says that there are two types of messages that are sent with __netlink_sendreq() - RTM_GETLINK and RTM_GETADDR. The RTM_GETLINK is binary compatible between Linux and FreeBSD and thus doesn't need any ABI handler. PR: 279012 Fixes: b977dd1ea5fbc2df3f1279330be4d089322eb2cf --- sys/compat/linux/linux_netlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/compat/linux/linux_netlink.c b/sys/compat/linux/linux_netlink.c index 8675f830b4ef..f51838ee00d7 100644 --- a/sys/compat/linux/linux_netlink.c +++ b/sys/compat/linux/linux_netlink.c @@ -94,7 +94,8 @@ rtnl_ifaddr_from_linux(struct nlmsghdr *hdr, struct nl_pstate *npt) struct ifaddrmsg *ifam = (struct ifaddrmsg *)(hdr + 1); sa_family_t f; - if (hdr->nlmsg_len < sizeof(struct nlmsghdr) + sizeof(struct ifaddrmsg)) + if (hdr->nlmsg_len < sizeof(struct nlmsghdr) + + offsetof(struct ifaddrmsg, ifa_family) + sizeof(ifam->ifa_family)) return (EBADMSG); if ((f = linux_to_bsd_domain(ifam->ifa_family)) == AF_UNKNOWN) return (EPFNOSUPPORT);