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]
Message-ID: <cbc4026aa94ff68e984743ef1666a6dd810c596d.camel@sipsolutions.net>
Date:   Fri, 18 Feb 2022 17:51:04 +0100
From:   Johannes Berg <johannes@...solutions.net>
To:     trix@...hat.com, davem@...emloft.net, kuba@...nel.org,
        nathan@...nel.org, ndesaulniers@...gle.com, cjhuang@...eaurora.org,
        briannorris@...omium.org, kuabhs@...omium.org
Cc:     linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org, llvm@...ts.linux.dev
Subject: Re: [PATCH] nl80211: check return of nla_parse_nested

On Fri, 2022-02-18 at 08:30 -0800, trix@...hat.com wrote:
> From: Tom Rix <trix@...hat.com>
> 
> Clang static analysis reports this representative problem
> nl80211.c:15426:6: warning: Branch condition evaluates
>   to a garbage value
>   if (!tb[NL80211_SAR_ATTR_TYPE] ||
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> tb is set when nla_parse_nested() is successful.
> So check.

Well, it's a bit annoying that we cannot express/check this, but we
already validated that it's going to succeed, through the nested policy:

static const struct nla_policy nl80211_policy[NUM_NL80211_ATTR] = {
[...]
        [NL80211_ATTR_SAR_SPEC] = NLA_POLICY_NESTED(sar_policy),


Thus, it cannot actually fail. I suppose in this case checking for
errors doesn't make the code that much worse, but there's isn't really
much point. Maybe a comment would be useful?

johannes

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ