linux-stable/drivers/nfc
Duoming Zhou b413b0cb00 NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx
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: 2130fb97fe ("NFC: st21nfca: Adding support for secure element")
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20220518115733.62111-1-duoming@zju.edu.cn
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-05-19 17:54:02 -07:00
..
fdp nfc: fdp: Merge the same judgment 2021-11-26 11:22:14 -08:00
microread nfc: microread: drop unneeded debug prints 2021-10-11 17:00:52 -07:00
nfcmrvl nfc: nfcmrvl: main: reorder destructive operations in nfcmrvl_nci_unregister_dev to avoid bugs 2022-05-01 13:26:05 +01:00
nxp-nci nfc: constify nci_ops 2021-07-25 09:21:20 +01:00
pn533 nfc: pn533: Fix buggy cleanup order 2022-05-18 13:58:13 +01:00
pn544 nfc: pn544: make array rset_cmd static const 2022-01-11 21:09:03 -08:00
s3fwrn5 nfc: s3fwrn5: simplify dereferencing pointer to struct device 2021-10-11 17:00:51 -07:00
st-nci spi: Make remove() return void 2022-02-28 10:43:07 -08:00
st21nfca NFC: hci: fix sleep in atomic context bugs in nfc_hci_hcp_message_tx 2022-05-19 17:54:02 -07:00
st95hf spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
Kconfig
Makefile
mei_phy.c nfc: mei_phy: constify buffer passed to mei_nfc_send() 2021-07-29 12:28:02 +01:00
mei_phy.h nfc: constify nfc_phy_ops 2021-07-25 09:21:21 +01:00
nfcsim.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-07-31 09:14:46 -07:00
port100.c NFC: port100: fix use-after-free in port100_send_complete 2022-03-09 19:59:34 -08:00
trf7970a.c spi: make remove callback a void function 2022-02-09 13:00:45 +00:00
virtual_ncidev.c nfc: virtual_ncidev: change default device permissions 2021-11-26 11:14:31 -08:00