Re: [PATCH] net: nfc: nci: fix for UBSAN: shift-out-of-bounds in nci_activate_target

Krzysztof Kozlowski
2023-04-19T19:42:56Z

On 19/04/2023 21:21, Anup Sharma wrote:

>
>>>> + pr_err("Too many supported protocol by the device\n");
>>>> + return -EINVAL;
>>>
>>> I am pretty sure that you broke now NFC. Test the patches first and
>>> share your test scenario.
>
> Since a reproducer for this bug is not available, I am unable to test it locally
> or through syzbot before submitting the patch.

Reproducer is only to test the actual issue, not test the code. Code can
be tested with real device and maybe with virtual NCI driver.

> Are there any other tests that
> I can perform before submitting the patch, apart from simply compiling the kernel?

Compiling a kernel is not tested. Maybe you can test this part
successfully with virtual NCI driver, maybe not, I don't know.

>
>>
>> BTW, ISO15693 is here protocol 128, so definitely more than 32.
>
> Thank you for your feedback. I would like to address the UBSAN bug and I have
> thought of a potential solution which involves adding a check statement for the
> minimum and maximum values of the protocol before net/nfc/nci/core.c +912:
>
> if (!(nci_target->supported_protocols & (1 << protocol)))
>
> Could you please assist me in determining the correct approach?

I would first propose to check whether the UBSAN report is an actual
real issue to fix.

Best regards,
Krzysztof