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] [day] [month] [year] [list]
Date:   Fri, 7 Apr 2023 11:00:55 +0200
From:   Eric Dumazet <edumazet@...gle.com>
To:     Haoyi Liu <iccccc@...t.edu.cn>
Cc:     "David S. Miller" <davem@...emloft.net>,
        David Ahern <dsahern@...nel.org>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        hust-os-kernel-patches@...glegroups.com, yalongz@...t.edu.cn,
        error27@...il.com, Dongliang Mu <dzm91@...t.edu.cn>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next] net/ipv6: silence 'passing zero to ERR_PTR()' warning

On Fri, Apr 7, 2023 at 5:54 AM Haoyi Liu <iccccc@...t.edu.cn> wrote:
>
> Smatch complains that if xfrm_lookup() returns NULL then this does a
> weird thing with "err":
>
>     net/ ipv6/ icmp.c:411 icmpv6_route_lookup()
>     warn: passing zero to ERR_PTR()
>
> Just return "dst2" directly instead of assigning it to"dst" and then
> looking up the value of "err".  No functional change.
>
> Signed-off-by: Haoyi Liu <iccccc@...t.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
> ---
> The issue is found by static analysis, and the patch is remains untested.
> ---
>  net/ipv6/icmp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
> index 1f53f2a74480..a5e77acead89 100644
> --- a/net/ipv6/icmp.c
> +++ b/net/ipv6/icmp.c
> @@ -395,7 +395,7 @@ static struct dst_entry *icmpv6_route_lookup(struct net *net,
>         dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk, XFRM_LOOKUP_ICMP);
>         if (!IS_ERR(dst2)) {
>                 dst_release(dst);
> -               dst = dst2;
> +               return dst2;
>         } else {
>                 err = PTR_ERR(dst2);
>                 if (err == -EPERM) {
> --
> 2.25.1
>

Please cleanup this thing, this is a maze of returns, gotos, and
unnecessary 'else's

Thanks.

diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index 1f53f2a74480c0b8433204b567e7f98ad1216ad6..c76861f1ff6e4ee12d2686c1d135b24595989dfa
100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -395,14 +395,12 @@ static struct dst_entry
*icmpv6_route_lookup(struct net *net,
        dst2 = xfrm_lookup(net, dst2, flowi6_to_flowi(&fl2), sk,
XFRM_LOOKUP_ICMP);
        if (!IS_ERR(dst2)) {
                dst_release(dst);
-               dst = dst2;
-       } else {
-               err = PTR_ERR(dst2);
-               if (err == -EPERM) {
-                       dst_release(dst);
-                       return dst2;
-               } else
-                       goto relookup_failed;
+               return dst2;
+       }
+       err = PTR_ERR(dst2);
+       if (err == -EPERM) {
+               dst_release(dst);
+               return dst2;
        }

 relookup_failed:

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ