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>] [day] [month] [year] [list]
Message-ID: <202207251346.5l0YTQRD-lkp@intel.com>
Date:   Mon, 25 Jul 2022 13:55:46 +0800
From:   kernel test robot <lkp@...el.com>
To:     Lorenzo Bianconi <lorenzo@...nel.org>
Cc:     llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org, Felix Fietkau <nbd@....name>
Subject: drivers/net/wireless/mediatek/mt76/mt7915/mac.c:2347:22: warning:
 taking address of packed member 'req_type' of class or structure
 'ieee80211_twt_params' may result in an unaligned pointer value

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   e0dccc3b76fb35bb257b4118367a883073d7390e
commit: 3782b69d03e714b8ff98b84c7426d8cef0e64d7c mt76: mt7915: introduce mt7915_mac_add_twt_setup routine
date:   9 months ago
config: arm-buildonly-randconfig-r003-20220724 (https://download.01.org/0day-ci/archive/20220725/202207251346.5l0YTQRD-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 9e88cbcc403bdf82f29259ad60ff60a8fc4434a1)
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
        # install arm cross compiling tool for clang build
        # apt-get install binutils-arm-linux-gnueabi
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3782b69d03e714b8ff98b84c7426d8cef0e64d7c
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 3782b69d03e714b8ff98b84c7426d8cef0e64d7c
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/net/wireless/mediatek/mt76/ drivers/usb/gadget/

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

All warnings (new ones prefixed by >>):

>> drivers/net/wireless/mediatek/mt76/mt7915/mac.c:2347:22: warning: taking address of packed member 'req_type' of class or structure 'ieee80211_twt_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
           le16p_replace_bits(&twt_agrt->req_type, flowid,
                               ^~~~~~~~~~~~~~~~~~
   drivers/net/wireless/mediatek/mt76/mt7915/mac.c:2395:22: warning: taking address of packed member 'req_type' of class or structure 'ieee80211_twt_params' may result in an unaligned pointer value [-Waddress-of-packed-member]
           le16p_replace_bits(&twt_agrt->req_type, setup_cmd,
                               ^~~~~~~~~~~~~~~~~~
   2 warnings generated.


vim +2347 drivers/net/wireless/mediatek/mt76/mt7915/mac.c

  2320	
  2321	void mt7915_mac_add_twt_setup(struct ieee80211_hw *hw,
  2322				      struct ieee80211_sta *sta,
  2323				      struct ieee80211_twt_setup *twt)
  2324	{
  2325		enum ieee80211_twt_setup_cmd setup_cmd = TWT_SETUP_CMD_REJECT;
  2326		struct mt7915_sta *msta = (struct mt7915_sta *)sta->drv_priv;
  2327		struct ieee80211_twt_params *twt_agrt = (void *)twt->params;
  2328		u16 req_type = le16_to_cpu(twt_agrt->req_type);
  2329		enum ieee80211_twt_setup_cmd sta_setup_cmd;
  2330		struct mt7915_dev *dev = mt7915_hw_dev(hw);
  2331		struct mt7915_twt_flow *flow;
  2332		int flowid, table_id;
  2333		u8 exp;
  2334	
  2335		if (mt7915_mac_check_twt_req(twt))
  2336			goto out;
  2337	
  2338		mutex_lock(&dev->mt76.mutex);
  2339	
  2340		if (dev->twt.n_agrt == MT7915_MAX_TWT_AGRT)
  2341			goto unlock;
  2342	
  2343		if (hweight8(msta->twt.flowid_mask) == ARRAY_SIZE(msta->twt.flow))
  2344			goto unlock;
  2345	
  2346		flowid = ffs(~msta->twt.flowid_mask) - 1;
> 2347		le16p_replace_bits(&twt_agrt->req_type, flowid,
  2348				   IEEE80211_TWT_REQTYPE_FLOWID);
  2349	
  2350		table_id = ffs(~dev->twt.table_mask) - 1;
  2351		exp = FIELD_GET(IEEE80211_TWT_REQTYPE_WAKE_INT_EXP, req_type);
  2352		sta_setup_cmd = FIELD_GET(IEEE80211_TWT_REQTYPE_SETUP_CMD, req_type);
  2353	
  2354		flow = &msta->twt.flow[flowid];
  2355		memset(flow, 0, sizeof(*flow));
  2356		INIT_LIST_HEAD(&flow->list);
  2357		flow->wcid = msta->wcid.idx;
  2358		flow->table_id = table_id;
  2359		flow->id = flowid;
  2360		flow->duration = twt_agrt->min_twt_dur;
  2361		flow->mantissa = twt_agrt->mantissa;
  2362		flow->exp = exp;
  2363		flow->protection = !!(req_type & IEEE80211_TWT_REQTYPE_PROTECTION);
  2364		flow->flowtype = !!(req_type & IEEE80211_TWT_REQTYPE_FLOWTYPE);
  2365		flow->trigger = !!(req_type & IEEE80211_TWT_REQTYPE_TRIGGER);
  2366	
  2367		if (sta_setup_cmd == TWT_SETUP_CMD_REQUEST ||
  2368		    sta_setup_cmd == TWT_SETUP_CMD_SUGGEST) {
  2369			u64 interval = (u64)le16_to_cpu(twt_agrt->mantissa) << exp;
  2370			u64 flow_tsf, curr_tsf;
  2371			u32 rem;
  2372	
  2373			flow->sched = true;
  2374			flow->start_tsf = mt7915_mac_twt_sched_list_add(dev, flow);
  2375			curr_tsf = __mt7915_get_tsf(hw, msta->vif);
  2376			div_u64_rem(curr_tsf - flow->start_tsf, interval, &rem);
  2377			flow_tsf = curr_tsf + interval - rem;
  2378			twt_agrt->twt = cpu_to_le64(flow_tsf);
  2379		} else {
  2380			list_add_tail(&flow->list, &dev->twt_list);
  2381		}
  2382		flow->tsf = le64_to_cpu(twt_agrt->twt);
  2383	
  2384		if (mt7915_mcu_twt_agrt_update(dev, msta->vif, flow, MCU_TWT_AGRT_ADD))
  2385			goto unlock;
  2386	
  2387		setup_cmd = TWT_SETUP_CMD_ACCEPT;
  2388		dev->twt.table_mask |= BIT(table_id);
  2389		msta->twt.flowid_mask |= BIT(flowid);
  2390		dev->twt.n_agrt++;
  2391	
  2392	unlock:
  2393		mutex_unlock(&dev->mt76.mutex);
  2394	out:
  2395		le16p_replace_bits(&twt_agrt->req_type, setup_cmd,
  2396				   IEEE80211_TWT_REQTYPE_SETUP_CMD);
  2397		twt->control = (twt->control & IEEE80211_TWT_CONTROL_WAKE_DUR_UNIT) |
  2398			       (twt->control & IEEE80211_TWT_CONTROL_RX_DISABLED);
  2399	}
  2400	

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ