<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/drivers/nfc, branch v6.0</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v6.0</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v6.0'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2022-08-22T13:51:30Z</updated>
<entry>
<title>nfc: pn533: Fix use-after-free bugs caused by pn532_cmd_timeout</title>
<updated>2022-08-22T13:51:30Z</updated>
<author>
<name>Duoming Zhou</name>
<email>duoming@zju.edu.cn</email>
</author>
<published>2022-08-18T09:06:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f1e941dbf80a9b8bab0bffbc4cbe41cc7f4c6fb6'/>
<id>urn:sha1:f1e941dbf80a9b8bab0bffbc4cbe41cc7f4c6fb6</id>
<content type='text'>
When the pn532 uart device is detaching, the pn532_uart_remove()
is called. But there are no functions in pn532_uart_remove() that
could delete the cmd_timeout timer, which will cause use-after-free
bugs. The process is shown below:

    (thread 1)                  |        (thread 2)
                                |  pn532_uart_send_frame
pn532_uart_remove               |    mod_timer(&amp;pn532-&gt;cmd_timeout,...)
  ...                           |    (wait a time)
  kfree(pn532) //FREE           |    pn532_cmd_timeout
                                |      pn532_uart_send_frame
                                |        pn532-&gt;... //USE

This patch adds del_timer_sync() in pn532_uart_remove() in order to
prevent the use-after-free bugs. What's more, the pn53x_unregister_nfc()
is well synchronized, it sets nfc_dev-&gt;shutting_down to true and there
are no syscalls could restart the cmd_timeout timer.

Fixes: c656aa4c27b1 ("nfc: pn533: add UART phy driver")
Signed-off-by: Duoming Zhou &lt;duoming@zju.edu.cn&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>NFC: nxp-nci: add error reporting</title>
<updated>2022-07-14T01:52:12Z</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2022-07-12T17:00:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5dc0f7491f9af356a3c78d56fe55890ebf37a1ac'/>
<id>urn:sha1:5dc0f7491f9af356a3c78d56fe55890ebf37a1ac</id>
<content type='text'>
The PN7160 supports error notifications. Add the appropriate callbacks.

Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Acked-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Link: https://lore.kernel.org/r/20220712170011.2990629-1-michael@walle.cc
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>NFC: nxp-nci: don't print header length mismatch on i2c error</title>
<updated>2022-06-29T13:05:00Z</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2022-06-27T17:06:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=9577fc5fdc8b07b891709af6453545db405e24ad'/>
<id>urn:sha1:9577fc5fdc8b07b891709af6453545db405e24ad</id>
<content type='text'>
Don't print a misleading header length mismatch error if the i2c call
returns an error. Instead just return the error code without any error
message.

Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>NFC: nxp-nci: Don't issue a zero length i2c_master_read()</title>
<updated>2022-06-29T13:05:00Z</updated>
<author>
<name>Michael Walle</name>
<email>michael@walle.cc</email>
</author>
<published>2022-06-27T17:06:42Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=eddd95b9423946aaacb55cac6a9b2cea8ab944fc'/>
<id>urn:sha1:eddd95b9423946aaacb55cac6a9b2cea8ab944fc</id>
<content type='text'>
There are packets which doesn't have a payload. In that case, the second
i2c_master_read() will have a zero length. But because the NFC
controller doesn't have any data left, it will NACK the I2C read and
-ENXIO will be returned. In case there is no payload, just skip the
second i2c master read.

Fixes: 6be88670fc59 ("NFC: nxp-nci_i2c: Add I2C support to NXP NCI driver")
Signed-off-by: Michael Walle &lt;michael@walle.cc&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>nfc: nfcmrvl: Fix irq_of_parse_and_map() return value</title>
<updated>2022-06-29T04:27:53Z</updated>
<author>
<name>Krzysztof Kozlowski</name>
<email>krzysztof.kozlowski@linaro.org</email>
</author>
<published>2022-06-27T12:40:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5a478a653b4cca148d5c89832f007ec0809d7e6d'/>
<id>urn:sha1:5a478a653b4cca148d5c89832f007ec0809d7e6d</id>
<content type='text'>
The irq_of_parse_and_map() returns 0 on failure, not a negative ERRNO.

Reported-by: Lv Ruyi &lt;lv.ruyi@zte.com.cn&gt;
Fixes: caf6e49bf6d0 ("NFC: nfcmrvl: add spi driver")
Signed-off-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Link: https://lore.kernel.org/r/20220627124048.296253-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>nfc: nfcmrvl: Fix memory leak in nfcmrvl_play_deferred</title>
<updated>2022-06-08T17:18:10Z</updated>
<author>
<name>Xiaohui Zhang</name>
<email>xiaohuizhang@ruc.edu.cn</email>
</author>
<published>2022-06-07T08:32:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8a4d480702b71184fabcf379b80bf7539716752e'/>
<id>urn:sha1:8a4d480702b71184fabcf379b80bf7539716752e</id>
<content type='text'>
Similar to the handling of play_deferred in commit 19cfe912c37b
("Bluetooth: btusb: Fix memory leak in play_deferred"), we thought
a patch might be needed here as well.

Currently usb_submit_urb is called directly to submit deferred tx
urbs after unanchor them.

So the usb_giveback_urb_bh would failed to unref it in usb_unanchor_urb
and cause memory leak.

Put those urbs in tx_anchor to avoid the leak, and also fix the error
handling.

Signed-off-by: Xiaohui Zhang &lt;xiaohuizhang@ruc.edu.cn&gt;
Acked-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Link: https://lore.kernel.org/r/20220607083230.6182-1-xiaohuizhang@ruc.edu.cn
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>nfc: st21nfca: fix incorrect sizing calculations in EVT_TRANSACTION</title>
<updated>2022-06-08T17:17:17Z</updated>
<author>
<name>Martin Faltesek</name>
<email>mfaltesek@google.com</email>
</author>
<published>2022-06-07T02:57:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f2e19b36593caed4c977c2f55aeba7408aeb2132'/>
<id>urn:sha1:f2e19b36593caed4c977c2f55aeba7408aeb2132</id>
<content type='text'>
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-&gt;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 &lt;mfaltesek@google.com&gt;
Reviewed-by: Guenter Roeck &lt;groeck@chromium.org&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>nfc: st21nfca: fix memory leaks in EVT_TRANSACTION handling</title>
<updated>2022-06-08T17:17:17Z</updated>
<author>
<name>Martin Faltesek</name>
<email>mfaltesek@google.com</email>
</author>
<published>2022-06-07T02:57:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=996419e0594abb311fb958553809f24f38e7abbe'/>
<id>urn:sha1:996419e0594abb311fb958553809f24f38e7abbe</id>
<content type='text'>
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 &lt;mfaltesek@google.com&gt;
Reviewed-by: Guenter Roeck &lt;groeck@chromium.org&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>nfc: st21nfca: fix incorrect validating logic in EVT_TRANSACTION</title>
<updated>2022-06-08T17:17:17Z</updated>
<author>
<name>Martin Faltesek</name>
<email>mfaltesek@google.com</email>
</author>
<published>2022-06-07T02:57:27Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=77e5fe8f176a525523ae091d6fd0fbb8834c156d'/>
<id>urn:sha1:77e5fe8f176a525523ae091d6fd0fbb8834c156d</id>
<content type='text'>
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 &amp;&amp; to ||.

Fixes: 26fc6c7f02cb ("NFC: st21nfca: Add HCI transaction event support")
Cc: stable@vger.kernel.org
Signed-off-by: Martin Faltesek &lt;mfaltesek@google.com&gt;
Reviewed-by: Guenter Roeck &lt;groeck@chromium.org&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
<entry>
<title>NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx</title>
<updated>2022-05-20T00:54:02Z</updated>
<author>
<name>Duoming Zhou</name>
<email>duoming@zju.edu.cn</email>
</author>
<published>2022-05-18T11:57:33Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=b413b0cb008646e9f24ce5253cb3cf7ee217aff6'/>
<id>urn:sha1:b413b0cb008646e9f24ce5253cb3cf7ee217aff6</id>
<content type='text'>
There are sleep in atomic context bugs when the request to secure
element of st21nfca is timeout. The root cause is that kzalloc and
alloc_skb with GFP_KERNEL parameter and mutex_lock are called in
st21nfca_se_wt_timeout which is a timer handler. The call tree shows
the execution paths that could lead to bugs:

   (Interrupt context)
st21nfca_se_wt_timeout
  nfc_hci_send_event
    nfc_hci_hcp_message_tx
      kzalloc(..., GFP_KERNEL) //may sleep
      alloc_skb(..., GFP_KERNEL) //may sleep
      mutex_lock() //may sleep

This patch moves the operations that may sleep into a work item.
The work item will run in another kernel thread which is in
process context to execute the bottom half of the interrupt.
So it could prevent atomic context from sleeping.

Fixes: 2130fb97fecf ("NFC: st21nfca: Adding support for secure element")
Signed-off-by: Duoming Zhou &lt;duoming@zju.edu.cn&gt;
Reviewed-by: Krzysztof Kozlowski &lt;krzysztof.kozlowski@linaro.org&gt;
Link: https://lore.kernel.org/r/20220518115733.62111-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
</content>
</entry>
</feed>
