Revert "net: dev: Convert sa_data to flexible array in struct sockaddr"
This reverts commit 4d3b2bd995ed993756ac43f3bc5be7688e66c8fa which is
commit b5f0de6df6dce8d641ef58ef7012f3304dffb9a1 upstream.
It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed. It's not a "real" break, and
we can work around it, but this really does not affect Android systems,
so it's safe to drop for now.
Bug: 161946584
Change-Id: Id2666dca715b44594f71e291a4c01e5b5a0e88d9
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 4c5ce81..041d603 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -31,10 +31,7 @@
struct sockaddr {
sa_family_t sa_family; /* address family, AF_xxx */
- union {
- char sa_data_min[14]; /* Minimum 14 bytes of protocol address */
- DECLARE_FLEX_ARRAY(char, sa_data);
- };
+ char sa_data[14]; /* 14 bytes of protocol address */
};
struct linger {
diff --git a/net/core/dev.c b/net/core/dev.c
index 415b860..5452b7f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -9097,7 +9097,7 @@
int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name)
{
- size_t size = sizeof(sa->sa_data_min);
+ size_t size = sizeof(sa->sa_data);
struct net_device *dev;
int ret = 0;
diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
index 6ddfd7b..0e87237 100644
--- a/net/core/dev_ioctl.c
+++ b/net/core/dev_ioctl.c
@@ -339,7 +339,7 @@
if (ifr->ifr_hwaddr.sa_family != dev->type)
return -EINVAL;
memcpy(dev->broadcast, ifr->ifr_hwaddr.sa_data,
- min(sizeof(ifr->ifr_hwaddr.sa_data_min),
+ min(sizeof(ifr->ifr_hwaddr.sa_data),
(size_t)dev->addr_len));
call_netdevice_notifiers(NETDEV_CHANGEADDR, dev);
return 0;
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 75fb807..d62f79c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3252,7 +3252,7 @@
int addr_len)
{
struct sock *sk = sock->sk;
- char name[sizeof(uaddr->sa_data_min) + 1];
+ char name[sizeof(uaddr->sa_data) + 1];
/*
* Check legality
@@ -3263,8 +3263,8 @@
/* uaddr->sa_data comes from the userspace, it's not guaranteed to be
* zero-terminated.
*/
- memcpy(name, uaddr->sa_data, sizeof(uaddr->sa_data_min));
- name[sizeof(uaddr->sa_data_min)] = 0;
+ memcpy(name, uaddr->sa_data, sizeof(uaddr->sa_data));
+ name[sizeof(uaddr->sa_data)] = 0;
return packet_do_bind(sk, name, 0, 0);
}
@@ -3536,11 +3536,11 @@
return -EOPNOTSUPP;
uaddr->sa_family = AF_PACKET;
- memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data_min));
+ memset(uaddr->sa_data, 0, sizeof(uaddr->sa_data));
rcu_read_lock();
dev = dev_get_by_index_rcu(sock_net(sk), READ_ONCE(pkt_sk(sk)->ifindex));
if (dev)
- strscpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data_min));
+ strscpy(uaddr->sa_data, dev->name, sizeof(uaddr->sa_data));
rcu_read_unlock();
return sizeof(*uaddr);