From 57048338eed191ea57eaf6a1082aa37ecaf0c4c8 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Tue, 23 Jul 2019 10:32:07 +0200 Subject: [PATCH] platform/netlink: mark nested netlink attribute with NLA_F_NESTED Kernel 5.2 is adding stricter checking for netlink messages. In particular, for certain API it checks now that NLA_F_NESTED flag is set for nested attributes ([1]). Note that libnl3 does not ever set this flag, and since our netlink implementation is copied from there, certain netlink messages are now rejected as invalid. On the other hand, libmnl always adds this flag ([2]). So we should do that as well. In particular, this affects the WireGuard netlink API causing request from NetworkManager to be rejected ([3]). [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b424e432e770d6dd572765459d5b6a96a19c5286 [2] https://git.netfilter.org/libmnl/tree/src/attr.c?id=5937dfcb0185f5cb9cf275992ea701ec4e619d9c#n535 [3] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/issues/212 https://gitlab.freedesktop.org/NetworkManager/NetworkManager/merge_requests/210 (cherry picked from commit 7811d1c187b7140e31b2c0145e4d3097c7e38750) --- src/platform/nm-netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform/nm-netlink.c b/src/platform/nm-netlink.c index 71506a2c37..a03dda53bb 100644 --- a/src/platform/nm-netlink.c +++ b/src/platform/nm-netlink.c @@ -510,7 +510,7 @@ nla_nest_start (struct nl_msg *msg, int attrtype) { struct nlattr *start = (struct nlattr *) nlmsg_tail (msg->nm_nlh); - if (nla_put (msg, attrtype, 0, NULL) < 0) + if (nla_put (msg, NLA_F_NESTED | attrtype, 0, NULL) < 0) return NULL; return start;