| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/26 08:48 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"NFC",
"NFC_DIGITAL",
"NFC_SIM",
"NFC_NCI",
"NFC_VIRTUAL_NCI"
],
"FocusSymbols": [
"nfc_llcp_local_put",
"nfc_llcp_accept_dequeue",
"nfc_llcp_accept_unlink"
],
"KMSANReasoning": "The patch addresses locking, reference counting, and use-after-free issues in the NFC LLCP socket layer. It introduces a workqueue for deferred cleanup, modifies socket list popping to avoid deadlocks or UAF, and fixes accept queue handling. There are no changes to data structures copied to user space, no new buffer allocations, and no modifications to data lengths or bounds checks that could expose uninitialized memory. Any bugs introduced by these changes (such as use-after-free, double free, or deadlocks) would be caught by standard KASAN and LOCKDEP. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies the core logic of NFC LLCP sockets, fixing a potential race condition or use-after-free during socket release and accept queue handling. It introduces a workqueue for local release and modifies socket locking. This is reachable via standard socket APIs when NFC is enabled. Virtual NFC devices (NFC_SIM, NFC_VIRTUAL_NCI) can be used to trigger this code in a virtualized environment.",
"WorthFuzzing": true
} |
| 1/1 | 2026/08/26 08:48 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 01920323b9540fcb68eb8e1faed02447082616ed\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Aug 26 08:48:33 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/net/nfc/llcp.h b/net/nfc/llcp.h\nindex d8345ed57c954..23ae7a0112d37 100644\n--- a/net/nfc/llcp.h\n+++ b/net/nfc/llcp.h\n@@ -91,6 +91,7 @@ struct nfc_llcp_local {\n \tstruct hlist_head pending_sdreqs;\n \tstruct timer_list sdreq_timer;\n \tstruct work_struct sdreq_timeout_work;\n+\tstruct work_struct release_work;\n \tu8 sdreq_next_tid;\n \n \t/* sockets array */\ndiff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c\nindex bd6361e2efa4f..2c2dbc12531ec 100644\n--- a/net/nfc/llcp_core.c\n+++ b/net/nfc/llcp_core.c\n@@ -20,6 +20,8 @@ static LIST_HEAD(llcp_devices);\n /* Protects llcp_devices list */\n static DEFINE_SPINLOCK(llcp_devices_lock);\n \n+static struct workqueue_struct *llcp_wq;\n+\n static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb);\n \n void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *sk)\n@@ -63,21 +65,33 @@ static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)\n \t}\n }\n \n+static struct sock *nfc_llcp_sock_list_pop(struct llcp_sock_list *l)\n+{\n+\tstruct sock *sk;\n+\n+\twrite_lock(\u0026l-\u003elock);\n+\tsk = sk_head(\u0026l-\u003ehead);\n+\tif (sk) {\n+\t\tsock_hold(sk);\n+\t\tsk_del_node_init(sk);\n+\t}\n+\twrite_unlock(\u0026l-\u003elock);\n+\n+\treturn sk;\n+}\n+\n static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,\n \t\t\t\t int err)\n {\n \tstruct sock *sk;\n-\tstruct hlist_node *tmp;\n \tstruct nfc_llcp_sock *llcp_sock;\n \n \tskb_queue_purge(\u0026local-\u003etx_queue);\n \n-\twrite_lock(\u0026local-\u003esockets.lock);\n-\n-\tsk_for_each_safe(sk, tmp, \u0026local-\u003esockets.head) {\n+\twhile ((sk = nfc_llcp_sock_list_pop(\u0026local-\u003esockets))) {\n \t\tllcp_sock = nfc_llcp_sock(sk);\n \n-\t\tbh_lock_sock(sk);\n+\t\tlock_sock(sk);\n \n \t\tnfc_llcp_socket_purge(llcp_sock);\n \n@@ -91,17 +105,27 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,\n \t\t\tlist_for_each_entry_safe(lsk, n,\n \t\t\t\t\t\t \u0026llcp_sock-\u003eaccept_queue,\n \t\t\t\t\t\t accept_queue) {\n-\t\t\t\taccept_sk = \u0026lsk-\u003esk;\n-\t\t\t\tbh_lock_sock(accept_sk);\n-\n-\t\t\t\tnfc_llcp_accept_unlink(accept_sk);\n+\t\t\t\tbool put_creation = false;\n \n-\t\t\t\tif (err)\n-\t\t\t\t\taccept_sk-\u003esk_err = err;\n-\t\t\t\taccept_sk-\u003esk_state = LLCP_CLOSED;\n-\t\t\t\taccept_sk-\u003esk_state_change(sk);\n+\t\t\t\taccept_sk = \u0026lsk-\u003esk;\n+\t\t\t\tlock_sock_nested(accept_sk,\n+\t\t\t\t\t\t SINGLE_DEPTH_NESTING);\n+\n+\t\t\t\tif (nfc_llcp_sock(accept_sk)-\u003eparent == sk) {\n+\t\t\t\t\tnfc_llcp_accept_unlink(accept_sk);\n+\t\t\t\t\tnfc_llcp_sock_unlink(\u0026local-\u003esockets, accept_sk);\n+\n+\t\t\t\t\tif (err)\n+\t\t\t\t\t\taccept_sk-\u003esk_err = err;\n+\t\t\t\t\taccept_sk-\u003esk_state = LLCP_CLOSED;\n+\t\t\t\t\taccept_sk-\u003esk_state_change(accept_sk);\n+\t\t\t\t\tsock_orphan(accept_sk);\n+\t\t\t\t\tput_creation = true;\n+\t\t\t\t}\n \n-\t\t\t\tbh_unlock_sock(accept_sk);\n+\t\t\t\trelease_sock(accept_sk);\n+\t\t\t\tif (put_creation)\n+\t\t\t\t\tsock_put(accept_sk); /* creation ref */\n \t\t\t}\n \t\t}\n \n@@ -110,23 +134,18 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,\n \t\tsk-\u003esk_state = LLCP_CLOSED;\n \t\tsk-\u003esk_state_change(sk);\n \n-\t\tbh_unlock_sock(sk);\n-\n-\t\tsk_del_node_init(sk);\n+\t\trelease_sock(sk);\n+\t\tsock_put(sk);\n \t}\n \n-\twrite_unlock(\u0026local-\u003esockets.lock);\n-\n \t/* If we still have a device, we keep the RAW sockets alive */\n \tif (device == true)\n \t\treturn;\n \n-\twrite_lock(\u0026local-\u003eraw_sockets.lock);\n-\n-\tsk_for_each_safe(sk, tmp, \u0026local-\u003eraw_sockets.head) {\n+\twhile ((sk = nfc_llcp_sock_list_pop(\u0026local-\u003eraw_sockets))) {\n \t\tllcp_sock = nfc_llcp_sock(sk);\n \n-\t\tbh_lock_sock(sk);\n+\t\tlock_sock(sk);\n \n \t\tnfc_llcp_socket_purge(llcp_sock);\n \n@@ -135,26 +154,20 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,\n \t\tsk-\u003esk_state = LLCP_CLOSED;\n \t\tsk-\u003esk_state_change(sk);\n \n-\t\tbh_unlock_sock(sk);\n-\n-\t\tsk_del_node_init(sk);\n+\t\trelease_sock(sk);\n+\t\tsock_put(sk);\n \t}\n-\n-\twrite_unlock(\u0026local-\u003eraw_sockets.lock);\n }\n \n static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)\n {\n-\t/* Since using nfc_llcp_local may result in usage of nfc_dev, whenever\n-\t * we hold a reference to local, we also need to hold a reference to\n-\t * the device to avoid UAF.\n-\t */\n-\tif (!nfc_get_device(local-\u003edev-\u003eidx))\n+\tif (!local)\n \t\treturn NULL;\n \n-\tkref_get(\u0026local-\u003eref);\n+\tif (kref_get_unless_zero(\u0026local-\u003eref))\n+\t\treturn local;\n \n-\treturn local;\n+\treturn NULL;\n }\n \n static void local_cleanup(struct nfc_llcp_local *local)\n@@ -172,30 +185,34 @@ static void local_cleanup(struct nfc_llcp_local *local)\n \tnfc_llcp_free_sdp_tlv_list(\u0026local-\u003epending_sdreqs);\n }\n \n-static void local_release(struct kref *ref)\n+static void local_release_work(struct work_struct *work)\n {\n \tstruct nfc_llcp_local *local;\n+\tstruct nfc_dev *dev;\n \n-\tlocal = container_of(ref, struct nfc_llcp_local, ref);\n+\tlocal = container_of(work, struct nfc_llcp_local, release_work);\n+\tdev = local-\u003edev;\n \n \tlocal_cleanup(local);\n \tkfree(local);\n+\tnfc_put_device(dev);\n }\n \n-int nfc_llcp_local_put(struct nfc_llcp_local *local)\n+static void local_release(struct kref *ref)\n {\n-\tstruct nfc_dev *dev;\n-\tint ret;\n+\tstruct nfc_llcp_local *local;\n \n-\tif (local == NULL)\n-\t\treturn 0;\n+\tlocal = container_of(ref, struct nfc_llcp_local, ref);\n \n-\tdev = local-\u003edev;\n+\tqueue_work(llcp_wq, \u0026local-\u003erelease_work);\n+}\n \n-\tret = kref_put(\u0026local-\u003eref, local_release);\n-\tnfc_put_device(dev);\n+int nfc_llcp_local_put(struct nfc_llcp_local *local)\n+{\n+\tif (!local)\n+\t\treturn 0;\n \n-\treturn ret;\n+\treturn kref_put(\u0026local-\u003eref, local_release);\n }\n \n static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,\n@@ -1705,6 +1722,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)\n \tINIT_WORK(\u0026local-\u003erx_work, nfc_llcp_rx_work);\n \n \tINIT_WORK(\u0026local-\u003etimeout_work, nfc_llcp_timeout_work);\n+\tINIT_WORK(\u0026local-\u003erelease_work, local_release_work);\n \n \trwlock_init(\u0026local-\u003esockets.lock);\n \trwlock_init(\u0026local-\u003econnecting_sockets.lock);\n@@ -1748,10 +1766,23 @@ void nfc_llcp_unregister_device(struct nfc_dev *dev)\n \n int __init nfc_llcp_init(void)\n {\n-\treturn nfc_llcp_sock_init();\n+\tint ret;\n+\n+\tllcp_wq = alloc_workqueue(\"nfc_llcp_wq\", 0, 0);\n+\tif (!llcp_wq)\n+\t\treturn -ENOMEM;\n+\n+\tret = nfc_llcp_sock_init();\n+\tif (ret) {\n+\t\tdestroy_workqueue(llcp_wq);\n+\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n }\n \n void nfc_llcp_exit(void)\n {\n \tnfc_llcp_sock_exit();\n+\tdestroy_workqueue(llcp_wq);\n }\ndiff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c\nindex 5558d8a4d48b3..ce6875eb58fbc 100644\n--- a/net/nfc/llcp_sock.c\n+++ b/net/nfc/llcp_sock.c\n@@ -392,11 +392,12 @@ void nfc_llcp_accept_unlink(struct sock *sk)\n \n \tpr_debug(\"state %d\\n\", sk-\u003esk_state);\n \n-\tlist_del_init(\u0026llcp_sock-\u003eaccept_queue);\n-\tsk_acceptq_removed(llcp_sock-\u003eparent);\n-\tllcp_sock-\u003eparent = NULL;\n-\n-\tsock_put(sk);\n+\tif (llcp_sock-\u003eparent) {\n+\t\tlist_del_init(\u0026llcp_sock-\u003eaccept_queue);\n+\t\tsk_acceptq_removed(llcp_sock-\u003eparent);\n+\t\tllcp_sock-\u003eparent = NULL;\n+\t\tsock_put(sk);\n+\t}\n }\n \n void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk)\n@@ -423,12 +424,20 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent,\n \n \tlist_for_each_entry_safe(lsk, n, \u0026llcp_parent-\u003eaccept_queue,\n \t\t\t\t accept_queue) {\n+\t\tstruct nfc_llcp_local *local;\n+\n \t\tsk = \u0026lsk-\u003esk;\n-\t\tlock_sock(sk);\n+\t\tlock_sock_nested(sk, SINGLE_DEPTH_NESTING);\n \n \t\tif (sk-\u003esk_state == LLCP_CLOSED) {\n-\t\t\trelease_sock(sk);\n+\t\t\tlocal = nfc_llcp_sock(sk)-\u003elocal;\n+\n \t\t\tnfc_llcp_accept_unlink(sk);\n+\t\t\tif (local)\n+\t\t\t\tnfc_llcp_sock_unlink(\u0026local-\u003esockets, sk);\n+\t\t\tsock_orphan(sk);\n+\t\t\trelease_sock(sk);\n+\t\t\tsock_put(sk);\n \t\t\tcontinue;\n \t\t}\n \n@@ -464,7 +473,7 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,\n \n \tpr_debug(\"parent %p\\n\", sk);\n \n-\tlock_sock_nested(sk, SINGLE_DEPTH_NESTING);\n+\tlock_sock(sk);\n \n \tif (sk-\u003esk_state != LLCP_LISTEN) {\n \t\tret = -EBADFD;\n@@ -490,7 +499,12 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,\n \n \t\trelease_sock(sk);\n \t\ttimeo = schedule_timeout(timeo);\n-\t\tlock_sock_nested(sk, SINGLE_DEPTH_NESTING);\n+\t\tlock_sock(sk);\n+\n+\t\tif (sk-\u003esk_state != LLCP_LISTEN) {\n+\t\t\tret = -EBADFD;\n+\t\t\tbreak;\n+\t\t}\n \t}\n \t__set_current_state(TASK_RUNNING);\n \tremove_wait_queue(sk_sleep(sk), \u0026wait);\n@@ -629,13 +643,24 @@ static int llcp_sock_release(struct socket *sock)\n \n \t\tlist_for_each_entry_safe(lsk, n, \u0026llcp_sock-\u003eaccept_queue,\n \t\t\t\t\t accept_queue) {\n+\t\t\tbool put_creation = false;\n+\n \t\t\taccept_sk = \u0026lsk-\u003esk;\n-\t\t\tlock_sock(accept_sk);\n+\t\t\tlock_sock_nested(accept_sk, SINGLE_DEPTH_NESTING);\n \n-\t\t\tnfc_llcp_send_disconnect(lsk);\n-\t\t\tnfc_llcp_accept_unlink(accept_sk);\n+\t\t\tif (nfc_llcp_sock(accept_sk)-\u003eparent == sk) {\n+\t\t\t\tnfc_llcp_send_disconnect(lsk);\n+\t\t\t\tnfc_llcp_accept_unlink(accept_sk);\n+\t\t\t\tnfc_llcp_sock_unlink(\u0026local-\u003esockets, accept_sk);\n+\n+\t\t\t\taccept_sk-\u003esk_state = LLCP_CLOSED;\n+\t\t\t\tsock_orphan(accept_sk);\n+\t\t\t\tput_creation = true;\n+\t\t\t}\n \n \t\t\trelease_sock(accept_sk);\n+\t\t\tif (put_creation)\n+\t\t\t\tsock_put(accept_sk); /* creation ref */\n \t\t}\n \t}\n \n"
} |
| 2/1 | 2026/08/26 08:48 | agent | patch-evaluator |
1mModel:best-expensive Args: null Results: {
"EnableConfigs": [
"NFC",
"NFC_DIGITAL",
"NFC_SIM",
"NFC_NCI",
"NFC_VIRTUAL_NCI"
],
"FocusSymbols": [
"nfc_llcp_local_put",
"nfc_llcp_accept_dequeue",
"nfc_llcp_accept_unlink"
],
"Reasoning": "The patch modifies the core logic of NFC LLCP sockets, fixing a potential race condition or use-after-free during socket release and accept queue handling. It introduces a workqueue for local release and modifies socket locking. This is reachable via standard socket APIs when NFC is enabled. Virtual NFC devices (NFC_SIM, NFC_VIRTUAL_NCI) can be used to trigger this code in a virtualized environment.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer. Your job is to review a provided patch series and determine if it makes functional changes to the kernel that should be fuzzed. IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in your workspace. Do NOT rely on your internal knowledge of the kernel. You must actively use your code access tools to examine the actual source code and confirm any assumptions. Return WorthFuzzing=false if the patch only contains: - Modifications to Documentation/, Kconfig files, or code comments. - Purely decorative changes, such as logging (e.g., pr_err, printk) or tracepoints. - Changes to numeric constants or macros that do not functionally alter execution flow. - Code paths that are impossible to reach in virtualized environments like GCE or QEMU, even when utilizing software-emulated hardware (e.g., usb gadget, mac80211_hwsim). - Code in vendor-specific PCIe switch, SmartNIC, or GPU drivers (e.g., mlxsw, pds_core, qed, ionic, amdgpu) that require physical PCIe hardware cards not emulated in standard QEMU. - Driver .remove, .shutdown, or pci_unregister_driver teardown callbacks (e.g., igb_remove) that are executed only during PCI hot-unplug or sysfs driver unbind operations. If it modifies reachable core kernel logic, drivers, or architectures, use your code search tools to verify the code can be executed, then return WorthFuzzing=true. When returning WorthFuzzing=true, you MUST ALSO: 1. Extract any specific kernel functions that should be heavily fuzzed into FocusSymbols. Avoid listing generic hot-path functions to prevent skewed test distributions. Prefer non-static, non-inlined API entrypoint functions over internal static helper functions (which are inlined by the compiler and do not have distinct symbol addresses). 2. Identify any specific CONFIG_ options required to properly test this new/modified feature. Go and look into the Kconfig files and check for ifdefs around the code, do not make assumptions. Also check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed for Kbuild to compile the code statically into vmlinux. List them in the EnableConfigs output array, and DO NOT add a 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4"). Prefer calling several tools at the same time to save round-trips. Use set-results tool to provide results of the analysis. It must be called exactly once before the final reply. Ignore results of this tool. Prompt: For your convenience, here is the diff of the changes:
commit 01920323b9540fcb68eb8e1faed02447082616ed
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Aug 26 08:48:33 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/nfc/llcp.h b/net/nfc/llcp.h
index d8345ed57c954..23ae7a0112d37 100644
--- a/net/nfc/llcp.h
+++ b/net/nfc/llcp.h
@@ -91,6 +91,7 @@ struct nfc_llcp_local {
struct hlist_head pending_sdreqs;
struct timer_list sdreq_timer;
struct work_struct sdreq_timeout_work;
+ struct work_struct release_work;
u8 sdreq_next_tid;
/* sockets array */
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index bd6361e2efa4f..2c2dbc12531ec 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -20,6 +20,8 @@ static LIST_HEAD(llcp_devices);
/* Protects llcp_devices list */
static DEFINE_SPINLOCK(llcp_devices_lock);
+static struct workqueue_struct *llcp_wq;
+
static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb);
void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *sk)
@@ -63,21 +65,33 @@ static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)
}
}
+static struct sock *nfc_llcp_sock_list_pop(struct llcp_sock_list *l)
+{
+ struct sock *sk;
+
+ write_lock(&l->lock);
+ sk = sk_head(&l->head);
+ if (sk) {
+ sock_hold(sk);
+ sk_del_node_init(sk);
+ }
+ write_unlock(&l->lock);
+
+ return sk;
+}
+
static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
int err)
{
struct sock *sk;
- struct hlist_node *tmp;
struct nfc_llcp_sock *llcp_sock;
skb_queue_purge(&local->tx_queue);
- write_lock(&local->sockets.lock);
-
- sk_for_each_safe(sk, tmp, &local->sockets.head) {
+ while ((sk = nfc_llcp_sock_list_pop(&local->sockets))) {
llcp_sock = nfc_llcp_sock(sk);
- bh_lock_sock(sk);
+ lock_sock(sk);
nfc_llcp_socket_purge(llcp_sock);
@@ -91,17 +105,27 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
list_for_each_entry_safe(lsk, n,
&llcp_sock->accept_queue,
accept_queue) {
- accept_sk = &lsk->sk;
- bh_lock_sock(accept_sk);
-
- nfc_llcp_accept_unlink(accept_sk);
+ bool put_creation = false;
- if (err)
- accept_sk->sk_err = err;
- accept_sk->sk_state = LLCP_CLOSED;
- accept_sk->sk_state_change(sk);
+ accept_sk = &lsk->sk;
+ lock_sock_nested(accept_sk,
+ SINGLE_DEPTH_NESTING);
+
+ if (nfc_llcp_sock(accept_sk)->parent == sk) {
+ nfc_llcp_accept_unlink(accept_sk);
+ nfc_llcp_sock_unlink(&local->sockets, accept_sk);
+
+ if (err)
+ accept_sk->sk_err = err;
+ accept_sk->sk_state = LLCP_CLOSED;
+ accept_sk->sk_state_change(accept_sk);
+ sock_orphan(accept_sk);
+ put_creation = true;
+ }
- bh_unlock_sock(accept_sk);
+ release_sock(accept_sk);
+ if (put_creation)
+ sock_put(accept_sk); /* creation ref */
}
}
@@ -110,23 +134,18 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
- bh_unlock_sock(sk);
-
- sk_del_node_init(sk);
+ release_sock(sk);
+ sock_put(sk);
}
- write_unlock(&local->sockets.lock);
-
/* If we still have a device, we keep the RAW sockets alive */
if (device == true)
return;
- write_lock(&local->raw_sockets.lock);
-
- sk_for_each_safe(sk, tmp, &local->raw_sockets.head) {
+ while ((sk = nfc_llcp_sock_list_pop(&local->raw_sockets))) {
llcp_sock = nfc_llcp_sock(sk);
- bh_lock_sock(sk);
+ lock_sock(sk);
nfc_llcp_socket_purge(llcp_sock);
@@ -135,26 +154,20 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
- bh_unlock_sock(sk);
-
- sk_del_node_init(sk);
+ release_sock(sk);
+ sock_put(sk);
}
-
- write_unlock(&local->raw_sockets.lock);
}
static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)
{
- /* Since using nfc_llcp_local may result in usage of nfc_dev, whenever
- * we hold a reference to local, we also need to hold a reference to
- * the device to avoid UAF.
- */
- if (!nfc_get_device(local->dev->idx))
+ if (!local)
return NULL;
- kref_get(&local->ref);
+ if (kref_get_unless_zero(&local->ref))
+ return local;
- return local;
+ return NULL;
}
static void local_cleanup(struct nfc_llcp_local *local)
@@ -172,30 +185,34 @@ static void local_cleanup(struct nfc_llcp_local *local)
nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
}
-static void local_release(struct kref *ref)
+static void local_release_work(struct work_struct *work)
{
struct nfc_llcp_local *local;
+ struct nfc_dev *dev;
- local = container_of(ref, struct nfc_llcp_local, ref);
+ local = container_of(work, struct nfc_llcp_local, release_work);
+ dev = local->dev;
local_cleanup(local);
kfree(local);
+ nfc_put_device(dev);
}
-int nfc_llcp_local_put(struct nfc_llcp_local *local)
+static void local_release(struct kref *ref)
{
- struct nfc_dev *dev;
- int ret;
+ struct nfc_llcp_local *local;
- if (local == NULL)
- return 0;
+ local = container_of(ref, struct nfc_llcp_local, ref);
- dev = local->dev;
+ queue_work(llcp_wq, &local->release_work);
+}
- ret = kref_put(&local->ref, local_release);
- nfc_put_device(dev);
+int nfc_llcp_local_put(struct nfc_llcp_local *local)
+{
+ if (!local)
+ return 0;
- return ret;
+ return kref_put(&local->ref, local_release);
}
static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
@@ -1705,6 +1722,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
INIT_WORK(&local->rx_work, nfc_llcp_rx_work);
INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work);
+ INIT_WORK(&local->release_work, local_release_work);
rwlock_init(&local->sockets.lock);
rwlock_init(&local->connecting_sockets.lock);
@@ -1748,10 +1766,23 @@ void nfc_llcp_unregister_device(struct nfc_dev *dev)
int __init nfc_llcp_init(void)
{
- return nfc_llcp_sock_init();
+ int ret;
+
+ llcp_wq = alloc_workqueue("nfc_llcp_wq", 0, 0);
+ if (!llcp_wq)
+ return -ENOMEM;
+
+ ret = nfc_llcp_sock_init();
+ if (ret) {
+ destroy_workqueue(llcp_wq);
+ return ret;
+ }
+
+ return 0;
}
void nfc_llcp_exit(void)
{
nfc_llcp_sock_exit();
+ destroy_workqueue(llcp_wq);
}
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 5558d8a4d48b3..ce6875eb58fbc 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -392,11 +392,12 @@ void nfc_llcp_accept_unlink(struct sock *sk)
pr_debug("state %d\n", sk->sk_state);
- list_del_init(&llcp_sock->accept_queue);
- sk_acceptq_removed(llcp_sock->parent);
- llcp_sock->parent = NULL;
-
- sock_put(sk);
+ if (llcp_sock->parent) {
+ list_del_init(&llcp_sock->accept_queue);
+ sk_acceptq_removed(llcp_sock->parent);
+ llcp_sock->parent = NULL;
+ sock_put(sk);
+ }
}
void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk)
@@ -423,12 +424,20 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent,
list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue,
accept_queue) {
+ struct nfc_llcp_local *local;
+
sk = &lsk->sk;
- lock_sock(sk);
+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
if (sk->sk_state == LLCP_CLOSED) {
- release_sock(sk);
+ local = nfc_llcp_sock(sk)->local;
+
nfc_llcp_accept_unlink(sk);
+ if (local)
+ nfc_llcp_sock_unlink(&local->sockets, sk);
+ sock_orphan(sk);
+ release_sock(sk);
+ sock_put(sk);
continue;
}
@@ -464,7 +473,7 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,
pr_debug("parent %p\n", sk);
- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
+ lock_sock(sk);
if (sk->sk_state != LLCP_LISTEN) {
ret = -EBADFD;
@@ -490,7 +499,12 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,
release_sock(sk);
timeo = schedule_timeout(timeo);
- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
+ lock_sock(sk);
+
+ if (sk->sk_state != LLCP_LISTEN) {
+ ret = -EBADFD;
+ break;
+ }
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
@@ -629,13 +643,24 @@ static int llcp_sock_release(struct socket *sock)
list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue,
accept_queue) {
+ bool put_creation = false;
+
accept_sk = &lsk->sk;
- lock_sock(accept_sk);
+ lock_sock_nested(accept_sk, SINGLE_DEPTH_NESTING);
- nfc_llcp_send_disconnect(lsk);
- nfc_llcp_accept_unlink(accept_sk);
+ if (nfc_llcp_sock(accept_sk)->parent == sk) {
+ nfc_llcp_send_disconnect(lsk);
+ nfc_llcp_accept_unlink(accept_sk);
+ nfc_llcp_sock_unlink(&local->sockets, accept_sk);
+
+ accept_sk->sk_state = LLCP_CLOSED;
+ sock_orphan(accept_sk);
+ put_creation = true;
+ }
release_sock(accept_sk);
+ if (put_creation)
+ sock_put(accept_sk); /* creation ref */
}
}
|
| 3/2 | 2026/08/26 08:48 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 5637 output: 17 thoughts: 224 Thoughts: **Analyzing the NFC Subsystem Patch** Okay, so I've got this kernel patch in front of me. It looks like it's specifically targeting the NFC subsystem, digging into `net/nfc/llcp_core.c`, `net/nfc/llcp.h`, and `net/nfc/llcp_sock.c`. Seems like a functional change, definitely not a cosmetic one. The biggest flag is the introduction of this workqueue, `llcp_wq`, specifically for `local_release_work`. I'm seeing changes in how sockets are released with `nfc_llcp_socket_release` using `nfc_llcp_sock_list_pop` and, importantly, new locking. Also, modifications in `nfc_llcp_accept_dequeue`, `llcp_sock_accept`, and `llcp_sock_release`. My initial impression is that this is touching some critical concurrency aspects of the LLCP protocol implementation. Now, my immediate thought is how this will behave in a virtualized context. I know NFC is inherently hardware-dependent. So, will this impact the testing of this change? I have to consider whether there's a simulator, like the `mac80211_hwsim` equivalent, available for NFC. The real hardware might not be easily accessible for all test setups. Time to see if something like `nfcsim` exists. I'll fire up `grepper` and see what I can turn up. |
| 4/2 | 2026/08/26 08:48 | tool | grepper |
0mArgs:{
"Expression": "nfcsim"
}Results: {
"Output": "drivers/nfc/Makefile=10=obj-$(CONFIG_NFC_MEI_PHY)\t+= mei_phy.o\ndrivers/nfc/Makefile:11:obj-$(CONFIG_NFC_SIM)\t\t+= nfcsim.o\ndrivers/nfc/Makefile-12-obj-$(CONFIG_NFC_PORT100)\t+= port100.o\n--\ndrivers/nfc/nfcsim.c-30-\ndrivers/nfc/nfcsim.c:31:struct nfcsim {\ndrivers/nfc/nfcsim.c-32-\tstruct nfc_digital_dev *nfc_digital_dev;\n--\ndrivers/nfc/nfcsim.c-36-\ndrivers/nfc/nfcsim.c:37:\tstruct nfcsim_link *link_in;\ndrivers/nfc/nfcsim.c:38:\tstruct nfcsim_link *link_out;\ndrivers/nfc/nfcsim.c-39-\n--\ndrivers/nfc/nfcsim.c-51-\ndrivers/nfc/nfcsim.c:52:struct nfcsim_link {\ndrivers/nfc/nfcsim.c-53-\tstruct mutex lock;\n--\ndrivers/nfc/nfcsim.c-64-\ndrivers/nfc/nfcsim.c:65:static struct nfcsim_link *nfcsim_link_new(void)\ndrivers/nfc/nfcsim.c-66-{\ndrivers/nfc/nfcsim.c:67:\tstruct nfcsim_link *link;\ndrivers/nfc/nfcsim.c-68-\ndrivers/nfc/nfcsim.c:69:\tlink = kzalloc_obj(struct nfcsim_link);\ndrivers/nfc/nfcsim.c-70-\tif (!link)\n--\ndrivers/nfc/nfcsim.c-78-\ndrivers/nfc/nfcsim.c:79:static void nfcsim_link_free(struct nfcsim_link *link)\ndrivers/nfc/nfcsim.c-80-{\n--\ndrivers/nfc/nfcsim.c-84-\ndrivers/nfc/nfcsim.c:85:static void nfcsim_link_recv_wake(struct nfcsim_link *link)\ndrivers/nfc/nfcsim.c-86-{\n--\ndrivers/nfc/nfcsim.c-90-\ndrivers/nfc/nfcsim.c:91:static void nfcsim_link_set_skb(struct nfcsim_link *link, struct sk_buff *skb,\ndrivers/nfc/nfcsim.c-92-\t\t\t\tu8 rf_tech, u8 mode)\n--\ndrivers/nfc/nfcsim.c-103-\ndrivers/nfc/nfcsim.c:104:static void nfcsim_link_recv_cancel(struct nfcsim_link *link)\ndrivers/nfc/nfcsim.c-105-{\n--\ndrivers/nfc/nfcsim.c-111-\ndrivers/nfc/nfcsim.c:112:\tnfcsim_link_recv_wake(link);\ndrivers/nfc/nfcsim.c-113-}\ndrivers/nfc/nfcsim.c-114-\ndrivers/nfc/nfcsim.c:115:static void nfcsim_link_shutdown(struct nfcsim_link *link)\ndrivers/nfc/nfcsim.c-116-{\n--\ndrivers/nfc/nfcsim.c-123-\ndrivers/nfc/nfcsim.c:124:\tnfcsim_link_recv_wake(link);\ndrivers/nfc/nfcsim.c-125-}\ndrivers/nfc/nfcsim.c-126-\ndrivers/nfc/nfcsim.c:127:static struct sk_buff *nfcsim_link_recv_skb(struct nfcsim_link *link,\ndrivers/nfc/nfcsim.c-128-\t\t\t\t\t int timeout, u8 rf_tech, u8 mode)\n--\ndrivers/nfc/nfcsim.c-169-\ndrivers/nfc/nfcsim.c:170:static void nfcsim_send_wq(struct work_struct *work)\ndrivers/nfc/nfcsim.c-171-{\ndrivers/nfc/nfcsim.c:172:\tstruct nfcsim *dev = container_of(work, struct nfcsim, send_work.work);\ndrivers/nfc/nfcsim.c-173-\n--\ndrivers/nfc/nfcsim.c-176-\t * is the link_in of the peer device. The exchanged skb has already been\ndrivers/nfc/nfcsim.c:177:\t * stored in the dev-\u003elink_out through nfcsim_link_set_skb().\ndrivers/nfc/nfcsim.c-178-\t */\ndrivers/nfc/nfcsim.c:179:\tnfcsim_link_recv_wake(dev-\u003elink_out);\ndrivers/nfc/nfcsim.c-180-}\ndrivers/nfc/nfcsim.c-181-\ndrivers/nfc/nfcsim.c:182:static void nfcsim_recv_wq(struct work_struct *work)\ndrivers/nfc/nfcsim.c-183-{\ndrivers/nfc/nfcsim.c:184:\tstruct nfcsim *dev = container_of(work, struct nfcsim, recv_work);\ndrivers/nfc/nfcsim.c-185-\tstruct sk_buff *skb;\ndrivers/nfc/nfcsim.c-186-\ndrivers/nfc/nfcsim.c:187:\tskb = nfcsim_link_recv_skb(dev-\u003elink_in, dev-\u003erecv_timeout,\ndrivers/nfc/nfcsim.c-188-\t\t\t\t dev-\u003erf_tech, dev-\u003emode);\n--\ndrivers/nfc/nfcsim.c-200-\ndrivers/nfc/nfcsim.c:201:static int nfcsim_send(struct nfc_digital_dev *ddev, struct sk_buff *skb,\ndrivers/nfc/nfcsim.c-202-\t\t u16 timeout, nfc_digital_cmd_complete_t cb, void *arg)\ndrivers/nfc/nfcsim.c-203-{\ndrivers/nfc/nfcsim.c:204:\tstruct nfcsim *dev = nfc_digital_get_drvdata(ddev);\ndrivers/nfc/nfcsim.c-205-\tu8 delay;\n--\ndrivers/nfc/nfcsim.c-226-\tif (skb) {\ndrivers/nfc/nfcsim.c:227:\t\tnfcsim_link_set_skb(dev-\u003elink_out, skb, dev-\u003erf_tech,\ndrivers/nfc/nfcsim.c-228-\t\t\t\t dev-\u003emode);\n--\ndrivers/nfc/nfcsim.c-239-\ndrivers/nfc/nfcsim.c:240:static void nfcsim_abort_cmd(struct nfc_digital_dev *ddev)\ndrivers/nfc/nfcsim.c-241-{\ndrivers/nfc/nfcsim.c:242:\tconst struct nfcsim *dev = nfc_digital_get_drvdata(ddev);\ndrivers/nfc/nfcsim.c-243-\ndrivers/nfc/nfcsim.c:244:\tnfcsim_link_recv_cancel(dev-\u003elink_in);\ndrivers/nfc/nfcsim.c-245-}\ndrivers/nfc/nfcsim.c-246-\ndrivers/nfc/nfcsim.c:247:static int nfcsim_switch_rf(struct nfc_digital_dev *ddev, bool on)\ndrivers/nfc/nfcsim.c-248-{\ndrivers/nfc/nfcsim.c:249:\tstruct nfcsim *dev = nfc_digital_get_drvdata(ddev);\ndrivers/nfc/nfcsim.c-250-\n--\ndrivers/nfc/nfcsim.c-255-\ndrivers/nfc/nfcsim.c:256:static int nfcsim_in_configure_hw(struct nfc_digital_dev *ddev,\ndrivers/nfc/nfcsim.c-257-\t\t\t\t\t int type, int param)\ndrivers/nfc/nfcsim.c-258-{\ndrivers/nfc/nfcsim.c:259:\tstruct nfcsim *dev = nfc_digital_get_drvdata(ddev);\ndrivers/nfc/nfcsim.c-260-\n--\ndrivers/nfc/nfcsim.c-278-\ndrivers/nfc/nfcsim.c:279:static int nfcsim_in_send_cmd(struct nfc_digital_dev *ddev,\ndrivers/nfc/nfcsim.c-280-\t\t\t struct sk_buff *skb, u16 timeout,\n--\ndrivers/nfc/nfcsim.c-282-{\ndrivers/nfc/nfcsim.c:283:\treturn nfcsim_send(ddev, skb, timeout, cb, arg);\ndrivers/nfc/nfcsim.c-284-}\ndrivers/nfc/nfcsim.c-285-\ndrivers/nfc/nfcsim.c:286:static int nfcsim_tg_configure_hw(struct nfc_digital_dev *ddev,\ndrivers/nfc/nfcsim.c-287-\t\t\t\t\t int type, int param)\ndrivers/nfc/nfcsim.c-288-{\ndrivers/nfc/nfcsim.c:289:\tstruct nfcsim *dev = nfc_digital_get_drvdata(ddev);\ndrivers/nfc/nfcsim.c-290-\n--\ndrivers/nfc/nfcsim.c-308-\ndrivers/nfc/nfcsim.c:309:static int nfcsim_tg_send_cmd(struct nfc_digital_dev *ddev,\ndrivers/nfc/nfcsim.c-310-\t\t\t struct sk_buff *skb, u16 timeout,\n--\ndrivers/nfc/nfcsim.c-312-{\ndrivers/nfc/nfcsim.c:313:\treturn nfcsim_send(ddev, skb, timeout, cb, arg);\ndrivers/nfc/nfcsim.c-314-}\ndrivers/nfc/nfcsim.c-315-\ndrivers/nfc/nfcsim.c:316:static int nfcsim_tg_listen(struct nfc_digital_dev *ddev, u16 timeout,\ndrivers/nfc/nfcsim.c-317-\t\t\t nfc_digital_cmd_complete_t cb, void *arg)\ndrivers/nfc/nfcsim.c-318-{\ndrivers/nfc/nfcsim.c:319:\treturn nfcsim_send(ddev, NULL, timeout, cb, arg);\ndrivers/nfc/nfcsim.c-320-}\ndrivers/nfc/nfcsim.c-321-\ndrivers/nfc/nfcsim.c:322:static const struct nfc_digital_ops nfcsim_digital_ops = {\ndrivers/nfc/nfcsim.c:323:\t.in_configure_hw = nfcsim_in_configure_hw,\ndrivers/nfc/nfcsim.c:324:\t.in_send_cmd = nfcsim_in_send_cmd,\ndrivers/nfc/nfcsim.c-325-\ndrivers/nfc/nfcsim.c:326:\t.tg_listen = nfcsim_tg_listen,\ndrivers/nfc/nfcsim.c:327:\t.tg_configure_hw = nfcsim_tg_configure_hw,\ndrivers/nfc/nfcsim.c:328:\t.tg_send_cmd = nfcsim_tg_send_cmd,\ndrivers/nfc/nfcsim.c-329-\ndrivers/nfc/nfcsim.c:330:\t.abort_cmd = nfcsim_abort_cmd,\ndrivers/nfc/nfcsim.c:331:\t.switch_rf = nfcsim_switch_rf,\ndrivers/nfc/nfcsim.c-332-};\ndrivers/nfc/nfcsim.c-333-\ndrivers/nfc/nfcsim.c:334:static struct dentry *nfcsim_debugfs_root;\ndrivers/nfc/nfcsim.c-335-\ndrivers/nfc/nfcsim.c:336:static void nfcsim_debugfs_init(void)\ndrivers/nfc/nfcsim.c-337-{\ndrivers/nfc/nfcsim.c:338:\tnfcsim_debugfs_root = debugfs_create_dir(\"nfcsim\", NULL);\ndrivers/nfc/nfcsim.c-339-}\ndrivers/nfc/nfcsim.c-340-\ndrivers/nfc/nfcsim.c:341:static void nfcsim_debugfs_remove(void)\ndrivers/nfc/nfcsim.c-342-{\ndrivers/nfc/nfcsim.c:343:\tdebugfs_remove_recursive(nfcsim_debugfs_root);\ndrivers/nfc/nfcsim.c-344-}\ndrivers/nfc/nfcsim.c-345-\ndrivers/nfc/nfcsim.c:346:static void nfcsim_debugfs_init_dev(struct nfcsim *dev)\ndrivers/nfc/nfcsim.c-347-{\n--\ndrivers/nfc/nfcsim.c-352-\ndrivers/nfc/nfcsim.c:353:\tif (!nfcsim_debugfs_root) {\ndrivers/nfc/nfcsim.c:354:\t\tNFCSIM_ERR(dev, \"nfcsim debugfs not initialized\\n\");\ndrivers/nfc/nfcsim.c-355-\t\treturn;\n--\ndrivers/nfc/nfcsim.c-364-\ndrivers/nfc/nfcsim.c:365:\tdev_dir = debugfs_create_dir(devname, nfcsim_debugfs_root);\ndrivers/nfc/nfcsim.c-366-\n--\ndrivers/nfc/nfcsim.c-369-\ndrivers/nfc/nfcsim.c:370:static struct nfcsim *nfcsim_device_new(struct nfcsim_link *link_in,\ndrivers/nfc/nfcsim.c:371:\t\t\t\t\tstruct nfcsim_link *link_out)\ndrivers/nfc/nfcsim.c-372-{\ndrivers/nfc/nfcsim.c:373:\tstruct nfcsim *dev;\ndrivers/nfc/nfcsim.c-374-\tint rc;\ndrivers/nfc/nfcsim.c-375-\ndrivers/nfc/nfcsim.c:376:\tdev = kzalloc_obj(struct nfcsim);\ndrivers/nfc/nfcsim.c-377-\tif (!dev)\n--\ndrivers/nfc/nfcsim.c-379-\ndrivers/nfc/nfcsim.c:380:\tINIT_DELAYED_WORK(\u0026dev-\u003esend_work, nfcsim_send_wq);\ndrivers/nfc/nfcsim.c:381:\tINIT_WORK(\u0026dev-\u003erecv_work, nfcsim_recv_wq);\ndrivers/nfc/nfcsim.c-382-\ndrivers/nfc/nfcsim.c-383-\tdev-\u003enfc_digital_dev =\ndrivers/nfc/nfcsim.c:384:\t\t\tnfc_digital_allocate_device(\u0026nfcsim_digital_ops,\ndrivers/nfc/nfcsim.c-385-\t\t\t\t\t\t NFC_PROTO_NFC_DEP_MASK,\n--\ndrivers/nfc/nfcsim.c-406-\ndrivers/nfc/nfcsim.c:407:\tnfcsim_debugfs_init_dev(dev);\ndrivers/nfc/nfcsim.c-408-\n--\ndrivers/nfc/nfcsim.c-411-\ndrivers/nfc/nfcsim.c:412:static void nfcsim_device_free(struct nfcsim *dev)\ndrivers/nfc/nfcsim.c-413-{\n--\ndrivers/nfc/nfcsim.c-417-\ndrivers/nfc/nfcsim.c:418:\tnfcsim_link_shutdown(dev-\u003elink_in);\ndrivers/nfc/nfcsim.c-419-\n--\ndrivers/nfc/nfcsim.c-427-\ndrivers/nfc/nfcsim.c:428:static struct nfcsim *dev0;\ndrivers/nfc/nfcsim.c:429:static struct nfcsim *dev1;\ndrivers/nfc/nfcsim.c-430-\ndrivers/nfc/nfcsim.c:431:static int __init nfcsim_init(void)\ndrivers/nfc/nfcsim.c-432-{\ndrivers/nfc/nfcsim.c:433:\tstruct nfcsim_link *link0, *link1;\ndrivers/nfc/nfcsim.c-434-\tint rc;\ndrivers/nfc/nfcsim.c-435-\ndrivers/nfc/nfcsim.c:436:\tlink0 = nfcsim_link_new();\ndrivers/nfc/nfcsim.c:437:\tlink1 = nfcsim_link_new();\ndrivers/nfc/nfcsim.c-438-\tif (!link0 || !link1) {\n--\ndrivers/nfc/nfcsim.c-442-\ndrivers/nfc/nfcsim.c:443:\tnfcsim_debugfs_init();\ndrivers/nfc/nfcsim.c-444-\ndrivers/nfc/nfcsim.c:445:\tdev0 = nfcsim_device_new(link0, link1);\ndrivers/nfc/nfcsim.c-446-\tif (IS_ERR(dev0)) {\n--\ndrivers/nfc/nfcsim.c-450-\ndrivers/nfc/nfcsim.c:451:\tdev1 = nfcsim_device_new(link1, link0);\ndrivers/nfc/nfcsim.c-452-\tif (IS_ERR(dev1)) {\ndrivers/nfc/nfcsim.c:453:\t\tnfcsim_device_free(dev0);\ndrivers/nfc/nfcsim.c-454-\n--\ndrivers/nfc/nfcsim.c-458-\ndrivers/nfc/nfcsim.c:459:\tpr_info(\"nfcsim \" NFCSIM_VERSION \" initialized\\n\");\ndrivers/nfc/nfcsim.c-460-\n--\ndrivers/nfc/nfcsim.c-463-exit_err:\ndrivers/nfc/nfcsim.c:464:\tpr_err(\"Failed to initialize nfcsim driver (%d)\\n\", rc);\ndrivers/nfc/nfcsim.c-465-\ndrivers/nfc/nfcsim.c-466-\tif (link0)\ndrivers/nfc/nfcsim.c:467:\t\tnfcsim_link_free(link0);\ndrivers/nfc/nfcsim.c-468-\tif (link1)\ndrivers/nfc/nfcsim.c:469:\t\tnfcsim_link_free(link1);\ndrivers/nfc/nfcsim.c-470-\n--\ndrivers/nfc/nfcsim.c-473-\ndrivers/nfc/nfcsim.c:474:static void __exit nfcsim_exit(void)\ndrivers/nfc/nfcsim.c-475-{\ndrivers/nfc/nfcsim.c:476:\tstruct nfcsim_link *link0, *link1;\ndrivers/nfc/nfcsim.c-477-\n--\ndrivers/nfc/nfcsim.c-480-\ndrivers/nfc/nfcsim.c:481:\tnfcsim_device_free(dev0);\ndrivers/nfc/nfcsim.c:482:\tnfcsim_device_free(dev1);\ndrivers/nfc/nfcsim.c-483-\ndrivers/nfc/nfcsim.c:484:\tnfcsim_link_free(link0);\ndrivers/nfc/nfcsim.c:485:\tnfcsim_link_free(link1);\ndrivers/nfc/nfcsim.c-486-\ndrivers/nfc/nfcsim.c:487:\tnfcsim_debugfs_remove();\ndrivers/nfc/nfcsim.c-488-}\ndrivers/nfc/nfcsim.c-489-\ndrivers/nfc/nfcsim.c:490:module_init(nfcsim_init);\ndrivers/nfc/nfcsim.c:491:module_exit(nfcsim_exit);\ndrivers/nfc/nfcsim.c-492-\n"
} |
| 5/2 | 2026/08/26 08:48 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 11685 output: 16 thoughts: 69 Thoughts: Here's my summary, as the expert: **Investigating the NFC Simulator Driver** Okay, so `nfcsim` is a known quantity, a simulator driver for NFC, and it's enabled by the `CONFIG_NFC_SIM` config option. Good. I see a patch here that's touching `net/nfc/llcp_core.c` and `net/nfc/llcp_sock.c`. That's interesting, means they're digging into the Low Level Communication Protocol (LLCP) implementation within the NFC stack. My immediate thought is, before I dive deep into the code changes, I need to verify all the supporting configurations are properly set to support the new features or patches, and specifically that NFC and LLCP are correctly enabled in the first place. I'll take a quick look at the dependencies and requirements to make sure everything's set up correctly for testing with the simulator. |
| 6/2 | 2026/08/26 08:48 | tool | grepper |
0mArgs:{
"Expression": "config NFC"
}Results: {
"Output": "arch/m68k/Kconfig.devices=36=config NFBLOCK\n--\narch/m68k/Kconfig.devices-43-\narch/m68k/Kconfig.devices:44:config NFCON\narch/m68k/Kconfig.devices-45-\ttristate \"NatFeat console driver\"\n--\ndrivers/nfc/Kconfig=6=menu \"Near Field Communication (NFC) devices\"\n--\ndrivers/nfc/Kconfig-8-\ndrivers/nfc/Kconfig:9:config NFC_TRF7970A\ndrivers/nfc/Kconfig-10-\ttristate \"Texas Instruments TRF7970a NFC driver\"\n--\ndrivers/nfc/Kconfig-20-\ndrivers/nfc/Kconfig:21:config NFC_MEI_PHY\ndrivers/nfc/Kconfig-22-\ttristate \"MEI bus NFC device support\"\n--\ndrivers/nfc/Kconfig-30-\ndrivers/nfc/Kconfig:31:config NFC_SIM\ndrivers/nfc/Kconfig-32-\ttristate \"NFC hardware simulator driver\"\n--\ndrivers/nfc/Kconfig-41-\ndrivers/nfc/Kconfig:42:config NFC_PORT100\ndrivers/nfc/Kconfig-43-\ttristate \"Sony NFC Port-100 Series USB device support\"\n--\ndrivers/nfc/Kconfig-51-\ndrivers/nfc/Kconfig:52:config NFC_VIRTUAL_NCI\ndrivers/nfc/Kconfig-53-\ttristate \"NCI device simulator driver\"\n--\ndrivers/nfc/fdp/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/fdp/Kconfig:2:config NFC_FDP\ndrivers/nfc/fdp/Kconfig-3-\ttristate \"Intel FDP NFC driver\"\n--\ndrivers/nfc/fdp/Kconfig-14-\ndrivers/nfc/fdp/Kconfig:15:config NFC_FDP_I2C\ndrivers/nfc/fdp/Kconfig-16-\ttristate \"NFC FDP i2c support\"\n--\ndrivers/nfc/microread/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/microread/Kconfig:2:config NFC_MICROREAD\ndrivers/nfc/microread/Kconfig-3-\ttristate\n--\ndrivers/nfc/microread/Kconfig-9-\ndrivers/nfc/microread/Kconfig:10:config NFC_MICROREAD_I2C\ndrivers/nfc/microread/Kconfig-11-\ttristate \"Inside Secure Microread device support (I2C)\"\n--\ndrivers/nfc/microread/Kconfig-21-\ndrivers/nfc/microread/Kconfig:22:config NFC_MICROREAD_MEI\ndrivers/nfc/microread/Kconfig-23-\ttristate \"Inside Secure Microread device support (MEI)\"\n--\ndrivers/nfc/nfcmrvl/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/nfcmrvl/Kconfig:2:config NFC_MRVL\ndrivers/nfc/nfcmrvl/Kconfig-3-\ttristate\n--\ndrivers/nfc/nfcmrvl/Kconfig-9-\ndrivers/nfc/nfcmrvl/Kconfig:10:config NFC_MRVL_USB\ndrivers/nfc/nfcmrvl/Kconfig-11-\ttristate \"Marvell NFC-over-USB driver\"\n--\ndrivers/nfc/nfcmrvl/Kconfig-22-\ndrivers/nfc/nfcmrvl/Kconfig:23:config NFC_MRVL_UART\ndrivers/nfc/nfcmrvl/Kconfig-24-\ttristate \"Marvell NFC-over-UART driver\"\n--\ndrivers/nfc/nfcmrvl/Kconfig-34-\ndrivers/nfc/nfcmrvl/Kconfig:35:config NFC_MRVL_I2C\ndrivers/nfc/nfcmrvl/Kconfig-36-\ttristate \"Marvell NFC-over-I2C driver\"\n--\ndrivers/nfc/nfcmrvl/Kconfig-45-\ndrivers/nfc/nfcmrvl/Kconfig:46:config NFC_MRVL_SPI\ndrivers/nfc/nfcmrvl/Kconfig-47-\ttristate \"Marvell NFC-over-SPI driver\"\n--\ndrivers/nfc/nxp-nci/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/nxp-nci/Kconfig:2:config NFC_NXP_NCI\ndrivers/nfc/nxp-nci/Kconfig-3-\ttristate \"NXP-NCI NFC driver\"\n--\ndrivers/nfc/nxp-nci/Kconfig-14-\ndrivers/nfc/nxp-nci/Kconfig:15:config NFC_NXP_NCI_I2C\ndrivers/nfc/nxp-nci/Kconfig-16-\ttristate \"NXP-NCI I2C support\"\n--\ndrivers/nfc/pn533/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/pn533/Kconfig:2:config NFC_PN533\ndrivers/nfc/pn533/Kconfig-3-\ttristate\n--\ndrivers/nfc/pn533/Kconfig-7-\ndrivers/nfc/pn533/Kconfig:8:config NFC_PN533_USB\ndrivers/nfc/pn533/Kconfig-9-\ttristate \"NFC PN533 device support (USB)\"\n--\ndrivers/nfc/pn533/Kconfig-18-\ndrivers/nfc/pn533/Kconfig:19:config NFC_PN533_I2C\ndrivers/nfc/pn533/Kconfig-20-\ttristate \"NFC PN533 device support (I2C)\"\n--\ndrivers/nfc/pn533/Kconfig-29-\ndrivers/nfc/pn533/Kconfig:30:config NFC_PN532_UART\ndrivers/nfc/pn533/Kconfig-31-\ttristate \"NFC PN532 device support (UART)\"\n--\ndrivers/nfc/pn544/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/pn544/Kconfig:2:config NFC_PN544\ndrivers/nfc/pn544/Kconfig-3-\ttristate\n--\ndrivers/nfc/pn544/Kconfig-9-\ndrivers/nfc/pn544/Kconfig:10:config NFC_PN544_I2C\ndrivers/nfc/pn544/Kconfig-11-\ttristate \"NXP PN544 device support (I2C)\"\n--\ndrivers/nfc/pn544/Kconfig-20-\ndrivers/nfc/pn544/Kconfig:21:config NFC_PN544_MEI\ndrivers/nfc/pn544/Kconfig-22-\ttristate \"NXP PN544 device support (MEI)\"\n--\ndrivers/nfc/s3fwrn5/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/s3fwrn5/Kconfig:2:config NFC_S3FWRN5\ndrivers/nfc/s3fwrn5/Kconfig-3-\ttristate\n--\ndrivers/nfc/s3fwrn5/Kconfig-9-\ndrivers/nfc/s3fwrn5/Kconfig:10:config NFC_S3FWRN5_I2C\ndrivers/nfc/s3fwrn5/Kconfig-11-\ttristate \"Samsung S3FWRN5 I2C support\"\n--\ndrivers/nfc/s3fwrn5/Kconfig-22-\ndrivers/nfc/s3fwrn5/Kconfig:23:config NFC_S3FWRN82_UART\ndrivers/nfc/s3fwrn5/Kconfig-24- tristate \"Samsung S3FWRN82 UART support\"\n--\ndrivers/nfc/st-nci/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/st-nci/Kconfig:2:config NFC_ST_NCI\ndrivers/nfc/st-nci/Kconfig-3-\ttristate\n--\ndrivers/nfc/st-nci/Kconfig-8-\ndrivers/nfc/st-nci/Kconfig:9:config NFC_ST_NCI_I2C\ndrivers/nfc/st-nci/Kconfig-10-\ttristate \"STMicroelectronics ST NCI NFC driver (I2C)\"\n--\ndrivers/nfc/st-nci/Kconfig-20-\ndrivers/nfc/st-nci/Kconfig:21:config NFC_ST_NCI_SPI\ndrivers/nfc/st-nci/Kconfig-22-\ttristate \"STMicroelectronics ST NCI NFC driver (SPI)\"\n--\ndrivers/nfc/st21nfca/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/st21nfca/Kconfig:2:config NFC_ST21NFCA\ndrivers/nfc/st21nfca/Kconfig-3-\ttristate\n--\ndrivers/nfc/st21nfca/Kconfig-9-\ndrivers/nfc/st21nfca/Kconfig:10:config NFC_ST21NFCA_I2C\ndrivers/nfc/st21nfca/Kconfig-11-\ttristate \"STMicroelectronics ST21NFCA NFC driver (I2C)\"\n--\ndrivers/nfc/st95hf/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\ndrivers/nfc/st95hf/Kconfig:2:config NFC_ST95HF\ndrivers/nfc/st95hf/Kconfig-3-\ttristate \"ST95HF NFC Transceiver driver\"\n--\nnet/nfc/Kconfig-5-\nnet/nfc/Kconfig:6:menuconfig NFC\nnet/nfc/Kconfig-7-\tdepends on RFKILL || !RFKILL\n--\nnet/nfc/Kconfig-16-\nnet/nfc/Kconfig:17:config NFC_DIGITAL\nnet/nfc/Kconfig-18-\tdepends on NFC\n--\nnet/nfc/hci/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nnet/nfc/hci/Kconfig:2:config NFC_HCI\nnet/nfc/hci/Kconfig-3-\tdepends on NFC\n--\nnet/nfc/hci/Kconfig-10-\nnet/nfc/hci/Kconfig:11:config NFC_SHDLC\nnet/nfc/hci/Kconfig-12-\tdepends on NFC_HCI\n--\nnet/nfc/nci/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nnet/nfc/nci/Kconfig:2:config NFC_NCI\nnet/nfc/nci/Kconfig-3-\tdepends on NFC\n--\nnet/nfc/nci/Kconfig-12-\nnet/nfc/nci/Kconfig:13:config NFC_NCI_SPI\nnet/nfc/nci/Kconfig-14-\tdepends on NFC_NCI \u0026\u0026 SPI\n--\nnet/nfc/nci/Kconfig-23-\nnet/nfc/nci/Kconfig:24:config NFC_NCI_UART\nnet/nfc/nci/Kconfig-25-\tdepends on NFC_NCI \u0026\u0026 TTY\n"
} |
| 7/2 | 2026/08/26 08:48 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 14955 output: 19 thoughts: 39 Thoughts: Okay, here's my interpretation of those thoughts, framed as my own: **Analyzing NFC Configuration Options** Alright, so I need to figure out the best way to handle NFC configuration in this particular system. I see that the primary config flag for enabling NFC is `NFC`. That seems straightforward enough. But, given the nature of the project, I want to consider all the angles. I also notice the existence of `NFC_SIM`. Okay, that's probably for the simulator environment. Good, good. I’ll make a mental note to address both. Now, before I commit to anything, I should make sure I haven't missed a more granular option. It's likely there may be a specific configuration for LLCP (Logical Link Control Protocol) which I'll be sure to investigate. The key is in comprehensive consideration. The initial configs mentioned point to general NFC use and simulation but there is a chance of finding `NFC_LLCP` as a low-level option that is necessary to consider. No need to make assumptions; let's see what else might be hiding in the system. |
| 8/2 | 2026/08/26 08:48 | tool | grepper |
0mError:no matches Args: {
"Expression": "config NFC_LLCP"
}Results: {
"error": "no matches"
} |
| 9/2 | 2026/08/26 08:48 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 15261 output: 28 thoughts: 24 Thoughts: Here's my attempt at summarizing that thought process, tailored for an expert audience: **LLCP and NFC: A Quick Check** Okay, so I'm wondering about the relationship between LLCP (Logical Link Control Protocol) and NFC. Specifically, does enabling NFC *automatically* enable LLCP? It seems like a reasonable assumption, but I need to confirm. The best place to start, of course, is the source code. Let's dig into the `net/nfc/Makefile` file. That's usually where the build dependencies and core configurations reside. It should quickly reveal whether the LLCP module is conditionally compiled based on the NFC configuration, or if there's an explicit dependency expressed there. Hopefully, this'll be a quick one! |
| 10/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "llcp",
"PathPrefix": "net/nfc/Makefile"
}Results: {
"Output": "net/nfc/Makefile=9=obj-$(CONFIG_NFC_DIGITAL) += nfc_digital.o\nnet/nfc/Makefile-10-\nnet/nfc/Makefile:11:nfc-objs := core.o netlink.o af_nfc.o rawsock.o llcp_core.o llcp_commands.o \\\nnet/nfc/Makefile:12:\t\tllcp_sock.o\nnet/nfc/Makefile-13-\n"
} |
| 11/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 15599 output: 34 thoughts: 150 Thoughts: **Analyzing the NFC LLCP Socket Changes** Okay, so I see that `llcp_core.o` and `llcp_sock.o` are indeed built when `CONFIG_NFC` is enabled, which is expected. They're part of that `nfc-objs` grouping. The patch targets quite a few crucial functions, mainly the lifecycle and management of NFC LLCP sockets. I'm seeing modifications in `nfc_llcp_socket_release`, `nfc_llcp_local_put`, `nfc_llcp_accept_dequeue`, `llcp_sock_accept`, and `llcp_sock_release`. Those are all core to how the LLCP sockets operate. Now, let's get down to specifics. I need to understand the impact of these changes. My first thought is to identify the key symbols that are being modified. I can see that `nfc_llcp_socket_release` is static, so its scope is limited to the module itself. I need to determine if `nfc_llcp_local_put` is exported to fully understand its potential impact on the wider kernel. That's the next check. |
| 12/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "nfc_llcp_local_put",
"PathPrefix": "net/nfc/"
}Results: {
"Output": "net/nfc/llcp.h=204=struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);\nnet/nfc/llcp.h:205:int nfc_llcp_local_put(struct nfc_llcp_local *local);\nnet/nfc/llcp.h-206-u8 nfc_llcp_get_sdp_ssap(struct nfc_llcp_local *local,\n--\nnet/nfc/llcp_commands.c=371=int nfc_llcp_send_symm(struct nfc_dev *dev)\n--\nnet/nfc/llcp_commands.c-401-out:\nnet/nfc/llcp_commands.c:402:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_commands.c-403-\treturn err;\n--\nnet/nfc/llcp_core.c=201=static void local_release(struct kref *ref)\n--\nnet/nfc/llcp_core.c-209-\nnet/nfc/llcp_core.c:210:int nfc_llcp_local_put(struct nfc_llcp_local *local)\nnet/nfc/llcp_core.c-211-{\n--\nnet/nfc/llcp_core.c=655=u8 *nfc_llcp_general_bytes(struct nfc_dev *dev, size_t *general_bytes_len)\n--\nnet/nfc/llcp_core.c-668-\nnet/nfc/llcp_core.c:669:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-670-\n--\nnet/nfc/llcp_core.c=674=int nfc_llcp_set_remote_gb(struct nfc_dev *dev, const u8 *gb, u8 gb_len)\n--\nnet/nfc/llcp_core.c-701-out:\nnet/nfc/llcp_core.c:702:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-703-\treturn err;\n--\nnet/nfc/llcp_core.c=1634=int nfc_llcp_data_received(struct nfc_dev *dev, struct sk_buff *skb)\n--\nnet/nfc/llcp_core.c-1645-\nnet/nfc/llcp_core.c:1646:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-1647-\n--\nnet/nfc/llcp_core.c=1651=void nfc_llcp_mac_is_down(struct nfc_dev *dev)\n--\nnet/nfc/llcp_core.c-1664-\nnet/nfc/llcp_core.c:1665:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-1666-}\n--\nnet/nfc/llcp_core.c=1668=void nfc_llcp_mac_is_up(struct nfc_dev *dev, u32 target_idx,\n--\nnet/nfc/llcp_core.c-1691-\nnet/nfc/llcp_core.c:1692:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-1693-}\n--\nnet/nfc/llcp_core.c=1753=void nfc_llcp_unregister_device(struct nfc_dev *dev)\n--\nnet/nfc/llcp_core.c-1763-\nnet/nfc/llcp_core.c:1764:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_core.c-1765-}\n--\nnet/nfc/llcp_sock.c=59=static int llcp_sock_bind(struct socket *sock, struct sockaddr_unsized *addr, int alen)\n--\nnet/nfc/llcp_sock.c-136-sock_llcp_put_local:\nnet/nfc/llcp_sock.c:137:\tnfc_llcp_local_put(llcp_sock-\u003elocal);\nnet/nfc/llcp_sock.c-138-\tllcp_sock-\u003elocal = NULL;\n--\nnet/nfc/llcp_sock.c=686=static int llcp_sock_connect(struct socket *sock, struct sockaddr_unsized *_addr,\n--\nnet/nfc/llcp_sock.c-799-sock_llcp_put_local:\nnet/nfc/llcp_sock.c:800:\tnfc_llcp_local_put(local);\nnet/nfc/llcp_sock.c-801-\n--\nnet/nfc/llcp_sock.c=1045=void nfc_llcp_sock_free(struct nfc_llcp_sock *sock)\n--\nnet/nfc/llcp_sock.c-1055-\nnet/nfc/llcp_sock.c:1056:\tnfc_llcp_local_put(sock-\u003elocal);\nnet/nfc/llcp_sock.c-1057-}\n--\nnet/nfc/netlink.c=1017=static int nfc_genl_llc_get_params(struct sk_buff *skb, struct genl_info *info)\n--\nnet/nfc/netlink.c-1050-put_local:\nnet/nfc/netlink.c:1051:\tnfc_llcp_local_put(local);\nnet/nfc/netlink.c-1052-\n--\nnet/nfc/netlink.c=1068=static int nfc_genl_llc_set_params(struct sk_buff *skb, struct genl_info *info)\n--\nnet/nfc/netlink.c-1126-put_local:\nnet/nfc/netlink.c:1127:\tnfc_llcp_local_put(local);\nnet/nfc/netlink.c-1128-\n--\nnet/nfc/netlink.c=1137=static int nfc_genl_llc_sdreq(struct sk_buff *skb, struct genl_info *info)\n--\nnet/nfc/netlink.c-1218-put_local:\nnet/nfc/netlink.c:1219:\tnfc_llcp_local_put(local);\nnet/nfc/netlink.c-1220-\n--\nnet/nfc/nfc.h=54=struct nfc_llcp_local *nfc_llcp_find_local(struct nfc_dev *dev);\nnet/nfc/nfc.h:55:int nfc_llcp_local_put(struct nfc_llcp_local *local);\nnet/nfc/nfc.h-56-int __init nfc_llcp_init(void);\n"
} |
| 13/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 17890 output: 37 thoughts: 80 Thoughts: Here's my summary, as though I'm thinking through this process: **Focusing on LLCP Socket Operations** Okay, `nfc_llcp_local_put` looks like a solid starting point for my analysis. But wait, what about `llcp_sock_accept` and `llcp_sock_release`? Those functions are defined as static, which is interesting, but they are also assigned to the `struct proto_ops`. That makes them important. Hmm, I should check where they're defined. Let's dig into `net/nfc/llcp_sock.c` and see what `llcp_sock_accept` is all about. This seems like it will be a good place to start my investigation. |
| 14/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "llcp_sock_accept",
"PathPrefix": "net/nfc/llcp_sock.c"
}Results: {
"Output": "net/nfc/llcp_sock.c=417=struct sock *nfc_llcp_accept_dequeue(struct sock *parent,\n--\nnet/nfc/llcp_sock.c-465-\nnet/nfc/llcp_sock.c:466:static int llcp_sock_accept(struct socket *sock, struct socket *newsock,\nnet/nfc/llcp_sock.c-467-\t\t\t struct proto_accept_arg *arg)\n--\nnet/nfc/llcp_sock.c=952=static const struct proto_ops llcp_sock_ops = {\n--\nnet/nfc/llcp_sock.c-958-\t.socketpair = sock_no_socketpair,\nnet/nfc/llcp_sock.c:959:\t.accept = llcp_sock_accept,\nnet/nfc/llcp_sock.c-960-\t.getname = llcp_sock_getname,\n"
} |
| 15/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 18424 output: 34 thoughts: 35 Thoughts: Here's my summary, as if I were thinking these thoughts: **Analyzing LLCP Socket Acceptance** Okay, so I'm digging into this `llcp_sock_accept` function. The first thing that jumps out is that it's declared `static`. That immediately suggests it's internal to this compilation unit, and not meant to be called from anywhere else. Good to know. But I need to double-check that this is correct. Now, what about `nfc_llcp_accept_dequeue`? Hmm, that name feels like it should be related, and possibly exposed for external use. Let me quickly verify if this one is *also* static or whether it's exported and visible to other modules. That'll be key to understanding the overall design here. I'll need to check the function declaration to be sure. This is an important distinction to identify the correct scope of the functionality. |
| 16/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "nfc_llcp_accept_dequeue",
"PathPrefix": "net/nfc/"
}Results: {
"Output": "net/nfc/llcp.h=218=void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk);\nnet/nfc/llcp.h:219:struct sock *nfc_llcp_accept_dequeue(struct sock *sk, struct socket *newsock);\nnet/nfc/llcp.h-220-\n--\nnet/nfc/llcp_sock.c=403=void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk)\n--\nnet/nfc/llcp_sock.c-416-\nnet/nfc/llcp_sock.c:417:struct sock *nfc_llcp_accept_dequeue(struct sock *parent,\nnet/nfc/llcp_sock.c-418-\t\t\t\t struct socket *newsock)\n--\nnet/nfc/llcp_sock.c=466=static int llcp_sock_accept(struct socket *sock, struct socket *newsock,\n--\nnet/nfc/llcp_sock.c-486-\tadd_wait_queue_exclusive(sk_sleep(sk), \u0026wait);\nnet/nfc/llcp_sock.c:487:\twhile (!(new_sk = nfc_llcp_accept_dequeue(sk, newsock))) {\nnet/nfc/llcp_sock.c-488-\t\tset_current_state(TASK_INTERRUPTIBLE);\n"
} |
| 17/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 19055 output: 34 thoughts: 92 Thoughts: Here's my thought process, as I analyze these functions: **Function Scope Inquiry** Okay, so `nfc_llcp_accept_dequeue` isn't static. That immediately jumps out at me – it means it's likely being called from outside this specific module or file. That's good to know for understanding dependencies and potential side effects. Now, I need to check the others to build a clearer picture. Let's see… `nfc_llcp_socket_release`? Ah, that one *is* static. Interesting. I need to keep track of this difference because it immediately flags potential encapsulation issues. A static function is, by definition, intended for internal use only within its translation unit. Its behavior shouldn't impact anything outside it. Alright, what else has been modified? I'm now going to quickly scan for other non-static functions related to this LLCP implementation. Any deviation from the established pattern warrants closer inspection. `nfc_llcp_sock_list_pop` appears to be static, confirming its intended local scope. Same with `local_release_work`. Okay, two more static functions, solidifying the idea that the system is trying to keep the inner workings of the LLCP layer pretty contained. Aha! `nfc_llcp_accept_unlink` is also non-static, like the `nfc_llcp_accept_dequeue`! This suggests a broader external interaction. This suggests a pattern emerging, namely that there's a specific reason for some functions to be accessible outside of their declaration context, probably to manage external connections. It's time to dig deeper on these two functions and see what they're actually *doing*. I need to understand why these particular functions are exposed and what dependencies they might introduce. |
| 18/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "nfc_llcp_accept_unlink",
"PathPrefix": "net/nfc/"
}Results: {
"Output": "net/nfc/llcp.h=216=void nfc_llcp_sock_free(struct nfc_llcp_sock *sock);\nnet/nfc/llcp.h:217:void nfc_llcp_accept_unlink(struct sock *sk);\nnet/nfc/llcp.h-218-void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk);\n--\nnet/nfc/llcp_core.c=83=static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,\n--\nnet/nfc/llcp_core.c-114-\t\t\t\tif (nfc_llcp_sock(accept_sk)-\u003eparent == sk) {\nnet/nfc/llcp_core.c:115:\t\t\t\t\tnfc_llcp_accept_unlink(accept_sk);\nnet/nfc/llcp_core.c-116-\t\t\t\t\tnfc_llcp_sock_unlink(\u0026local-\u003esockets, accept_sk);\n--\nnet/nfc/llcp_sock.c=304=static int nfc_llcp_getsockopt(struct socket *sock, int level, int optname,\n--\nnet/nfc/llcp_sock.c-388-\nnet/nfc/llcp_sock.c:389:void nfc_llcp_accept_unlink(struct sock *sk)\nnet/nfc/llcp_sock.c-390-{\n--\nnet/nfc/llcp_sock.c=417=struct sock *nfc_llcp_accept_dequeue(struct sock *parent,\n--\nnet/nfc/llcp_sock.c-434-\nnet/nfc/llcp_sock.c:435:\t\t\tnfc_llcp_accept_unlink(sk);\nnet/nfc/llcp_sock.c-436-\t\t\tif (local)\n--\nnet/nfc/llcp_sock.c=616=static int llcp_sock_release(struct socket *sock)\n--\nnet/nfc/llcp_sock.c-652-\t\t\t\tnfc_llcp_send_disconnect(lsk);\nnet/nfc/llcp_sock.c:653:\t\t\t\tnfc_llcp_accept_unlink(accept_sk);\nnet/nfc/llcp_sock.c-654-\t\t\t\tnfc_llcp_sock_unlink(\u0026local-\u003esockets, accept_sk);\n"
} |
| 19/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 20180 output: 31 thoughts: 192 Thoughts: **My Analysis of NFC LLCP Code for Fuzzing** Okay, let's break this down. My initial instinct is that `nfc_llcp_accept_unlink`, `nfc_llcp_accept_dequeue`, and `nfc_llcp_local_put` are strong candidates for fuzzing targets within this NFC LLCP implementation. Those function names scream potential for input handling vulnerabilities. Now, the configuration aspects. I see `NFC` and `NFC_SIM`. *NFC_SIM* jumps out as the simulator, which is ideal for this kind of work, but I need to ensure the core is intact, and that seems to be enabled by `NFC`. But is `NFC_SIM` actually part of the core, or something else? Aha, `NFC_SIM` is a *driver*, but the code I'm looking at, specifically `net/nfc/llcp_core.c`, is compiled under the `NFC` flag. That's good. It means my target code is part of the main system, and not a separate module. Right, so to make sure the code gets compiled, `NFC` needs to be enabled. But to test the LLCP core, I need an NFC device. *Bingo!* `NFC_SIM` provides that virtual device. It's a perfect setup for fuzzing - I can simulate interactions without requiring physical hardware. Just to be certain, I'll quickly check if `NFC_SIM` has any dependencies that could complicate things. I want to know if there are hidden factors or limitations that need to be considered. |
| 20/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "config NFC_SIM",
"PathPrefix": "drivers/nfc/Kconfig"
}Results: {
"Output": "drivers/nfc/Kconfig=21=config NFC_MEI_PHY\n--\ndrivers/nfc/Kconfig-30-\ndrivers/nfc/Kconfig:31:config NFC_SIM\ndrivers/nfc/Kconfig-32-\ttristate \"NFC hardware simulator driver\"\n"
} |
| 21/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 20837 output: 34 thoughts: 13 Thoughts: Here's my take on the dependencies of `NFC_SIM`: **Deep Dive into NFC_SIM Dependencies** Okay, so before I get too far down the road with this, let's take a good, hard look at the dependencies of `NFC_SIM`. I need to ensure a robust and well-defined foundation, and that starts here. I'm thinking beyond just the immediately obvious; what external libraries is it pulling in? What specific versions are required, and are those versions still actively maintained? Are there any potential conflicts I need to be aware of? Are there any indirect dependencies – dependencies of dependencies – that might introduce unexpected complexities down the line? I'm also considering the build environment itself. What compiler versions are supported? What operating systems are officially supported, and what about less common ones? Are there any platform-specific dependencies I need to take into account? This is crucial for portability. And what about the testing framework? Are there any particular libraries or tools `NFC_SIM` relies on for unit tests, integration tests, or performance benchmarks? I'm not just concerned with getting the code to run; I want to ensure it's thoroughly tested and maintainable. Finally, I'm thinking about the future. Will `NFC_SIM` need to interact with any other systems or components down the line? Are there any emerging standards or technologies that I need to keep in mind when evaluating these dependencies? Choosing the right dependencies now can save a massive headache later. It's all about proactive risk mitigation. |
| 22/2 | 2026/08/26 08:49 | tool | read-file |
0mArgs:{
"File": "drivers/nfc/Kconfig",
"FirstLine": 30,
"LineCount": 10
}Results: {
"Contents": " 30:\t\n 31:\tconfig NFC_SIM\n 32:\t\ttristate \"NFC hardware simulator driver\"\n 33:\t\tdepends on NFC_DIGITAL\n 34:\t\thelp\n 35:\t\t This driver declares two virtual NFC devices supporting NFC-DEP\n 36:\t\t protocol. An LLCP connection can be established between them and\n 37:\t\t all packets sent from one device is sent back to the other, acting as\n 38:\t\t loopback devices.\n 39:\t\n"
} |
| 23/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21345 output: 32 thoughts: 31 Thoughts: Okay, here's my interpretation of those thoughts, summarized from a first-person perspective, assuming I'm well-versed in this field: **Dependency Deep Dive** Alright, I see it immediately. `NFC_SIM` relies on `NFC_DIGITAL`. This isn't unexpected, but it's a critical point to acknowledge before proceeding. Now, before I go any further, I need to understand `NFC_DIGITAL`'s own dependencies. It's time to trace its dependency tree. Gotta make sure I have a solid understanding of everything that feeds into `NFC_DIGITAL` because that inevitably impacts `NFC_SIM` and the broader system's behavior. Time to dig in. |
| 24/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "config NFC_DIGITAL",
"PathPrefix": "net/nfc/Kconfig"
}Results: {
"Output": "net/nfc/Kconfig=6=menuconfig NFC\n--\nnet/nfc/Kconfig-16-\nnet/nfc/Kconfig:17:config NFC_DIGITAL\nnet/nfc/Kconfig-18-\tdepends on NFC\n"
} |
| 25/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21636 output: 34 thoughts: 43 Thoughts: Okay, here's my take on those configurations: **Analyzing NFC Configuration Options** Alright, let's break this down. From what I'm seeing, `NFC`, `NFC_DIGITAL`, and `NFC_SIM` are the key configurations in play here. But hold on, it seems like `NFC_VIRTUAL_NCI` *might* be relevant too. I should really check that one as well, just to be thorough and see if it brings anything new to the table. We need to consider all angles when dealing with the NFC implementations. It's important to be complete. |
| 26/2 | 2026/08/26 08:49 | tool | read-file |
0mArgs:{
"File": "drivers/nfc/Kconfig",
"FirstLine": 51,
"LineCount": 10
}Results: {
"Contents": " 51:\t\n 52:\tconfig NFC_VIRTUAL_NCI\n 53:\t\ttristate \"NCI device simulator driver\"\n 54:\t\tdepends on NFC_NCI\n 55:\t\thelp\n 56:\t\t NCI virtual device simulates a NCI device to the user.\n 57:\t\t It can be used to validate the NCI module and applications.\n 58:\t\t This driver supports communication between the virtual NCI device and\n 59:\t\t module.\n 60:\t\n"
} |
| 27/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 21987 output: 35 thoughts: 34 Thoughts: Okay, here's my interpretation of those thoughts, summarized from my perspective as an expert in the field: **Dependency Deep Dive** Alright, so `NFC_VIRTUAL_NCI` is clearly built on top of `NFC_NCI`. That's a pretty standard layering approach, but I need to make absolutely sure the foundation is solid before I get too invested in the virtual aspects. So, the first logical step is to delve into the dependencies of `NFC_NCI`. I need to understand what it relies on, what its potential weak points are, and if any updates or changes there could ripple up and affect `NFC_VIRTUAL_NCI`. Got to thoroughly vet the base before I build on it. |
| 28/2 | 2026/08/26 08:49 | tool | grepper |
0mArgs:{
"Expression": "config NFC_NCI",
"PathPrefix": "net/nfc/nci/Kconfig"
}Results: {
"Output": "net/nfc/nci/Kconfig-1-# SPDX-License-Identifier: GPL-2.0-only\nnet/nfc/nci/Kconfig:2:config NFC_NCI\nnet/nfc/nci/Kconfig-3-\tdepends on NFC\n--\nnet/nfc/nci/Kconfig-12-\nnet/nfc/nci/Kconfig:13:config NFC_NCI_SPI\nnet/nfc/nci/Kconfig-14-\tdepends on NFC_NCI \u0026\u0026 SPI\n--\nnet/nfc/nci/Kconfig-23-\nnet/nfc/nci/Kconfig:24:config NFC_NCI_UART\nnet/nfc/nci/Kconfig-25-\tdepends on NFC_NCI \u0026\u0026 TTY\n"
} |
| 29/2 | 2026/08/26 08:49 | llm | patch-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 22417 output: 192 thoughts: 161 Thoughts: Here's my assessment of the situation: **NFC Testing and Potential Vulnerabilities** Okay, so I'm thinking, beyond the core `NFC` config, enabling `NFC_VIRTUAL_NCI` and `NFC_NCI` seems like a solid approach for comprehensive NFC testing. I need to keep in mind the core configurations of `NFC`, `NFC_DIGITAL`, and `NFC_SIM`. This patch is interesting – it's addressing a race condition or potential use-after-free situation within LLCP socket release. That immediately flags this as something that warrants fuzzing. It's a classic area for memory corruption vulnerabilities, and LLCP being a lower-level protocol makes it an even better target. My focus should be on these key symbols: `nfc_llcp_local_put`, `nfc_llcp_accept_dequeue`, and `nfc_llcp_accept_unlink`. They are likely at the heart of the issue and understanding their behavior will be critical for effective fuzzing. Before I commit to this, I'll quickly scan the existing configs to make sure I haven't overlooked any other relevant options that might impact the test environment. |
| 30/2 | 2026/08/26 08:49 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"NFC",
"NFC_DIGITAL",
"NFC_SIM",
"NFC_NCI",
"NFC_VIRTUAL_NCI"
],
"FocusSymbols": [
"nfc_llcp_local_put",
"nfc_llcp_accept_dequeue",
"nfc_llcp_accept_unlink"
],
"Reasoning": "The patch modifies the core logic of NFC LLCP sockets, fixing a potential race condition or use-after-free during socket release and accept queue handling. It introduces a workqueue for local release and modifies socket locking. This is reachable via standard socket APIs when NFC is enabled. Virtual NFC devices (NFC_SIM, NFC_VIRTUAL_NCI) can be used to trigger this code in a virtualized environment.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"NFC",
"NFC_DIGITAL",
"NFC_SIM",
"NFC_NCI",
"NFC_VIRTUAL_NCI"
],
"FocusSymbols": [
"nfc_llcp_local_put",
"nfc_llcp_accept_dequeue",
"nfc_llcp_accept_unlink"
],
"Reasoning": "The patch modifies the core logic of NFC LLCP sockets, fixing a potential race condition or use-after-free during socket release and accept queue handling. It introduces a workqueue for local release and modifies socket locking. This is reachable via standard socket APIs when NFC is enabled. Virtual NFC devices (NFC_SIM, NFC_VIRTUAL_NCI) can be used to trigger this code in a virtualized environment.",
"WorthFuzzing": true
} |
| 31/1 | 2026/08/26 08:49 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 32/2 | 2026/08/26 08:49 | agent | kmsan-evaluator |
0mModel:best-expensive Args: null Results: {
"KMSANReasoning": "The patch addresses locking, reference counting, and use-after-free issues in the NFC LLCP socket layer. It introduces a workqueue for deferred cleanup, modifies socket list popping to avoid deadlocks or UAF, and fixes accept queue handling. There are no changes to data structures copied to user space, no new buffer allocations, and no modifications to data lengths or bounds checks that could expose uninitialized memory. Any bugs introduced by these changes (such as use-after-free, double free, or deadlocks) would be caught by standard KASAN and LOCKDEP. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: For your convenience, here is the diff of the changes:
commit 01920323b9540fcb68eb8e1faed02447082616ed
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Aug 26 08:48:33 2026 +0000
syz-cluster: applied patch under review
diff --git a/net/nfc/llcp.h b/net/nfc/llcp.h
index d8345ed57c954..23ae7a0112d37 100644
--- a/net/nfc/llcp.h
+++ b/net/nfc/llcp.h
@@ -91,6 +91,7 @@ struct nfc_llcp_local {
struct hlist_head pending_sdreqs;
struct timer_list sdreq_timer;
struct work_struct sdreq_timeout_work;
+ struct work_struct release_work;
u8 sdreq_next_tid;
/* sockets array */
diff --git a/net/nfc/llcp_core.c b/net/nfc/llcp_core.c
index bd6361e2efa4f..2c2dbc12531ec 100644
--- a/net/nfc/llcp_core.c
+++ b/net/nfc/llcp_core.c
@@ -20,6 +20,8 @@ static LIST_HEAD(llcp_devices);
/* Protects llcp_devices list */
static DEFINE_SPINLOCK(llcp_devices_lock);
+static struct workqueue_struct *llcp_wq;
+
static void nfc_llcp_rx_skb(struct nfc_llcp_local *local, struct sk_buff *skb);
void nfc_llcp_sock_link(struct llcp_sock_list *l, struct sock *sk)
@@ -63,21 +65,33 @@ static void nfc_llcp_socket_purge(struct nfc_llcp_sock *sock)
}
}
+static struct sock *nfc_llcp_sock_list_pop(struct llcp_sock_list *l)
+{
+ struct sock *sk;
+
+ write_lock(&l->lock);
+ sk = sk_head(&l->head);
+ if (sk) {
+ sock_hold(sk);
+ sk_del_node_init(sk);
+ }
+ write_unlock(&l->lock);
+
+ return sk;
+}
+
static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
int err)
{
struct sock *sk;
- struct hlist_node *tmp;
struct nfc_llcp_sock *llcp_sock;
skb_queue_purge(&local->tx_queue);
- write_lock(&local->sockets.lock);
-
- sk_for_each_safe(sk, tmp, &local->sockets.head) {
+ while ((sk = nfc_llcp_sock_list_pop(&local->sockets))) {
llcp_sock = nfc_llcp_sock(sk);
- bh_lock_sock(sk);
+ lock_sock(sk);
nfc_llcp_socket_purge(llcp_sock);
@@ -91,17 +105,27 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
list_for_each_entry_safe(lsk, n,
&llcp_sock->accept_queue,
accept_queue) {
- accept_sk = &lsk->sk;
- bh_lock_sock(accept_sk);
-
- nfc_llcp_accept_unlink(accept_sk);
+ bool put_creation = false;
- if (err)
- accept_sk->sk_err = err;
- accept_sk->sk_state = LLCP_CLOSED;
- accept_sk->sk_state_change(sk);
+ accept_sk = &lsk->sk;
+ lock_sock_nested(accept_sk,
+ SINGLE_DEPTH_NESTING);
+
+ if (nfc_llcp_sock(accept_sk)->parent == sk) {
+ nfc_llcp_accept_unlink(accept_sk);
+ nfc_llcp_sock_unlink(&local->sockets, accept_sk);
+
+ if (err)
+ accept_sk->sk_err = err;
+ accept_sk->sk_state = LLCP_CLOSED;
+ accept_sk->sk_state_change(accept_sk);
+ sock_orphan(accept_sk);
+ put_creation = true;
+ }
- bh_unlock_sock(accept_sk);
+ release_sock(accept_sk);
+ if (put_creation)
+ sock_put(accept_sk); /* creation ref */
}
}
@@ -110,23 +134,18 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
- bh_unlock_sock(sk);
-
- sk_del_node_init(sk);
+ release_sock(sk);
+ sock_put(sk);
}
- write_unlock(&local->sockets.lock);
-
/* If we still have a device, we keep the RAW sockets alive */
if (device == true)
return;
- write_lock(&local->raw_sockets.lock);
-
- sk_for_each_safe(sk, tmp, &local->raw_sockets.head) {
+ while ((sk = nfc_llcp_sock_list_pop(&local->raw_sockets))) {
llcp_sock = nfc_llcp_sock(sk);
- bh_lock_sock(sk);
+ lock_sock(sk);
nfc_llcp_socket_purge(llcp_sock);
@@ -135,26 +154,20 @@ static void nfc_llcp_socket_release(struct nfc_llcp_local *local, bool device,
sk->sk_state = LLCP_CLOSED;
sk->sk_state_change(sk);
- bh_unlock_sock(sk);
-
- sk_del_node_init(sk);
+ release_sock(sk);
+ sock_put(sk);
}
-
- write_unlock(&local->raw_sockets.lock);
}
static struct nfc_llcp_local *nfc_llcp_local_get(struct nfc_llcp_local *local)
{
- /* Since using nfc_llcp_local may result in usage of nfc_dev, whenever
- * we hold a reference to local, we also need to hold a reference to
- * the device to avoid UAF.
- */
- if (!nfc_get_device(local->dev->idx))
+ if (!local)
return NULL;
- kref_get(&local->ref);
+ if (kref_get_unless_zero(&local->ref))
+ return local;
- return local;
+ return NULL;
}
static void local_cleanup(struct nfc_llcp_local *local)
@@ -172,30 +185,34 @@ static void local_cleanup(struct nfc_llcp_local *local)
nfc_llcp_free_sdp_tlv_list(&local->pending_sdreqs);
}
-static void local_release(struct kref *ref)
+static void local_release_work(struct work_struct *work)
{
struct nfc_llcp_local *local;
+ struct nfc_dev *dev;
- local = container_of(ref, struct nfc_llcp_local, ref);
+ local = container_of(work, struct nfc_llcp_local, release_work);
+ dev = local->dev;
local_cleanup(local);
kfree(local);
+ nfc_put_device(dev);
}
-int nfc_llcp_local_put(struct nfc_llcp_local *local)
+static void local_release(struct kref *ref)
{
- struct nfc_dev *dev;
- int ret;
+ struct nfc_llcp_local *local;
- if (local == NULL)
- return 0;
+ local = container_of(ref, struct nfc_llcp_local, ref);
- dev = local->dev;
+ queue_work(llcp_wq, &local->release_work);
+}
- ret = kref_put(&local->ref, local_release);
- nfc_put_device(dev);
+int nfc_llcp_local_put(struct nfc_llcp_local *local)
+{
+ if (!local)
+ return 0;
- return ret;
+ return kref_put(&local->ref, local_release);
}
static struct nfc_llcp_sock *nfc_llcp_sock_get(struct nfc_llcp_local *local,
@@ -1705,6 +1722,7 @@ int nfc_llcp_register_device(struct nfc_dev *ndev)
INIT_WORK(&local->rx_work, nfc_llcp_rx_work);
INIT_WORK(&local->timeout_work, nfc_llcp_timeout_work);
+ INIT_WORK(&local->release_work, local_release_work);
rwlock_init(&local->sockets.lock);
rwlock_init(&local->connecting_sockets.lock);
@@ -1748,10 +1766,23 @@ void nfc_llcp_unregister_device(struct nfc_dev *dev)
int __init nfc_llcp_init(void)
{
- return nfc_llcp_sock_init();
+ int ret;
+
+ llcp_wq = alloc_workqueue("nfc_llcp_wq", 0, 0);
+ if (!llcp_wq)
+ return -ENOMEM;
+
+ ret = nfc_llcp_sock_init();
+ if (ret) {
+ destroy_workqueue(llcp_wq);
+ return ret;
+ }
+
+ return 0;
}
void nfc_llcp_exit(void)
{
nfc_llcp_sock_exit();
+ destroy_workqueue(llcp_wq);
}
diff --git a/net/nfc/llcp_sock.c b/net/nfc/llcp_sock.c
index 5558d8a4d48b3..ce6875eb58fbc 100644
--- a/net/nfc/llcp_sock.c
+++ b/net/nfc/llcp_sock.c
@@ -392,11 +392,12 @@ void nfc_llcp_accept_unlink(struct sock *sk)
pr_debug("state %d\n", sk->sk_state);
- list_del_init(&llcp_sock->accept_queue);
- sk_acceptq_removed(llcp_sock->parent);
- llcp_sock->parent = NULL;
-
- sock_put(sk);
+ if (llcp_sock->parent) {
+ list_del_init(&llcp_sock->accept_queue);
+ sk_acceptq_removed(llcp_sock->parent);
+ llcp_sock->parent = NULL;
+ sock_put(sk);
+ }
}
void nfc_llcp_accept_enqueue(struct sock *parent, struct sock *sk)
@@ -423,12 +424,20 @@ struct sock *nfc_llcp_accept_dequeue(struct sock *parent,
list_for_each_entry_safe(lsk, n, &llcp_parent->accept_queue,
accept_queue) {
+ struct nfc_llcp_local *local;
+
sk = &lsk->sk;
- lock_sock(sk);
+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
if (sk->sk_state == LLCP_CLOSED) {
- release_sock(sk);
+ local = nfc_llcp_sock(sk)->local;
+
nfc_llcp_accept_unlink(sk);
+ if (local)
+ nfc_llcp_sock_unlink(&local->sockets, sk);
+ sock_orphan(sk);
+ release_sock(sk);
+ sock_put(sk);
continue;
}
@@ -464,7 +473,7 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,
pr_debug("parent %p\n", sk);
- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
+ lock_sock(sk);
if (sk->sk_state != LLCP_LISTEN) {
ret = -EBADFD;
@@ -490,7 +499,12 @@ static int llcp_sock_accept(struct socket *sock, struct socket *newsock,
release_sock(sk);
timeo = schedule_timeout(timeo);
- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
+ lock_sock(sk);
+
+ if (sk->sk_state != LLCP_LISTEN) {
+ ret = -EBADFD;
+ break;
+ }
}
__set_current_state(TASK_RUNNING);
remove_wait_queue(sk_sleep(sk), &wait);
@@ -629,13 +643,24 @@ static int llcp_sock_release(struct socket *sock)
list_for_each_entry_safe(lsk, n, &llcp_sock->accept_queue,
accept_queue) {
+ bool put_creation = false;
+
accept_sk = &lsk->sk;
- lock_sock(accept_sk);
+ lock_sock_nested(accept_sk, SINGLE_DEPTH_NESTING);
- nfc_llcp_send_disconnect(lsk);
- nfc_llcp_accept_unlink(accept_sk);
+ if (nfc_llcp_sock(accept_sk)->parent == sk) {
+ nfc_llcp_send_disconnect(lsk);
+ nfc_llcp_accept_unlink(accept_sk);
+ nfc_llcp_sock_unlink(&local->sockets, accept_sk);
+
+ accept_sk->sk_state = LLCP_CLOSED;
+ sock_orphan(accept_sk);
+ put_creation = true;
+ }
release_sock(accept_sk);
+ if (put_creation)
+ sock_put(accept_sk); /* creation ref */
}
}
|
| 33/3 | 2026/08/26 08:49 | llm | kmsan-evaluator |
0mModel:gemini-3.1-pro-preview Args: null Results: null Tokens: input: 5634 output: 156 thoughts: 554 Thoughts: **My Assessment of the NFC LLCP Patch** Okay, so I've just reviewed this patch for the NFC LLCP subsystem. My initial assessment is that it's focused on some crucial, but very targeted, fixes. It's essentially a deep dive into socket lifecycle management, particularly around locking, reference counting, and cleanup procedures. It's touching core functions: `nfc_llcp_socket_release`, `nfc_llcp_local_get`, `local_release_work`, `nfc_llcp_local_put`, `nfc_llcp_accept_unlink`, `nfc_llcp_accept_dequeue`, `llcp_sock_accept`, and `llcp_sock_release` (along with `nfc_llcp_init` and `nfc_llcp_exit`). I can see that there's a definite focus on improving socket state handling and preventing issues like use-after-free conditions and race conditions. The introduction of `release_work` and deferring the local release to a workqueue (`llcp_wq`) is a key indicator of this refactoring. I'm also seeing some improvements to the locking primitives being used, such as `lock_sock` over `lock_sock_nested` in `llcp_sock_accept`. My main concern, as always, is whether these changes introduce any new security vulnerabilities, particularly related to uninitialized memory exposure or information leaks. However, after careful review, I'm confident that the answer is no. This patch doesn't involve any changes that involve sending new data structures to user space, nor is it reading uninitialized memory, or allocating complex data structures with uninitialized fields. These modifications are purely control plane operations, concerned with the management of socket lifecycle. There's no data copying or direct interaction with user space data that would necessitate KMSAN. Since these changes are all about socket state, locking, and reference counting, standard KASAN, LOCKDEP, and KCSAN should be perfectly adequate to catch any potential issues – such as UAF, deadlocks, or data races. Therefore, I'm comfortable setting `NeedsKMSAN=false` for this one. I've double-checked that all of the modified functions, including the ones mentioned above, don't deal with copying data to user space or reading uninitialized memory. They are clearly focused on internal socket state management and cleanup. So, KMSAN is not necessary here. I think this patch is a good set of fixes. |
| 34/3 | 2026/08/26 08:50 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch addresses locking, reference counting, and use-after-free issues in the NFC LLCP socket layer. It introduces a workqueue for deferred cleanup, modifies socket list popping to avoid deadlocks or UAF, and fixes accept queue handling. There are no changes to data structures copied to user space, no new buffer allocations, and no modifications to data lengths or bounds checks that could expose uninitialized memory. Any bugs introduced by these changes (such as use-after-free, double free, or deadlocks) would be caught by standard KASAN and LOCKDEP. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch addresses locking, reference counting, and use-after-free issues in the NFC LLCP socket layer. It introduces a workqueue for deferred cleanup, modifies socket list popping to avoid deadlocks or UAF, and fixes accept queue handling. There are no changes to data structures copied to user space, no new buffer allocations, and no modifications to data lengths or bounds checks that could expose uninitialized memory. Any bugs introduced by these changes (such as use-after-free, double free, or deadlocks) would be caught by standard KASAN and LOCKDEP. Therefore, a dedicated KMSAN fuzzing session is not required.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|