Skip to content

Commit 40b9385

Browse files
keesdavem330
authored andcommitted
enic: Avoid false positive under FORTIFY_SOURCE
FORTIFY_SOURCE has been ignoring 0-sized destinations while the kernel code base has been converted to flexible arrays. In order to enforce the 0-sized destinations (e.g. with __counted_by), the remaining 0-sized destinations need to be handled. Unfortunately, struct vic_provinfo resists full conversion, as it contains a flexible array of flexible arrays, which is only possible with the 0-sized fake flexible array. Use unsafe_memcpy() to avoid future false positives under CONFIG_FORTIFY_SOURCE. Signed-off-by: Kees Cook <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 121e4dc commit 40b9385

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/ethernet/cisco/enic/vnic_vic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,
4949

5050
tlv->type = htons(type);
5151
tlv->length = htons(length);
52-
memcpy(tlv->value, value, length);
52+
unsafe_memcpy(tlv->value, value, length,
53+
/* Flexible array of flexible arrays */);
5354

5455
vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1);
5556
vp->length = htonl(ntohl(vp->length) +

0 commit comments

Comments
 (0)