Skip to content

Commit

Permalink
enic: Avoid false positive under FORTIFY_SOURCE
Browse files Browse the repository at this point in the history
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 <keescook@chromium.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Kees Cook authored and David S. Miller committed Feb 19, 2024
1 parent 121e4dc commit 40b9385
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/ethernet/cisco/enic/vnic_vic.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ int vic_provinfo_add_tlv(struct vic_provinfo *vp, u16 type, u16 length,

tlv->type = htons(type);
tlv->length = htons(length);
memcpy(tlv->value, value, length);
unsafe_memcpy(tlv->value, value, length,
/* Flexible array of flexible arrays */);

vp->num_tlvs = htonl(ntohl(vp->num_tlvs) + 1);
vp->length = htonl(ntohl(vp->length) +
Expand Down

0 comments on commit 40b9385

Please sign in to comment.