summaryrefslogtreecommitdiffstats
path: root/net/nfc
Commit message (Collapse)AuthorAgeFilesLines
* NFC: llcp: integer underflow in nfc_llcp_set_remote_gb()Dan Carpenter2013-02-081-3/+2Star
| | | | | | | | | | | | | | If gb_len is less than 3 it would cause an integer underflow and possibly memory corruption in nfc_llcp_parse_gb_tlv(). I removed the old test for gb_len == 0. I also removed the test for ->remote_gb == NULL. It's not possible for ->remote_gb to be NULL and we have already dereferenced ->remote_gb_len so it's too late to test. The old test return -ENODEV but my test returns -EINVAL. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
* NFC: Use skb_copy_datagram_iovecSamuel Ortiz2013-01-111-1/+1
| | | | | | Safer and more robust than than memcpy_toiovec. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Avoid memcpy on LLCP connection less Rx pathSamuel Ortiz2013-01-111-8/+8
| | | | | | We can cast msg_name to a sockaddr_nfc_llcp pointer directly. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Initial Secure Element APISamuel Ortiz2013-01-104-1/+8
| | | | | | | | | | Each NFC adapter can have several links to different secure elements and that property needs to be exported by the drivers. A secure element link can be enabled and disabled, and card emulation will be handled by the currently active one. Otherwise card emulation will be host implemented. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Add HCI quirks to support driver (non)standard implementationsEric Lapuyade2013-01-102-1/+9
| | | | | | | | | Some chips diverge from the HCI spec in their implementation of standard features. This adds a new quirks parameter to nfc_hci_allocate_device() to let the driver indicate its divergence. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Fixed skb leak in tm_send() nfc and hci ops implementationsEric Lapuyade2013-01-101-2/+4
| | | | | Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Changed event_received hci ops result semanticEric Lapuyade2013-01-101-6/+8
| | | | | | | | | | | | | Some chips use a standard HCI event code, destined to a proprietary gate, with a different meaning. Therefore, the HCI driver must always have a chance to intercept the event before standard processing is attempted. The new semantic specifies that the result value "1" means that the driver doesn't especially handle the event. result <= 0 means it was handled. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Added error handling in event_received hci opsEric Lapuyade2013-01-101-3/+5
| | | | | | There is no use to return an error if the caller doesn't get it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Fixed nfc core and hci unregistration and cleanupEric Lapuyade2013-01-103-32/+53
| | | | | | | | | | When an adapter is removed, it will unregister itself from hci and/or nfc core. In order to do that safely, work tasks must first be canceled and prevented to be scheduled again, before the hci or nfc device can be destroyed. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: llcp: Fix Rx memory leakSamuel Ortiz2013-01-101-10/+25
| | | | | | | | | | | | | The reference count bump on the llcp Rx path is leading to a memory leak whenever we're not receiving an I frame. We fix that by removing the refcount bump (drivers must not free their received skb) and using it only in the I frame path, when the frame is actually queued. In that case, the skb will only be freed when someone fetches it from userspace. in all other cases, LLCP received frames will be freed when leaving the Rx work queue. Reported-by: Eric Lapuyade <eric.lapuyade@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: llcp: Remove the tx backlog queueSamuel Ortiz2013-01-103-6/+2Star
| | | | | | | | Not only it was improperly use to queue backlogged RX skbuffs, but it was also not processed at all. If the socket receive queue is full we simply drop the incoming packets. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* NFC: Add support for SO_TIMESTAMP LLCP socket optionThierry Escande2013-01-103-0/+8
| | | | | | | | Set timestamp in sent and received sk_buffs. timestamp is then put in msghdr structure in llcp_sock_recvmsg(). Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* nfc: remove noisy message from llcp_sock_sendmsgDave Jones2012-12-131-4/+0Star
| | | | | | | | | This is easily triggerable when fuzz-testing as an unprivileged user. We could rate-limit it, but given we don't print similar messages for other protocols, I just removed it. Signed-off-by: Dave Jones <davej@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
* Merge tag 'nfc-fixes-3.7-2' of ↵John W. Linville2012-12-061-1/+4
|\ | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/sameo/nfc-3.0 This is an NFC LLCP fix for 3.7 and contains only one patch. It fixes a potential crash when receiving an LLCP HDLC frame acking a frame that is not the last sent one. In that case we may dereference an already freed pointer.
| * NFC: Fix incorrect llcp pointer dereferenceWaldemar Rymarkiewicz2012-11-281-1/+4
| | | | | | | | | | | | | | | | | | nfc_llcp_ns(s) dereferences the s pointer which is freed a line above. In a result, it can produce a crash or you will read incorrect value. Signed-off-by: Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | Merge branch 'master' of ↵John W. Linville2012-11-211-1/+1
|\| | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless Conflicts: drivers/net/wireless/brcm80211/brcmfmac/wl_cfg80211.c drivers/net/wireless/iwlwifi/pcie/tx.c
| * NFC: Fix nfc_llcp_local chained list insertionThierry Escande2012-11-201-1/+1
| | | | | | | | | | | | | | list_add was called with swapped parameters Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Queue a copy of the transmitted LLCP skbSamuel Ortiz2012-11-191-4/+13
| | | | | | | | | | | | | | | | | | | | Drivers are allowed to modify the sent skb and thus we need to make a copy of it before passing it to the driver. Without this fix, LLCP Tx skbs were not queued properly as the ptype check was failing due to e.g. the pn533 driver skb_pushing the Tx skb. Reported-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Stop sending LLCP frames when tx queues are getting too deepSamuel Ortiz2012-11-191-0/+17
| | | | | | | | | | | | | | | | When the tx pending queues and/or the socket tx queue is getting too deep, we have to let userspace know. We won't be queueing any more frames until the congestion is fixed. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Copy user space buffer when sending UI framesSamuel Ortiz2012-11-191-2/+13
| | | | | | | | | | | | | | Using the userspace IO vector directly is wrong, we should copy it from user space first. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Export nfc_hci_sak_to_protocol()Eric Lapuyade2012-11-191-1/+2
| | | | | | | | | | | | | | Some HCI drivers will need it. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Export nfc_hci_result_to_errno as it can be needed by HCI driversEric Lapuyade2012-11-191-1/+2
| | | | | | | | | | Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Dot not dispatch HCI event received on unopened pipeEric Lapuyade2012-11-191-5/+8
| | | | | | | | | | | | | | | | A chip with pre-opened gates may send events on a gate that nobody has opened in the handset host. Discard those events. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Ignore err when chip doesn't implement HW/SW info registersEric Lapuyade2012-11-191-0/+6
| | | | | | | | | | | | | | | | | | NFC_HCI_ID_MGMT_VERSION_SW and NFC_HCI_ID_MGMT_VERSION_HW are optional registers for gate NFC_HCI_ID_MGMT_GATE in standard HCI. When chip doesn't implement, just leave all the information as zeros. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Fix hci_connect_gate() when a pre-opened pipe is passedEric Lapuyade2012-11-191-2/+2
| | | | | | | | | | | | | | | | | | | | In some cases, pre-opened pipes don't stay open when a clear all pipes command is sent. They stay created however. Therefore, one can never assume that such a pipe is already open. As re-opening a pipe seems not to be a problem, we do that now. Signed-off-by: Eric Lapuyade <eric.lapuyade@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Extend netlink interface for LTO, RW, and MIUX parameters supportThierry Escande2012-10-295-19/+174
| | | | | | | | | | | | | | | | | | | | | | | | | | NFC_CMD_LLC_GET_PARAMS: request LTO, RW, and MIUX parameters for a device NFC_CMD_LLC_SET_PARAMS: set one or more of LTO, RW, and MIUX parameters for a device. LTO must be set before the link is up otherwise -EINPROGRESS is returned. RW and MIUX can be set at anytime and will be passed in subsequent CONNECT and CC messages. If one of the passed parameters is wrong none is set and -EINVAL is returned. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Purge LLCP socket Tx queues when being disconnectedSamuel Ortiz2012-10-261-0/+31
| | | | | | | | | | | | | | | | The Tx queues are no longer valid when we receive a disconnection or when the LLCP link goes down. In the later case we also purge the entire local Tx queue. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Remove CONFIG_EXPERIMENTAL from the NCI MakefileKees Cook2012-10-261-2/+2
| | | | | | | | | | | | | | | | | | | | This config item has not carried much meaning for a while now and is almost always enabled by default. As agreed during the Linux kernel summit, remove it. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Remove CONFIG_EXPERIMENTAL from the LLCP MakefileKees Cook2012-10-261-2/+2
| | | | | | | | | | | | | | | | | | | | This config item has not carried much meaning for a while now and is almost always enabled by default. As agreed during the Linux kernel summit, remove it. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Remove CONFIG_EXPERIMENTALKees Cook2012-10-261-2/+2
| | | | | | | | | | | | | | | | | | | | This config item has not carried much meaning for a while now and is almost always enabled by default. As agreed during the Linux kernel summit, remove it. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Fix some code style and whitespace issuesSzymon Janc2012-10-268-17/+17
| | | | | | | | | | Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Use IDR library to assing NFC devices IDsSamuel Ortiz2012-10-261-7/+16
| | | | | | | | | | | | | | As a consequence the NFC device IDs won't be increasing all the time, as IDR provides the first available ID. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Return NULL when no LLCP socket for a dsap,ssap couple is foundSamuel Ortiz2012-10-261-4/+6
| | | | | | | | | | | | | | The previous code was always returning the last socket from the LLCP socket list. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Implement LLCP connection less Tx pathSamuel Ortiz2012-10-261-0/+19
| | | | | | | | | | | | | | It simply involves getting the client dsap and ssap and calling the UI frame building and sending routine. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: UI frame sending routine implementationSamuel Ortiz2012-10-262-0/+48
| | | | | | | | | | | | | | UI frames still need to follow the MIU rule, and they need to use the client passed dsap as the listening socket dsap is stuck on SDP. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Forward LLCP datagrams to userspaceSamuel Ortiz2012-10-261-1/+18
| | | | | | | | | | | | With connection less PDUs we have to send the SSAP and DSAP as well. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Handle LLCP UI framesSamuel Ortiz2012-10-262-0/+45
| | | | | | | | | | | | | | UI (Unnumbered Information) frames are used for sending data over connection less links. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Keep connection less bound sockets alive when DEP link goes downSamuel Ortiz2012-10-261-0/+10
| | | | | | | | | | | | | | | | When DEP goes down, bound cl sockets can be kept alive as there is no reason to kill a connection less server socket because the LLCP link went down. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Check for connection less sockets when looking for a service nameSamuel Ortiz2012-10-261-1/+6
| | | | | | | | | | | | Connection less server sockets will be in BOUND state, not LISTEN. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Reserve LLCP ssap when replying to an SNL frameSamuel Ortiz2012-10-261-6/+40
| | | | | | | | | | | | | | | | Replying to an SNL (Service Name Lookup) means that the other end of the link can now rely on our answer (Which is an ssap) and thus we have to reserve it. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Fix sparse warnings due to missing staticArron Wang2012-10-261-1/+1
| | | | | | | | | | Signed-off-by: Arron Wang <arron.wang@intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Fix style issues with logical operationsSzymon Janc2012-10-262-10/+10
| | | | | | | | | | | | | | Logical continuations should be on the previous line. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Fix not propagating return code in nfc_hci_clear_all_pipesSzymon Janc2012-10-261-6/+2Star
| | | | | | | | | | | | | | Return code from nfc_hci_execute_cmd was not propagated to caller. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Small nfc_hci_create_pipe refactoringSzymon Janc2012-10-261-8/+8
| | | | | | | | | | | | | | | | Check for error and return if any. This makes it easier to see what is a 'positive' function flow. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Remove unneeded LLCP function return callsSzymon Janc2012-10-261-9/+0Star
| | | | | | | | | | | | | | | | There is no need for return statement at the end of function returning void. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Remove not needed local variable in nci_set_local_general_bytesSzymon Janc2012-10-261-6/+4Star
| | | | | | | | | | | | | | | | No need for local rc variable as result of nci_request can be returned directly. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Use NFC_MAX_GT_LEN to check len in nci_set_local_general_bytesSzymon Janc2012-10-261-1/+1
| | | | | | | | | | | | | | | | | | local_gb is of size NFC_MAX_GT_LEN and len is used as index for it. Check len against this instead of NCI_MAX_PARAM_LEN before accessing local_gb. Signed-off-by: Szymon Janc <szymon.janc@tieto.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Add NFC_ATTR_RF_MODE when sending device netlink propertiesThierry Escande2012-10-261-1/+2
| | | | | | | | | | | | | | | | This is useful when getting devices to know if they're in target or initiator mode. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Set rf_mode to NFC_RF_NONE where necessaryThierry Escande2012-10-261-0/+5
| | | | | | | | | | | | | | | | rf_mode is now set to NFC_RF_NONE when a device gets allocated, when the link goes down, and when stop polling. Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
* | NFC: Initial SNL supportSamuel Ortiz2012-10-261-0/+65
| | | | | | | | | | | | | | | | | | | | SNL (Service Name Lookup) allows for LLCP peers to map service names with SAPs. This is mandatory for connection less support as peers need to get the right SAPs without sending the CONNECT frame. Here we only support the Rx part of SNL. The Tx one will be implemented when supporting connection less LLCP sockets. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>