net: netlink: reduce extack cookie size
authorJohannes Berg <johannes.berg@intel.com>
Fri, 16 May 2025 11:59:27 +0000 (13:59 +0200)
committerJakub Kicinski <kuba@kernel.org>
Mon, 19 May 2025 23:06:42 +0000 (16:06 -0700)
Seems like the extack cookie hasn't found any users outside
of wireless, which always uses nl_set_extack_cookie_u64().
Thus, allocating 20 bytes for it is pointless, reduce that
to 8 bytes, and add a BUILD_BUG_ON() to ensure it's enough
(obviously it is, for a u64, but in case it changes again.)

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://patch.msgid.link/20250516115927.38209-2-johannes@sipsolutions.net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netlink.h

index c3ae84a77e1691096e589496f153c114361804d9..882e9c1b6c1dcc1fe83870b0a7a7f21daff4f48f 100644 (file)
@@ -63,7 +63,7 @@ netlink_kernel_create(struct net *net, int unit, struct netlink_kernel_cfg *cfg)
 }
 
 /* this can be increased when necessary - don't expose to userland */
-#define NETLINK_MAX_COOKIE_LEN 20
+#define NETLINK_MAX_COOKIE_LEN 8
 #define NETLINK_MAX_FMTMSG_LEN 80
 
 /**
@@ -212,6 +212,7 @@ static inline void nl_set_extack_cookie_u64(struct netlink_ext_ack *extack,
 {
        if (!extack)
                return;
+       BUILD_BUG_ON(sizeof(extack->cookie) < sizeof(cookie));
        memcpy(extack->cookie, &cookie, sizeof(cookie));
        extack->cookie_len = sizeof(cookie);
 }