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-next>] [day] [month] [year] [list]
Message-ID: <4bb65f2f-48f9-7d9c-ab2e-15596f15a4d8@canonical.com>
Date:   Fri, 5 Feb 2021 17:38:47 +0000
From:   Colin Ian King <colin.king@...onical.com>
To:     Johannes Berg <johannes.berg@...el.com>
Cc:     "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
        "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Potential invalid ~ operator in net/mac80211/cfg.c

Hi there,

while working through a backlog of older static analysis reports from
Coverity I found an interesting use of the ~ operator that looks
incorrect to me in function ieee80211_set_bitrate_mask():

                for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) {
                        if (~sdata->rc_rateidx_mcs_mask[i][j]) {
                                sdata->rc_has_mcs_mask[i] = true;
                                break;
                        }
                }

                for (j = 0; j < NL80211_VHT_NSS_MAX; j++) {
                        if (~sdata->rc_rateidx_vht_mcs_mask[i][j]) {
                                sdata->rc_has_vht_mcs_mask[i] = true;
                                break;
                        }
                }

For the ~ operator in both if stanzas, Coverity reports:

Logical vs. bitwise operator (CONSTANT_EXPRESSION_RESULT)
logical_vs_bitwise:

~sdata->rc_rateidx_mcs_mask[i][j] is always 1/true regardless of the
values of its operand. This occurs as the logical operand of if.
    Did you intend to use ! rather than ~?

I've checked the results of this and it does seem that ~ is incorrect
and always returns true for the if expression. So it probably should be
!, but I'm not sure if I'm missing something deeper here and wondering
why this has always worked.

Colin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ