lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250218184513.05ac19d0@kernel.org>
Date: Tue, 18 Feb 2025 18:45:13 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Gal Pressman <gal@...dia.com>
Cc: <netdev@...r.kernel.org>, "David S. Miller" <davem@...emloft.net>, "Eric
 Dumazet" <edumazet@...gle.com>, Paolo Abeni <pabeni@...hat.com>, Andrew
 Lunn <andrew+netdev@...n.ch>, Tariq Toukan <tariqt@...dia.com>, Louis Peens
 <louis.peens@...igine.com>, Simon Horman <horms@...nel.org>, David Ahern
 <dsahern@...nel.org>, "Pravin B Shelar" <pshelar@....org>, Yotam Gigi
 <yotam.gi@...il.com>, Jamal Hadi Salim <jhs@...atatu.com>, Cong Wang
 <xiyou.wangcong@...il.com>, Jiri Pirko <jiri@...nulli.us>, Kees Cook
 <kees@...nel.org>, "Gustavo A. R. Silva" <gustavoars@...nel.org>,
 <dev@...nvswitch.org>, <linux-hardening@...r.kernel.org>, Ilya Maximets
 <i.maximets@....org>, Alexander Lobakin <aleksander.lobakin@...el.com>
Subject: Re: [PATCH net-next v3 1/2] ip_tunnel: Use ip_tunnel_info() helper
 instead of 'info + 1'

On Mon, 17 Feb 2025 22:25:02 +0200 Gal Pressman wrote:
> diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
> index af7c99845948..6d97be6bc7fa 100644
> --- a/net/sched/act_tunnel_key.c
> +++ b/net/sched/act_tunnel_key.c
> @@ -572,7 +572,7 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
>  				       const struct ip_tunnel_info *info)
>  {
>  	int len = info->options_len;
> -	u8 *src = (u8 *)(info + 1);
> +	u8 *src = (u8 *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;
>  
>  	start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
> @@ -603,7 +603,8 @@ 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);
> +	struct vxlan_metadata *md =
> +		(struct vxlan_metadata *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;
>  
>  	start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
> @@ -622,7 +623,8 @@ 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);
> +	struct erspan_metadata *md =
> +		(struct erspan_metadata *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;

We shouldn't cast the const away any more. 
Squash this in, please:

diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index 6d97be6bc7fa..ae5dea7c48a8 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -569,20 +569,20 @@ 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 *)ip_tunnel_info_opts(info);
        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) ||
                    nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE,
                               opt->type) ||
@@ -601,12 +601,11 @@ 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 *)ip_tunnel_info_opts(info);
+       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);
        if (!start)
                return -EMSGSIZE;
@@ -621,12 +620,11 @@ 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 *)ip_tunnel_info_opts(info);
+       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);
        if (!start)
                return -EMSGSIZE;

-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ