Search Linux Wireless

ath12k: memcpy() source buffer overread

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When compiling with gcc 13.1 and CONFIG_FORTIFY_SOURCE=y, I've noticed the following:

...
In function ‘fortify_memcpy_chk’,
    inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1640:2,
    inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
[-Wattribute-warning]
  529 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In function ‘fortify_memcpy_chk’,
    inlined from ‘ath12k_peer_assoc_h_he’ at drivers/net/wireless/ath/ath12k/mac.c:1643:2,
    inlined from ‘ath12k_peer_assoc_prepare’ at drivers/net/wireless/ath/ath12k/mac.c:2027:2:
./include/linux/fortify-string.h:529:25: warning: call to ‘__read_overflow2_field’ declared with
attribute warning: detected read beyond size of field (2nd parameter); maybe use struct_group()?
[-Wattribute-warning]
  529 |                         __read_overflow2_field(q_size_field, size);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

And this seems correct because:

/* dst: u32[2], src: u8[6], size: 8 so 2 byte source overread */
memcpy(&arg->peer_he_cap_macinfo, he_cap->he_cap_elem.mac_cap_info,
       sizeof(arg->peer_he_cap_macinfo));

and:

/* dst: u32[3], src: u8[11], size: 12 so 1 byte source overread */
memcpy(&arg->peer_he_cap_phyinfo, he_cap->he_cap_elem.phy_cap_info,
       sizeof(arg->peer_he_cap_phyinfo));

Dmitry




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux