Re: [PATCH] NFC: nci: Bounds check struct nfc_target arrays

From: Krzysztof Kozlowski
Date: Mon Dec 05 2022 - 03:17:41 EST


On 02/12/2022 22:44, Kees Cook wrote:
> While running under CONFIG_FORTIFY_SOURCE=y, syzkaller reported:
>
> memcpy: detected field-spanning write (size 129) of single field "target->sensf_res" at net/nfc/nci/ntf.c:260 (size 18)
>
> This appears to be a legitimate lack of bounds checking in
> nci_add_new_protocol(). Add the missing checks.
>
> Reported-by: syzbot+210e196cef4711b65139@xxxxxxxxxxxxxxxxxxxxxxxxx
> Link: https://lore.kernel.org/lkml/0000000000001c590f05ee7b3ff4@xxxxxxxxxx
> Fixes: 019c4fbaa790 ("NFC: Add NCI multiple targets support")
> Cc: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
> Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>
> Cc: Eric Dumazet <edumazet@xxxxxxxxxx>
> Cc: Jakub Kicinski <kuba@xxxxxxxxxx>
> Cc: Paolo Abeni <pabeni@xxxxxxxxxx>
> Cc: netdev@xxxxxxxxxxxxxxx
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>

Best regards,
Krzysztof