aboutsummaryrefslogtreecommitdiffstats
path: root/sys/linux
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-10-25 16:13:45 +0200
committerDmitry Vyukov <dvyukov@google.com>2022-11-13 17:49:14 +0100
commit4149e87d4bf3ee3648e20929e455594fca75293e (patch)
tree379ad10f654835ce0a3562cf16e6b5a80ca1d1d9 /sys/linux
parent2df526854481775aa7dfcf9b2da4be92cbe5f53b (diff)
sys/linux: add NFC seed
Diffstat (limited to 'sys/linux')
-rw-r--r--sys/linux/test/nfc43
1 files changed, 43 insertions, 0 deletions
diff --git a/sys/linux/test/nfc b/sys/linux/test/nfc
new file mode 100644
index 000000000..8dfff2457
--- /dev/null
+++ b/sys/linux/test/nfc
@@ -0,0 +1,43 @@
+# Create NCI NFC device.
+
+r0 = openat$nci(AUTO, &AUTO, AUTO, AUTO)
+ioctl$IOCTL_GET_NCIDEV_IDX(r0, AUTO, &AUTO=<r1=>0x0)
+
+# Up the device.
+
+r2 = syz_init_net_socket$nl_generic(AUTO, AUTO, AUTO)
+r3 = syz_genetlink_get_family_id$nfc(&AUTO, r2)
+sendmsg$NFC_CMD_DEV_UP(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)
+
+# Mock communication with the device.
+# NCI core should send reset, init and discover commands.
+
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_CORE_RESET_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, 0x0}}, AUTO)
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_CORE_INIT_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {{0x0, 0x0, 0x0, ""}, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0}}}, AUTO)
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_MAP_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, 0x0}, AUTO)
+
+# Enable polling.
+
+sendmsg$NFC_CMD_START_POLL(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}, @NFC_ATTR_PROTOCOLS={AUTO, AUTO, 0xffffffff, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)
+
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_CORE_SET_CONFIG_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, ""}}, AUTO)
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_CORE_SET_CONFIG_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, ""}}, AUTO)
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, 0x0}, AUTO)
+
+# Pretend we discovered target 0.
+
+write$nci(r0, &AUTO=@NCI_OP_RF_DISCOVER_NTF={AUTO, 0x0, AUTO, AUTO, 0x0, @b={0x0, 0x1, AUTO, 0x1, {0x1, "aa"}, 0x0}}, AUTO)
+
+# Activate target 0.
+
+sendmsg$NFC_CMD_ACTIVATE_TARGET(r2, &AUTO={0x0, 0x0, &AUTO={&AUTO={AUTO, r3, 0x1, 0x123, 0x234, {AUTO, 0x0, 0x0}, [@NFC_ATTR_DEVICE_INDEX={AUTO, AUTO, r1, nil}, @NFC_ATTR_TARGET_INDEX={AUTO, AUTO, 0x0, nil}, @NFC_ATTR_PROTOCOLS={AUTO, AUTO, 0x1, nil}]}, AUTO}, 0x1, 0x0, 0x0, 0x0}, 0x0)
+
+read$nci(r0, &AUTO=""/100, AUTO)
+write$nci(r0, &AUTO=@NCI_OP_CORE_CONN_CREATE_RSP={AUTO, 0x0, AUTO, AUTO, 0x0, {0x0, 0x0, 0x0, 0x1}}, AUTO)
+