All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: net/bridge/br_netlink.c:99:13: warning: use of uninitialized value '<unknown>' [CWE-457]
Date: Tue, 16 Aug 2022 19:42:22 +0800	[thread overview]
Message-ID: <202208161913.WPgrC2rU-lkp@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 19582 bytes --]

:::::: 
:::::: Manual check reason: "low confidence bisect report"
:::::: Manual check reason: "low confidence static check first_new_problem: net/bridge/br_netlink.c:99:13: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]"
:::::: 

BCC: lkp(a)intel.com
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: Alexander Lobakin <alexandr.lobakin@intel.com>
CC: Yury Norov <yury.norov@gmail.com>
CC: Marco Elver <elver@google.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   568035b01cfb107af8d2e4bd2fb9aea22cf5b868
commit: b03fc1173c0c2bb8fad61902a862985cecdc4b1b bitops: let optimize out non-atomic bitops on compile-time constants
date:   7 weeks ago
:::::: branch date: 2 days ago
:::::: commit date: 7 weeks ago
config: arm-randconfig-c002-20220722 (https://download.01.org/0day-ci/archive/20220816/202208161913.WPgrC2rU-lkp(a)intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b03fc1173c0c2bb8fad61902a862985cecdc4b1b
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout b03fc1173c0c2bb8fad61902a862985cecdc4b1b
        # save the config file
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross ARCH=arm KBUILD_USERCFLAGS='-fanalyzer -Wno-error' 

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

gcc-analyzer warnings: (new ones prefixed by >>)
                            |   91 | #define NL_SET_ERR_MSG(extack, msg) do {                \
                            |      |                                        ^
                            |      |                                        |
                            |      |                                        (57) ...to here
   include/linux/netlink.h:102:9: note: in expansion of macro 'NL_SET_ERR_MSG'
                            |  102 |         NL_SET_ERR_MSG((extack), KBUILD_MODNAME ": " msg)
                            |      |         ^~~~~~~~~~~~~~
   net/bridge/br_private.h:662:17: note: in expansion of macro 'NL_SET_ERR_MSG_MOD'
                            |  662 |                 NL_SET_ERR_MSG_MOD(extack, "Pvid isn't allowed in a range");
                            |      |                 ^~~~~~~~~~~~~~~~~~
                            |
                     <------+
                     |
                   'br_process_vlan_info': events 58-62
                     |
                     |net/bridge/br_netlink.c:738:22:
                     |  738 |                 if (!br_vlan_valid_range(vinfo_curr, *vinfo_last, extack))
                     |      |                    ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                     |      |                    | |
                     |      |                    | (58) returning to 'br_process_vlan_info' from 'br_vlan_valid_range'
                     |      |                    (59) following 'true' branch...
                     |......
                     |  741 |                 memcpy(&tmp_vinfo, *vinfo_last,
                     |      |                 ~~~~~~
                     |      |                 |
                     |      |                 (60) ...to here
                     |  742 |                        sizeof(struct bridge_vlan_info));
                     |  743 |                 for (v = (*vinfo_last)->vid; v <= vinfo_curr->vid; v++) {
                     |      |                                              ~~~~~~~~~~~~~~~~~~~~
                     |      |                                                |
                     |      |                                                (61) following 'false' branch...
                     |......
                     |  766 |                 if (v_change_start)
                     |      |                 ~~    
                     |      |                 |
                     |      |                 (62) ...to here
                     |
                   'br_process_vlan_info': event 63
                     |
                     |cc1:
                     | (63): use of uninitialized value '^[[01m^[[K<unknown>^[[m^[[K' here
                     |
   In file included from include/net/rtnetlink.h:6,
                    from net/bridge/br_netlink.c:12:
   include/net/netlink.h: In function 'nla_get_u64':
   include/net/netlink.h:1617:13: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
    1617 |         u64 tmp;
         |             ^~~
     'br_changelink': events 1-8
       |
       |net/bridge/br_netlink.c:1212:12:
       | 1212 | static int br_changelink(struct net_device *brdev, struct nlattr *tb[],
       |      |            ^~~~~~~~~~~~~
       |      |            |
       |      |            (1) entry to 'br_changelink'
       |......
       | 1219 |         if (!data)
       |      |            ~
       |      |            |
       |      |            (2) following 'false' branch (when 'data' is non-NULL)...
       |......
       | 1222 |         if (data[IFLA_BR_FORWARD_DELAY]) {
       |      |         ~~  
       |      |         |
       |      |         (3) ...to here
       |......
       | 1260 |         if (data[IFLA_BR_VLAN_FILTERING]) {
       |      |            ~
       |      |            |
       |      |            (4) following 'false' branch...
       |......
       | 1302 |         if (data[IFLA_BR_GROUP_FWD_MASK]) {
       |      |         ~~  
       |      |         |
       |      |         (5) ...to here
       |......
       | 1390 |         if (data[IFLA_BR_MCAST_LAST_MEMBER_INTVL]) {
       |      |            ~
       |      |            |
       |      |            (6) following 'true' branch...
       | 1391 |                 u64 val = nla_get_u64(data[IFLA_BR_MCAST_LAST_MEMBER_INTVL]);
       |      |                 ~~~       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                 |         |
       |      |                 |         (8) calling 'nla_get_u64' from 'br_changelink'
       |      |                 (7) ...to here
       |
       +--> 'nla_get_u64': events 9-10
              |
              |include/net/netlink.h:1615:19:
              | 1615 | static inline u64 nla_get_u64(const struct nlattr *nla)
              |      |                   ^~~~~~~~~~~
              |      |                   |
              |      |                   (9) entry to 'nla_get_u64'
              | 1616 | {
              | 1617 |         u64 tmp;
              |      |             ~~~    
              |      |             |
              |      |             (10) use of uninitialized value '<unknown>' here
              |
   net/bridge/br_netlink.c: In function 'br_get_link_af_size_filtered':
>> net/bridge/br_netlink.c:99:13: warning: use of uninitialized value '<unknown>' [CWE-457] [-Wanalyzer-use-of-uninitialized-value]
      99 |         u32 num_cfm_peer_mep_infos;
         |             ^~~~~~~~~~~~~~~~~~~~~~
     'br_setlink': event 1
       |
       | 1026 | int br_setlink(struct net_device *dev, struct nlmsghdr *nlh, u16 flags,
       |      |     ^~~~~~~~~~
       |      |     |
       |      |     (1) entry to 'br_setlink'
       |
     'br_setlink': event 2
       |
       |net/bridge/br_private.h:432:56:
       |  432 |                 rtnl_dereference(dev->rx_handler_data) : NULL;
       |
     'br_setlink': event 3
       |
       |include/linux/rcupdate.h:348:32:
       |  348 | #define RCU_LOCKDEP_WARN(c, s) do { } while (0 && (c))
       |      |                                ^~
       |      |                                |
       |      |                                (3) ...to here
   include/linux/rcupdate.h:399:9: note: in expansion of macro 'RCU_LOCKDEP_WARN'
       |  399 |         RCU_LOCKDEP_WARN(!(c), "suspicious rcu_dereference_protected() usage"); \
       |      |         ^~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:595:9: note: in expansion of macro '__rcu_dereference_protected'
       |  595 |         __rcu_dereference_protected((p), __UNIQUE_ID(rcu), (c), __rcu)
       |      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rtnetlink.h:81:9: note: in expansion of macro 'rcu_dereference_protected'
       |   81 |         rcu_dereference_protected(p, lockdep_rtnl_is_held())
       |      |         ^~~~~~~~~~~~~~~~~~~~~~~~~
   net/bridge/br_private.h:432:17: note: in expansion of macro 'rtnl_dereference'
       |  432 |                 rtnl_dereference(dev->rx_handler_data) : NULL;
       |      |                 ^~~~~~~~~~~~~~~~
       |
     'br_setlink': events 4-6
       |
       |net/bridge/br_netlink.c:1046:12:
       | 1046 |         if (!p && !afspec)
       |      |            ^
       |      |            |
       |      |            (4) following 'false' branch...
       |......
       | 1049 |         if (p && protinfo) {
       |      |             ~~~~~~~~~~~~~
       |      |               |
       |      |               (5) ...to here
       |......
       | 1063 |                         if (nla_len(protinfo) < sizeof(u8))
       |      |                            ~
       |      |                            |
       |      |                            (6) following 'false' branch...
       |
     'br_setlink': event 7
       |
       |include/linux/instruction_pointer.h:6:41:
       |    6 | #define _THIS_IP_  ({ __label__ __here; __here: (unsigned long)&&__here; })
       |      |                                         ^~~~~~
       |      |                                         |
       |      |                                         (7) ...to here
   include/linux/spinlock_api_up.h:34:30: note: in expansion of macro '_THIS_IP_'
       |   34 |   do { __local_bh_disable_ip(_THIS_IP_, SOFTIRQ_LOCK_OFFSET); ___LOCK(lock); } while (0)
       |      |                              ^~~~~~~~~
   include/linux/spinlock_api_up.h:63:49: note: in expansion of macro '__LOCK_BH'
       |   63 | #define _raw_spin_lock_bh(lock)                 __LOCK_BH(lock)
       |      |                                                 ^~~~~~~~~
   include/linux/spinlock.h:273:41: note: in expansion of macro '_raw_spin_lock_bh'
       |  273 | #define raw_spin_lock_bh(lock)          _raw_spin_lock_bh(lock)
       |      |                                         ^~~~~~~~~~~~~~~~~
   include/linux/spinlock.h:354:9: note: in expansion of macro 'raw_spin_lock_bh'
       |  354 |         raw_spin_lock_bh(&lock->rlock);
       |      |         ^~~~~~~~~~~~~~~~
       |
     'br_setlink': events 8-14
       |
       |net/bridge/br_netlink.c:1070:20:
       |  649 |         return br_info_notify(event, br, port, filter);
       |      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       |      |                |
       |      |                (14) calling 'br_info_notify' from 'br_setlink'
       |......
       | 1070 |                 if (err)
       |      |                    ^
       |      |                    |
       |      |                    (8) following 'false' branch (when 'err == 0')...
       | 1071 |                         goto out;
       | 1072 |                 changed = true;
       |      |                 ~~~~~~~
       |      |                 |
       |      |                 (9) ...to here
       |......
       | 1075 |         if (afspec)
       |      |            ~        
       |      |            |
       |      |            (10) following 'false' branch (when 'afspec' is NULL)...
       |......
       | 1078 |         if (changed)
       |      |         ~~ ~        
       |      |         |  |
       |      |         |  (12) following 'true' branch...
       |      |         (11) ...to here

vim +99 net/bridge/br_netlink.c

2594e9064a5763 Nikolay Aleksandrov 2015-09-25   92  
fed0a159c8c5e4 Roopa Prabhu        2015-02-25   93  static size_t br_get_link_af_size_filtered(const struct net_device *dev,
fed0a159c8c5e4 Roopa Prabhu        2015-02-25   94  					   u32 filter_mask)
b7853d73e39b09 Roopa Prabhu        2015-02-21   95  {
2594e9064a5763 Nikolay Aleksandrov 2015-09-25   96  	struct net_bridge_vlan_group *vg = NULL;
efa5356b0d9753 Roopa Prabhu        2017-01-31   97  	struct net_bridge_port *p = NULL;
b6d0425b816eed Henrik Bjoernlund   2020-10-27   98  	struct net_bridge *br = NULL;
b6d0425b816eed Henrik Bjoernlund   2020-10-27  @99  	u32 num_cfm_peer_mep_infos;
b6d0425b816eed Henrik Bjoernlund   2020-10-27  100  	u32 num_cfm_mep_infos;
efa5356b0d9753 Roopa Prabhu        2017-01-31  101  	size_t vinfo_sz = 0;
b6d0425b816eed Henrik Bjoernlund   2020-10-27  102  	int num_vlan_infos;
b7853d73e39b09 Roopa Prabhu        2015-02-21  103  
2f56f6be47dbc6 Johannes Berg       2015-03-03  104  	rcu_read_lock();
35f861e3c58e12 Julian Wiedmann     2019-03-29  105  	if (netif_is_bridge_port(dev)) {
59259ff7a81b9e Zhang Zhengming     2021-04-28  106  		p = br_port_get_check_rcu(dev);
59259ff7a81b9e Zhang Zhengming     2021-04-28  107  		if (p)
907b1e6e83ed25 Nikolay Aleksandrov 2015-10-12  108  			vg = nbp_vlan_group_rcu(p);
254ec036db1123 Kyungrok Chung      2021-10-16  109  	} else if (netif_is_bridge_master(dev)) {
2594e9064a5763 Nikolay Aleksandrov 2015-09-25  110  		br = netdev_priv(dev);
907b1e6e83ed25 Nikolay Aleksandrov 2015-10-12  111  		vg = br_vlan_group_rcu(br);
2594e9064a5763 Nikolay Aleksandrov 2015-09-25  112  	}
77751ee8aec3e1 Nikolay Aleksandrov 2015-09-30  113  	num_vlan_infos = br_get_num_vlan_infos(vg, filter_mask);
2f56f6be47dbc6 Johannes Berg       2015-03-03  114  	rcu_read_unlock();
2f56f6be47dbc6 Johannes Berg       2015-03-03  115  
efa5356b0d9753 Roopa Prabhu        2017-01-31  116  	if (p && (p->flags & BR_VLAN_TUNNEL))
efa5356b0d9753 Roopa Prabhu        2017-01-31  117  		vinfo_sz += br_get_vlan_tunnel_info_size(vg);
efa5356b0d9753 Roopa Prabhu        2017-01-31  118  
b7853d73e39b09 Roopa Prabhu        2015-02-21  119  	/* Each VLAN is returned in bridge_vlan_info along with flags */
efa5356b0d9753 Roopa Prabhu        2017-01-31  120  	vinfo_sz += num_vlan_infos * nla_total_size(sizeof(struct bridge_vlan_info));
efa5356b0d9753 Roopa Prabhu        2017-01-31  121  
a911ad18a56aee Tobias Waldekranz   2022-03-22  122  	if (p && vg && (filter_mask & RTEXT_FILTER_MST))
122c29486e1ff7 Tobias Waldekranz   2022-03-16  123  		vinfo_sz += br_mst_info_size(vg);
122c29486e1ff7 Tobias Waldekranz   2022-03-16  124  
b6d0425b816eed Henrik Bjoernlund   2020-10-27  125  	if (!(filter_mask & RTEXT_FILTER_CFM_STATUS))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  126  		return vinfo_sz;
b6d0425b816eed Henrik Bjoernlund   2020-10-27  127  
b6d0425b816eed Henrik Bjoernlund   2020-10-27  128  	if (!br)
b6d0425b816eed Henrik Bjoernlund   2020-10-27  129  		return vinfo_sz;
b6d0425b816eed Henrik Bjoernlund   2020-10-27  130  
b6d0425b816eed Henrik Bjoernlund   2020-10-27  131  	/* CFM status info must be added */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  132  	br_cfm_mep_count(br, &num_cfm_mep_infos);
b6d0425b816eed Henrik Bjoernlund   2020-10-27  133  	br_cfm_peer_mep_count(br, &num_cfm_peer_mep_infos);
b6d0425b816eed Henrik Bjoernlund   2020-10-27  134  
b6d0425b816eed Henrik Bjoernlund   2020-10-27  135  	vinfo_sz += nla_total_size(0);	/* IFLA_BRIDGE_CFM */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  136  	/* For each status struct the MEP instance (u32) is added */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  137  	/* MEP instance (u32) + br_cfm_mep_status */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  138  	vinfo_sz += num_cfm_mep_infos *
b6d0425b816eed Henrik Bjoernlund   2020-10-27  139  		     /*IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  140  		    (nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  141  		     /* IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  142  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  143  		     /* IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  144  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  145  		     /* IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  146  		     + nla_total_size(sizeof(u32)));
b6d0425b816eed Henrik Bjoernlund   2020-10-27  147  	/* MEP instance (u32) + br_cfm_cc_peer_status */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  148  	vinfo_sz += num_cfm_peer_mep_infos *
b6d0425b816eed Henrik Bjoernlund   2020-10-27  149  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  150  		    (nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  151  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  152  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  153  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  154  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  155  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  156  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  157  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  158  		     + nla_total_size(sizeof(u8))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  159  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  160  		     + nla_total_size(sizeof(u8))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  161  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  162  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  163  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  164  		     + nla_total_size(sizeof(u32))
b6d0425b816eed Henrik Bjoernlund   2020-10-27  165  		     /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN */
b6d0425b816eed Henrik Bjoernlund   2020-10-27  166  		     + nla_total_size(sizeof(u32)));
b6d0425b816eed Henrik Bjoernlund   2020-10-27  167  
efa5356b0d9753 Roopa Prabhu        2017-01-31  168  	return vinfo_sz;
b7853d73e39b09 Roopa Prabhu        2015-02-21  169  }
b7853d73e39b09 Roopa Prabhu        2015-02-21  170  

:::::: The code at line 99 was first introduced by commit
:::::: b6d0425b816eed4dbd6fc590b27dbc7a113c0248 bridge: cfm: Netlink Notifications.

:::::: TO: Henrik Bjoernlund <henrik.bjoernlund@microchip.com>
:::::: CC: Jakub Kicinski <kuba@kernel.org>

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

             reply	other threads:[~2022-08-16 11:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-16 11:42 kernel test robot [this message]
  -- strict thread matches above, loose matches on Subject: below --
2022-08-18  9:42 net/bridge/br_netlink.c:99:13: warning: use of uninitialized value '<unknown>' [CWE-457] kernel test robot
2022-08-14 19:05 kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202208161913.WPgrC2rU-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.