Skip to content

Commit ba3fa6e

Browse files
gal-pressmankuba-moo
authored andcommitted
ip_tunnel: Use ip_tunnel_info() helper instead of 'info + 1'
Tunnel options should not be accessed directly, use the ip_tunnel_info() accessor instead. Signed-off-by: Gal Pressman <[email protected]> Reviewed-by: Kees Cook <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5d6ba5a commit ba3fa6e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/net/ip_tunnels.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ static inline void iptunnel_xmit_stats(struct net_device *dev, int pkt_len)
650650
static inline void ip_tunnel_info_opts_get(void *to,
651651
const struct ip_tunnel_info *info)
652652
{
653-
memcpy(to, info + 1, info->options_len);
653+
memcpy(to, ip_tunnel_info_opts(info), info->options_len);
654654
}
655655

656656
static inline void ip_tunnel_info_opts_set(struct ip_tunnel_info *info,

net/sched/act_tunnel_key.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,16 +571,16 @@ static void tunnel_key_release(struct tc_action *a)
571571
static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
572572
const struct ip_tunnel_info *info)
573573
{
574+
const u8 *src = ip_tunnel_info_opts(info);
574575
int len = info->options_len;
575-
u8 *src = (u8 *)(info + 1);
576576
struct nlattr *start;
577577

578578
start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
579579
if (!start)
580580
return -EMSGSIZE;
581581

582582
while (len > 0) {
583-
struct geneve_opt *opt = (struct geneve_opt *)src;
583+
const struct geneve_opt *opt = (const struct geneve_opt *)src;
584584

585585
if (nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,
586586
opt->opt_class) ||
@@ -603,7 +603,7 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
603603
static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
604604
const struct ip_tunnel_info *info)
605605
{
606-
struct vxlan_metadata *md = (struct vxlan_metadata *)(info + 1);
606+
const struct vxlan_metadata *md = ip_tunnel_info_opts(info);
607607
struct nlattr *start;
608608

609609
start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
@@ -622,7 +622,7 @@ static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
622622
static int tunnel_key_erspan_opts_dump(struct sk_buff *skb,
623623
const struct ip_tunnel_info *info)
624624
{
625-
struct erspan_metadata *md = (struct erspan_metadata *)(info + 1);
625+
const struct erspan_metadata *md = ip_tunnel_info_opts(info);
626626
struct nlattr *start;
627627

628628
start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN);

0 commit comments

Comments
 (0)