Skip to content

Commit

Permalink
ip_tunnel: Use ip_tunnel_info() helper instead of 'info + 1'
Browse files Browse the repository at this point in the history
Tunnel options should not be accessed directly, use the ip_tunnel_info()
accessor instead.

Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Kees Cook <kees@kernel.org>
Link: https://patch.msgid.link/20250219143256.370277-2-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Gal Pressman authored and Jakub Kicinski committed Feb 20, 2025
1 parent 5d6ba5a commit ba3fa6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/net/ip_tunnels.h
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len)
static inline void ip_tunnel_info_opts_get(void *to,
const struct ip_tunnel_info *info)
{
memcpy(to, info + 1, info->options_len);
memcpy(to, ip_tunnel_info_opts(info), info->options_len);
}

static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,
Expand Down
8 changes: 4 additions & 4 deletions net/sched/act_tunnel_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,16 +571,16 @@ static void tunnel_key_release(struct tc_action *a)
static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
const struct ip_tunnel_info *info)
{
const u8 *src = ip_tunnel_info_opts(info);
int len = info->options_len;
u8 *src = (u8 *)(info + 1);
struct nlattr *start;

start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
if (!start)
return -EMSGSIZE;

while (len > 0) {
struct geneve_opt *opt = (struct geneve_opt *)src;
const struct geneve_opt *opt = (const struct geneve_opt *)src;

if (nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,
opt->opt_class) ||
Expand All @@ -603,7 +603,7 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
const struct ip_tunnel_info *info)
{
struct vxlan_metadata *md = (struct vxlan_metadata *)(info + 1);
const struct vxlan_metadata *md = ip_tunnel_info_opts(info);
struct nlattr *start;

start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
Expand All @@ -622,7 +622,7 @@ static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
static int tunnel_key_erspan_opts_dump(struct sk_buff *skb,
const struct ip_tunnel_info *info)
{
struct erspan_metadata *md = (struct erspan_metadata *)(info + 1);
const struct erspan_metadata *md = ip_tunnel_info_opts(info);
struct nlattr *start;

start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN);
Expand Down

0 comments on commit ba3fa6e

Please sign in to comment.