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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 17 Nov 2023 18:15:08 +0100
From: Eric Dumazet <edumazet@...gle.com>
To: Kunwu Chan <chentao@...inos.cn>
Cc: davem@...emloft.net, dsahern@...nel.org, kuba@...nel.org, 
	pabeni@...hat.com, kunwu.chan@...mail.com, netdev@...r.kernel.org, 
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ipv4: Correct/silence an endian warning in __ip_do_redirect

On Fri, Nov 17, 2023 at 6:07 PM Kunwu Chan <chentao@...inos.cn> wrote:
>
> net/ipv4/route.c:783:46: warning: incorrect type in argument 2 (different base types)
> net/ipv4/route.c:783:46:    expected unsigned int [usertype] key
> net/ipv4/route.c:783:46:    got restricted __be32 [usertype] new_gw
>
> Signed-off-by: Kunwu Chan <chentao@...inos.cn>

We need Fixes: tag for networking patches.

> ---
>  net/ipv4/route.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index 3290a4442b4a..e8a542c6b031 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -780,7 +780,7 @@ static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flow
>                         goto reject_redirect;
>         }
>
> -       n = __ipv4_neigh_lookup(rt->dst.dev, new_gw);
> +       n = __ipv4_neigh_lookup(rt->dst.dev, be32_to_cpu(new_gw));
>         if (!n)
>                 n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev);
>         if (!IS_ERR(n)) {
> --
> 2.34.1
>

How was this patch tested ?

You are 'fixing' sparse warnings by replacing them with real bugs.

be32_to_cpu() is going to swap bytes on x86, so the lookup will fail horribly.

Here, if you must silence sparse, you want (__force u32)new_gw

Look at this commit for a template.

commit 3c42b2019863b327caa233072c50739d4144dd16

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ