* [linux-nfc] Re: [PATCH net v3 1/3] nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
[not found] ` <20220607025729.1673212-2-mfaltesek@google.com>
@ 2022-06-07 17:13 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-07 17:13 UTC (permalink / raw)
To: Martin Faltesek, kuba
Cc: christophe.ricard, gregkh, groeck, jordy, krzk, martin.faltesek,
netdev, linux-nfc, wklin, theflamefire89, stable
On 07/06/2022 04:57, Martin Faltesek wrote:
> The first validation check for EVT_TRANSACTION has two different checks
> tied together with logical AND. One is a check for minimum packet length,
> and the other is for a valid aid_tag. If either condition is true (fails),
> then an error should be triggered. The fix is to change && to ||.
>
> Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Martin Faltesek <mfaltesek@google.com>
> ---
> drivers/nfc/st21nfca/se.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Please add Acked-by/Reviewed-by tags when posting new versions. However,
there's no need to repost patches *only* to add the tags. The upstream
maintainer will do that for acks received on the version they apply.
https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540
If a tag was not added on purpose, please state why and what changed.
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
^ permalink raw reply [flat|nested] 4+ messages in thread
* [linux-nfc] Re: [PATCH net v3 2/3] nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
[not found] ` <20220607025729.1673212-3-mfaltesek@google.com>
@ 2022-06-07 17:15 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-07 17:15 UTC (permalink / raw)
To: Martin Faltesek, kuba
Cc: christophe.ricard, gregkh, groeck, jordy, krzk, martin.faltesek,
netdev, linux-nfc, wklin, theflamefire89, stable
On 07/06/2022 04:57, Martin Faltesek wrote:
> Error paths do not free previously allocated memory. Add devm_kfree() to
> those failure paths.
>
> Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
> Fixes: 4fbcc1a4cb20 ("nfc: st21nfca: Fix potential buffer overflows in EVT_TRANSACTION")
> Cc: stable@vger.kernel.org
> Signed-off-by: Martin Faltesek <mfaltesek@google.com>
Standard disclaimer:
---------
Please add Acked-by/Reviewed-by tags when posting new versions. However,
there's no need to repost patches *only* to add the tags. The upstream
maintainer will do that for acks received on the version they apply.
https://elixir.bootlin.com/linux/v5.17/source/Documentation/process/submitting-patches.rst#L540
If a tag was not added on purpose, please state why and what changed.
---------
So you dropped all my review tags?
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
^ permalink raw reply [flat|nested] 4+ messages in thread
* [linux-nfc] Re: [PATCH net v3 3/3] nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION
[not found] ` <20220607025729.1673212-4-mfaltesek@google.com>
@ 2022-06-08 7:09 ` Krzysztof Kozlowski
0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Kozlowski @ 2022-06-08 7:09 UTC (permalink / raw)
To: Martin Faltesek, kuba
Cc: christophe.ricard, gregkh, groeck, jordy, krzk, martin.faltesek,
netdev, linux-nfc, wklin, theflamefire89, stable
On 07/06/2022 04:57, Martin Faltesek wrote:
> The transaction buffer is allocated by using the size of the packet buf,
> and subtracting two which seem intended to remove the two tags which are
> not present in the target structure. This calculation leads to under
> counting memory because of differences between the packet contents and the
> target structure. The aid_len field is a u8 in the packet, but a u32 in
> the structure, resulting in at least 3 bytes always being under counted.
> Further, the aid data is a variable length field in the packet, but fixed
> in the structure, so if this field is less than the max, the difference is
> added to the under counting.
>
> The last validation check for transaction->params_len is also incorrect
> since it employs the same accounting error.
>
> To fix, perform validation checks progressively to safely reach the
> next field, to determine the size of both buffers and verify both tags.
> Once all validation checks pass, allocate the buffer and copy the data.
> This eliminates freeing memory on the error path, as those checks are
> moved ahead of memory allocation.
>
> Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
> Fixes: 4fbcc1a4cb20 ("nfc: st21nfca: Fix potential buffer overflows in EVT_TRANSACTION")
> Cc: stable@vger.kernel.org
> Signed-off-by: Martin Faltesek <mfaltesek@google.com>
> ---
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Best regards,
Krzysztof
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
^ permalink raw reply [flat|nested] 4+ messages in thread
* [linux-nfc] Re: [PATCH net v3 0/3] Split "nfc: st21nfca: Refactor EVT_TRANSACTION" into 3
[not found] ` <fc85ff14-70d6-0c3e-247d-eda2284a5f6b@oracle.com>
@ 2022-07-20 14:53 ` Martin Faltesek
0 siblings, 0 replies; 4+ messages in thread
From: Martin Faltesek @ 2022-07-20 14:53 UTC (permalink / raw)
To: Denis Efremov
Cc: Jakub Kicinski, Krzysztof Kozlowski, christophe.ricard,
Greg Kroah-Hartman, Guenter Roeck, jordy, krzk, Martin Faltesek,
netdev, linux-nfc, William K Lin, theflamefire89
On Wed, Jul 20, 2022 at 1:25 AM Denis Efremov
<denis.e.efremov@oracle.com> wrote:
>
> Hi,
>
> On 6/7/22 06:57, Martin Faltesek wrote:
> >
> > Martin Faltesek (3):
> > nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION
> > nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling
> > nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION
> >
> > drivers/nfc/st21nfca/se.c | 53 ++++++++++++++++++++++-----------------
> > 1 file changed, 30 insertions(+), 23 deletions(-)
>
>
> It looks like driver st-nci contains the same problems and all 3 fixes are
> also applicable to st_nci_hci_connectivity_event_received() function.
> At least I can see the memory leak
> https://elixir.bootlin.com/linux/v5.19-rc7/source/drivers/nfc/st-nci/se.c#L343
>
> Can you please double check the st-nci driver and send the same fixes to it?
> Reported-by: Denis Efremov <denis.e.efremov@oracle.com>
Will do.
_______________________________________________
Linux-nfc mailing list -- linux-nfc@lists.01.org
To unsubscribe send an email to linux-nfc-leave@lists.01.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-07-20 14:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20220607025729.1673212-1-mfaltesek@google.com>
[not found] ` <20220607025729.1673212-2-mfaltesek@google.com>
2022-06-07 17:13 ` [linux-nfc] Re: [PATCH net v3 1/3] nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION Krzysztof Kozlowski
[not found] ` <20220607025729.1673212-3-mfaltesek@google.com>
2022-06-07 17:15 ` [linux-nfc] Re: [PATCH net v3 2/3] nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling Krzysztof Kozlowski
[not found] ` <20220607025729.1673212-4-mfaltesek@google.com>
2022-06-08 7:09 ` [linux-nfc] Re: [PATCH net v3 3/3] nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION Krzysztof Kozlowski
[not found] ` <fc85ff14-70d6-0c3e-247d-eda2284a5f6b@oracle.com>
2022-07-20 14:53 ` [linux-nfc] Re: [PATCH net v3 0/3] Split "nfc: st21nfca: Refactor EVT_TRANSACTION" into 3 Martin Faltesek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).