net: psample: Fix netlink skb length with tunnel info
Subsystems (3)
PATCH 1/1 net: psample: Fix netlink skb length with tunnel info
Currently, the psample netlink skb is allocated with a size that does not account for the nested 'PSAMPLE_ATTR_TUNNEL' attribute and the padding required for the 64-bit attribute 'PSAMPLE_TUNNEL_KEY_ATTR_ID'. This can result in failure to add attributes to the netlink skb due to insufficient tail room. The following error message is printed to the kernel log: "Could not create psample log message".
Fix this by adjusting the allocation size to take into account the nested attribute and the padding.
--- net/psample/psample.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/psample/psample.c +2 -2
@@ -309,10 +309,10 @@ static int psample_tunnel_meta_len(struct ip_tunnel_info *tun_info)unsigned short tun_proto =ip_tunnel_info_af (tun_info);const struct ip_tunnel_key *tun_key = &tun_info->key;int tun_opts_len = tun_info->options_len; -int sum =0 ; +int sum =nla_total_size (0 );/* PSAMPLE_ATTR_TUNNEL */ if (tun_key->tun_flags &TUNNEL_KEY ) - sum +=nla_total_size (sizeof (u64)); + sum +=nla_total_size_64bit (sizeof (u64));if (tun_info->mode &IP_TUNNEL_INFO_BRIDGE ) sum +=nla_total_size (0 );
Signature · 1 line
2.26.2
This patch was applied to netdev/net.git (refs/heads/master):
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
Quoted 8 lines · On Thu, 25 Feb 2021 15:51:45 +0800 you wrote:
Currently, the psample netlink skb is allocated with a size that does not account for the nested '
PSAMPLE_ATTR_TUNNEL' attribute and the padding required for the 64-bit attribute 'PSAMPLE_TUNNEL_KEY_ATTR_ID'. This can result in failure to add attributes to the netlink skb due to insufficient tail room. The following error message is printed to the kernel log: "Could not create psample log message".[...]
Here is the summary with links:
- [net] net: psample: Fix netlink skb length with tunnel info
https://git.kernel.org/netdev/net/c/a93dcaada2dd
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html