Commit a49441c9 authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-fix-error-warning-by-fstrict-flex-arrays-3'

Kuniyuki Iwashima says:

====================
net: Fix error/warning by -fstrict-flex-arrays=3.

df8fc4e9 ("kbuild: Enable -fstrict-flex-arrays=3") started applying
strict rules for standard string functions (strlen(), memcpy(), etc.) if
CONFIG_FORTIFY_SOURCE=y.

This series fixes two false positives caught by syzkaller.

v2: https://lore.kernel.org/netdev/20230720004410.87588-1-kuniyu@amazon.com/
v1: https://lore.kernel.org/netdev/20230719185322.44255-1-kuniyu@amazon.com/
====================

Link: https://lore.kernel.org/r/20230724213425.22920-1-kuniyu@amazon.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 55cef78c a0ade840
...@@ -18,7 +18,11 @@ struct sockaddr_ll { ...@@ -18,7 +18,11 @@ struct sockaddr_ll {
unsigned short sll_hatype; unsigned short sll_hatype;
unsigned char sll_pkttype; unsigned char sll_pkttype;
unsigned char sll_halen; unsigned char sll_halen;
unsigned char sll_addr[8]; union {
unsigned char sll_addr[8];
/* Actual length is in sll_halen. */
__DECLARE_FLEX_ARRAY(unsigned char, sll_addr_flex);
};
}; };
/* Packet types */ /* Packet types */
......
...@@ -3601,7 +3601,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr, ...@@ -3601,7 +3601,7 @@ static int packet_getname(struct socket *sock, struct sockaddr *uaddr,
if (dev) { if (dev) {
sll->sll_hatype = dev->type; sll->sll_hatype = dev->type;
sll->sll_halen = dev->addr_len; sll->sll_halen = dev->addr_len;
memcpy(sll->sll_addr, dev->dev_addr, dev->addr_len); memcpy(sll->sll_addr_flex, dev->dev_addr, dev->addr_len);
} else { } else {
sll->sll_hatype = 0; /* Bad: we have no ARPHRD_UNSPEC */ sll->sll_hatype = 0; /* Bad: we have no ARPHRD_UNSPEC */
sll->sll_halen = 0; sll->sll_halen = 0;
......
...@@ -1208,10 +1208,8 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr, ...@@ -1208,10 +1208,8 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr,
struct path parent; struct path parent;
int err; int err;
unix_mkname_bsd(sunaddr, addr_len); addr_len = strnlen(sunaddr->sun_path, sizeof(sunaddr->sun_path))
addr_len = strlen(sunaddr->sun_path) + + offsetof(struct sockaddr_un, sun_path) + 1;
offsetof(struct sockaddr_un, sun_path) + 1;
addr = unix_create_addr(sunaddr, addr_len); addr = unix_create_addr(sunaddr, addr_len);
if (!addr) if (!addr)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment