All of lore.kernel.org
 help / color / mirror / Atom feed
* ath12k: memcpy() source buffer overread
@ 2023-06-20  6:18 Dmitry Antipov
  2023-08-03 13:54   ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Antipov @ 2023-06-20  6:18 UTC (permalink / raw)
  To: Kalle Valo; +Cc: linux-wireless

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-08-03 13:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-20  6:18 ath12k: memcpy() source buffer overread Dmitry Antipov
2023-08-03 13:54 ` Kalle Valo
2023-08-03 13:54   ` Kalle Valo

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.