]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drop_monitor: fix size calculations for 64-bit attributes
authorEric Dumazet <edumazet@google.com>
Wed, 22 Jul 2026 14:17:42 +0000 (14:17 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Jul 2026 18:00:01 +0000 (11:00 -0700)
net_dm_packet_report_fill() and net_dm_hw_packet_report_fill() use
nla_put_u64_64bit() to append 64-bit attributes (NET_DM_ATTR_PC and
NET_DM_ATTR_TIMESTAMP).

On 32-bit architectures without CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS,
nla_put_u64_64bit() may append a 4-byte NET_DM_ATTR_PAD attribute for
64-bit alignment.

However, net_dm_packet_report_size() and net_dm_hw_packet_report_size()
used nla_total_size(sizeof(u64)) instead of nla_total_size_64bit(sizeof(u64)),
budgeting 12 bytes instead of up to 16 bytes.

This under-estimation of SKB size can lead to an skb_over_panic() when
__nla_reserve() or skb_put() is subsequently called.

Fix this by using nla_total_size_64bit(sizeof(u64)) in both size calculations.

Fixes: ca30707dee2b ("drop_monitor: Add packet alert mode")
Fixes: 5e58109b1ea4 ("drop_monitor: Add support for packet alert mode for hardware drops")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://patch.msgid.link/20260722141743.3266924-2-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/drop_monitor.c

index b4d1ff2829b6182b86d13a0432b978de8b72325c..9abcdee8c76eadde0824c35ab7eff9214824917d 100644 (file)
@@ -566,13 +566,13 @@ static size_t net_dm_packet_report_size(size_t payload_len)
               /* NET_DM_ATTR_ORIGIN */
               nla_total_size(sizeof(u16)) +
               /* NET_DM_ATTR_PC */
-              nla_total_size(sizeof(u64)) +
+              nla_total_size_64bit(sizeof(u64)) +
               /* NET_DM_ATTR_SYMBOL */
               nla_total_size(NET_DM_MAX_SYMBOL_LEN + 1) +
               /* NET_DM_ATTR_IN_PORT */
               net_dm_in_port_size() +
               /* NET_DM_ATTR_TIMESTAMP */
-              nla_total_size(sizeof(u64)) +
+              nla_total_size_64bit(sizeof(u64)) +
               /* NET_DM_ATTR_ORIG_LEN */
               nla_total_size(sizeof(u32)) +
               /* NET_DM_ATTR_PROTO */
@@ -766,7 +766,7 @@ net_dm_hw_packet_report_size(size_t payload_len,
               /* NET_DM_ATTR_FLOW_ACTION_COOKIE */
               net_dm_flow_action_cookie_size(hw_metadata) +
               /* NET_DM_ATTR_TIMESTAMP */
-              nla_total_size(sizeof(u64)) +
+              nla_total_size_64bit(sizeof(u64)) +
               /* NET_DM_ATTR_ORIG_LEN */
               nla_total_size(sizeof(u32)) +
               /* NET_DM_ATTR_PROTO */