Message ID | 20240216233004.work.012-kees@kernel.org (mailing list archive) |
---|---|
State | Accepted |
Commit | 40b9385dd8e6a0515e1c9cd06a277483556b7286 |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | enic: Avoid false positive under FORTIFY_SOURCE | expand |
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Fri, 16 Feb 2024 15:30:05 -0800 you wrote: > 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. > > [...] Here is the summary with links: - enic: Avoid false positive under FORTIFY_SOURCE https://git.kernel.org/netdev/net/c/40b9385dd8e6 You are awesome, thank you!
diff --git a/drivers/net/ethernet/cisco/enic/vnic_vic.c b/drivers/net/ethernet/cisco/enic/vnic_vic.c index 20fcb20b42ed..66b577835338 100644 --- a/drivers/net/ethernet/cisco/enic/vnic_vic.c +++ b/drivers/net/ethernet/cisco/enic/vnic_vic.c @@ -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) +
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> --- Cc: Christian Benvenuti <benve@cisco.com> Cc: Satish Kharat <satishkh@cisco.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Gustavo A. R. Silva <gustavo@embeddedor.com> Cc: netdev@vger.kernel.org --- drivers/net/ethernet/cisco/enic/vnic_vic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)