1
0
Fork 0
alistair23-linux/drivers/nfc
Michael Thalmeier 37f895d7e8 NFC: pn533: Fix socket deadlock
A deadlock can occur when the NFC raw socket is closed while
the driver is processing a command.

Following is the call graph of the affected situation:

send data via raw_sock:
-------------
rawsock_tx_work
  sock_hold => socket refcnt++
  nfc_data_exchange => cb = rawsock_data_exchange_complete

    ops->im_transceive = pn533_transceive => arg->cb = db
                               = rawsock_data_exchange_complete

      pn533_send_data_async => cb = pn533_data_exchange_complete

        __pn533_send_async => cmd->complete_cb = cb
                              = pn533_data_exchange_complete

          if_ops->send_frame_async

response:
--------
pn533_recv_response
  queue_work(priv->wq, &priv->cmd_complete_work)

pn533_wq_cmd_complete

  pn533_send_async_complete

    cmd->complete_cb() = pn533_data_exchange_complete()

      arg->cb() = rawsock_data_exchange_complete()

        sock_put => socket refcnt-- => If the corresponding
                    socket gets closed in the meantime socket
                    will be destructed

          sk_free

            __sk_free

              sk->sk_destruct = rawsock_destruct

                nfc_deactivate_target

                  ops->deactivate_target = pn533_deactivate_target

                    pn533_send_cmd_sync

                      pn533_send_cmd_async

                        __pn533_send_async

                          list_add_tail(&cmd->queue,&dev->cmd_queue)
                                  => add to command list because
                                     a command is currently
                                     processed

                        wait_for_completion
                                   => the workqueue thread waits
                                      here because it is the one
                                      processing the commands
                                         => deadlock

To fix the deadlock pn533_deactivate_target is changed to
issue the PN533_CMD_IN_RELEASE command in async mode. This
way nothing blocks and the release command is executed after
the current command.

Signed-off-by: Michael Thalmeier <michael.thalmeier@hale.at>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
2016-04-09 23:53:11 +02:00
..
fdp nfc: fdp: Move i2c client irq checking 2015-12-29 19:06:21 +01:00
microread NFC: microread: Drop platform data header file 2016-03-09 23:25:45 +01:00
nfcmrvl NFC: nfcmrvl: avoid being stuck on FW dnld timeout 2015-11-05 00:32:25 +01:00
nxp-nci nfc: nxp-nci: Remove i2c client gpio irq configuration 2015-12-29 19:06:22 +01:00
pn544 NFC: pn544: Drop two useless checks in ACPI probe path 2016-03-03 10:34:45 +01:00
s3fwrn5 nfc: s3fwrn5: Use shash 2016-01-27 20:36:09 +08:00
st-nci nfc: st-nci: Add support for HCI event connectivity 2015-12-29 19:06:20 +01:00
st21nfca nfc: st21nfca: Add support for HCI event connectivity 2015-12-29 19:06:20 +01:00
st95hf NFC: st95hf: Fix build error 2015-12-29 19:06:12 +01:00
Kconfig NFC: Add STMicroelectronics ST95HF driver 2015-12-29 19:06:11 +01:00
Makefile NFC: Add STMicroelectronics ST95HF driver 2015-12-29 19:06:11 +01:00
mei_phy.c mei: bus: use mei_cldev_ prefix for the API functions 2015-09-20 19:31:10 -07:00
mei_phy.h mei: bus: complete variable rename of type struct mei_cl_device 2015-09-20 19:31:09 -07:00
nfcsim.c NFC: add rx delay sysfs parameter for nfcsim workqueue 2015-12-21 00:07:27 +01:00
nfcwilink.c NFC: nfcwilink: Drop a useless static qualifier 2015-10-19 20:06:13 +02:00
pn533.c NFC: pn533: Fix socket deadlock 2016-04-09 23:53:11 +02:00
port100.c NFC: logging neatening 2015-04-07 12:05:12 +02:00
trf7970a.c NFC: trf7970a: use to_spi_device 2015-12-29 19:06:12 +01:00