Sergei Trofimovich reported a regression [0] caused by commit a0ade8404c3b ("af_packet: Fix warning of fortified memcpy() in packet_getname()."). It introduced a flex array sll_addr_flex in struct sockaddr_ll as a union-ed member with sll_addr to work around the fortified memcpy() check. However, a userspace program uses a struct that has struct sockaddr_ll in the middle, where a flex array is illegal to exist. include/linux/if_packet.h:24:17: error: flexible array member 'sockaddr_ll::<unnamed union>::<unnamed struct>::sll_addr_flex' not at end of 'struct packet_info_t' 24 | __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex); | ^~~~~~~~~~~~~~~~~~~~ To fix the regression, let's go back to the first attempt [1] telling memcpy() the actual size of the array.
Showing the changes to include/uapi (1 of 2 files). Show all
Unified · Split
| @@ -18,11 +18,7 @@ struct sockaddr_ll { · 17 unmodified lines | |||
| 18 | unsigned short sll_hatype; | 18 | unsigned short sll_hatype; |
| 19 | unsigned char sll_pkttype; | 19 | unsigned char sll_pkttype; |
| 20 | unsigned char sll_halen; | 20 | unsigned char sll_halen; |
| 21 | union { | 21 | unsigned char sll_addr[8]; |
| 22 | unsigned char sll_addr[8]; | ||
| 23 | /* Actual length is in sll_halen. */ | ||
| 24 | __DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex); | ||
| 25 | }; | ||
| 26 | }; | 22 | }; |
| 27 | 23 | ||
| 28 | /* Packet types */ | 24 | /* Packet types */ |