summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Mi <cmi@nvidia.com>2021-02-25 15:51:45 +0800
committerJakub Kicinski <kuba@kernel.org>2021-02-25 09:49:46 -0800
commita93dcaada2ddb58dbc72652b42548adedd646d7a (patch)
treea628c1240c2b8e31b95d1fe1758e0be02f40bb91
parent4d9274cee40b6a20dd6148c6c81c6733c2678cbc (diff)
downloadlinux-stable-a93dcaada2ddb58dbc72652b42548adedd646d7a.tar.gz
linux-stable-a93dcaada2ddb58dbc72652b42548adedd646d7a.tar.bz2
linux-stable-a93dcaada2ddb58dbc72652b42548adedd646d7a.zip
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. Fixes: d8bed686ab96 ("net: psample: Add tunnel support") CC: Yotam Gigi <yotam.gi@gmail.com> Reviewed-by: Ido Schimmel <idosch@nvidia.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com> Signed-off-by: Chris Mi <cmi@nvidia.com> Link: https://lore.kernel.org/r/20210225075145.184314-1-cmi@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
-rw-r--r--net/psample/psample.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/net/psample/psample.c b/net/psample/psample.c
index 33e238c965bd..482c07f2766b 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -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);