]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
amt: fix size calculation in amt_get_size()
authorEric Dumazet <edumazet@google.com>
Wed, 1 Jul 2026 12:23:29 +0000 (12:23 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Mon, 6 Jul 2026 11:01:24 +0000 (13:01 +0200)
amt_get_size() incorrectly used sizeof(struct iphdr) for the sizes of
IFLA_AMT_DISCOVERY_IP, IFLA_AMT_REMOTE_IP, and IFLA_AMT_LOCAL_IP.
These attributes contain IPv4 addresses (__be32), not full IP headers.

Replace sizeof(struct iphdr) with sizeof(__be32) to avoid over-allocating
netlink message space.

Fixes: b9022b53adad ("amt: add control plane of amt interface")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Link: https://patch.msgid.link/20260701122329.3562825-1-edumazet@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/amt.c

index 724a8163a5142a6835950abb63d80f29417b2654..951dd10e192b7924f9d3f05065a298ddcf8f4b25 100644 (file)
@@ -3301,9 +3301,9 @@ static size_t amt_get_size(const struct net_device *dev)
               nla_total_size(sizeof(__u16)) + /* IFLA_AMT_GATEWAY_PORT */
               nla_total_size(sizeof(__u32)) + /* IFLA_AMT_LINK */
               nla_total_size(sizeof(__u32)) + /* IFLA_MAX_TUNNELS */
-              nla_total_size(sizeof(struct iphdr)) + /* IFLA_AMT_DISCOVERY_IP */
-              nla_total_size(sizeof(struct iphdr)) + /* IFLA_AMT_REMOTE_IP */
-              nla_total_size(sizeof(struct iphdr)); /* IFLA_AMT_LOCAL_IP */
+              nla_total_size(sizeof(__be32)) + /* IFLA_AMT_DISCOVERY_IP */
+              nla_total_size(sizeof(__be32)) + /* IFLA_AMT_REMOTE_IP */
+              nla_total_size(sizeof(__be32)); /* IFLA_AMT_LOCAL_IP */
 }
 
 static int amt_fill_info(struct sk_buff *skb, const struct net_device *dev)