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 inb977dd1ea5blocked 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:b977dd1ea5
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user