Commit 08ea556e authored by Kees Cook's avatar Kees Cook Committed by David S. Miller

ibmvnic: Define vnic_login_client_data name field as unsized array

The "name" field of struct vnic_login_client_data is a char array of
undefined length. This should be written as "char name[]" so the compiler
can make better decisions about the field (for example, not assuming
it's a single character). This was noticed while trying to tighten the
CONFIG_FORTIFY_SOURCE checking.
Signed-off-by: default avatarKees Cook <keescook@chromium.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5d136594
...@@ -3170,7 +3170,7 @@ static int send_version_xchg(struct ibmvnic_adapter *adapter) ...@@ -3170,7 +3170,7 @@ static int send_version_xchg(struct ibmvnic_adapter *adapter)
struct vnic_login_client_data { struct vnic_login_client_data {
u8 type; u8 type;
__be16 len; __be16 len;
char name; char name[];
} __packed; } __packed;
static int vnic_client_data_len(struct ibmvnic_adapter *adapter) static int vnic_client_data_len(struct ibmvnic_adapter *adapter)
...@@ -3199,21 +3199,21 @@ static void vnic_add_client_data(struct ibmvnic_adapter *adapter, ...@@ -3199,21 +3199,21 @@ static void vnic_add_client_data(struct ibmvnic_adapter *adapter,
vlcd->type = 1; vlcd->type = 1;
len = strlen(os_name) + 1; len = strlen(os_name) + 1;
vlcd->len = cpu_to_be16(len); vlcd->len = cpu_to_be16(len);
strncpy(&vlcd->name, os_name, len); strncpy(vlcd->name, os_name, len);
vlcd = (struct vnic_login_client_data *)((char *)&vlcd->name + len); vlcd = (struct vnic_login_client_data *)(vlcd->name + len);
/* Type 2 - LPAR name */ /* Type 2 - LPAR name */
vlcd->type = 2; vlcd->type = 2;
len = strlen(utsname()->nodename) + 1; len = strlen(utsname()->nodename) + 1;
vlcd->len = cpu_to_be16(len); vlcd->len = cpu_to_be16(len);
strncpy(&vlcd->name, utsname()->nodename, len); strncpy(vlcd->name, utsname()->nodename, len);
vlcd = (struct vnic_login_client_data *)((char *)&vlcd->name + len); vlcd = (struct vnic_login_client_data *)(vlcd->name + len);
/* Type 3 - device name */ /* Type 3 - device name */
vlcd->type = 3; vlcd->type = 3;
len = strlen(adapter->netdev->name) + 1; len = strlen(adapter->netdev->name) + 1;
vlcd->len = cpu_to_be16(len); vlcd->len = cpu_to_be16(len);
strncpy(&vlcd->name, adapter->netdev->name, len); strncpy(vlcd->name, adapter->netdev->name, len);
} }
static int send_login(struct ibmvnic_adapter *adapter) static int send_login(struct ibmvnic_adapter *adapter)
......
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