| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/08/31 04:12 | flow | patch-triage |
0mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The patch only adds and updates KUnit test cases in drivers/net/mctp/mctp-usblib-test.c. It does not introduce or modify any core kernel logic, runtime driver execution paths, or fuzzable interfaces.",
"WorthFuzzing": false
} |
| 1/1 | 2026/08/31 04:12 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit ce0bba4044cbf9dcd1bc9a86bd2187fda6fead37\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Mon Aug 31 04:12:34 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/mctp/mctp-usblib-test.c b/drivers/net/mctp/mctp-usblib-test.c\nindex 9df401a914ff5..b3a2cc5cbd99d 100644\n--- a/drivers/net/mctp/mctp-usblib-test.c\n+++ b/drivers/net/mctp/mctp-usblib-test.c\n@@ -6,6 +6,8 @@\n * Copyright (C) 2026 Code Construct Pty Ltd\n */\n \n+#include \"linux/percpu-defs.h\"\n+#include \u003clinux/array_size.h\u003e\n #include \u003cuapi/linux/netdevice.h\u003e\n #include \u003clinux/netdevice.h\u003e\n #include \u003ckunit/test.h\u003e\n@@ -14,6 +16,15 @@\n #include \u003cnet/mctpdevice.h\u003e\n #include \u003clinux/usb/mctp-usb.h\u003e\n \n+#define HDR_LEN sizeof(struct mctp_usb_hdr)\n+\n+struct tx_buff {\n+\tstruct list_head list;\n+\n+\tsize_t length;\n+\tu8 data[] __counted_by(length);\n+};\n+\n struct mctp_usblib_test_dev {\n \tstruct net_device *ndev;\n \tstruct mctp_dev *mdev;\n@@ -22,9 +33,110 @@ struct mctp_usblib_test_dev {\n \n struct mctp_usblib_test_ctx {\n \tstruct mctp_usblib_test_dev *dev;\n+\tstruct list_head tx_xfers;\n \tstruct mctp_route rt;\n };\n \n+static int mctp_usblib_test_tx_send(struct mctp_usblib_tx_ctx *tx_ctx,\n+\t\t\t\t void *data, size_t len)\n+{\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct tx_buff *new_node;\n+\tstruct net_device *ndev;\n+\tint rc;\n+\n+\tctx = mctp_usblib_tx_ctx_priv(tx_ctx);\n+\tndev = ctx-\u003edev-\u003endev;\n+\trc = 0;\n+\n+\tnew_node = kzalloc_flex(*new_node, data, len, GFP_KERNEL);\n+\tif (!new_node) {\n+\t\trc = -ENOMEM;\n+\t\tgoto exit;\n+\t}\n+\n+\tnew_node-\u003elength = len;\n+\tmemcpy(\u0026new_node-\u003edata, data, len);\n+\tlist_add_tail(\u0026new_node-\u003elist, \u0026ctx-\u003etx_xfers);\n+\n+exit:\n+\tmctp_usblib_tx_send_complete(tx_ctx, ndev, rc == 0);\n+\treturn rc;\n+}\n+\n+static int mctp_usblib_test_tx_send_fail(struct mctp_usblib_tx_ctx *tx_ctx,\n+\t\t\t\t\t void *data, size_t len)\n+{\n+\treturn -ENOMEM;\n+}\n+\n+static u8 *mctp_usblib_test_flatten_tx_buff(struct kunit *test,\n+\t\t\t\t\t struct list_head *in,\n+\t\t\t\t\t size_t *length_out)\n+{\n+\tstruct tx_buff *pos;\n+\tsize_t length;\n+\tu8 *buf, *tail;\n+\n+\tKUNIT_ASSERT_TRUE(test, length_out);\n+\tKUNIT_ASSERT_TRUE(test, in);\n+\n+\tlength = 0;\n+\tlist_for_each_entry(pos, in, list)\n+\t\tlength = size_add(length, pos-\u003elength);\n+\n+\tKUNIT_ASSERT_NE(test, length, 0);\n+\tKUNIT_ASSERT_NE(test, length, SIZE_MAX);\n+\n+\tbuf = kunit_kzalloc(test, length, GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_NULL(test, buf);\n+\n+\ttail = buf;\n+\tlist_for_each_entry(pos, in, list) {\n+\t\tmemcpy(tail, pos-\u003edata, pos-\u003elength);\n+\t\ttail += pos-\u003elength;\n+\t}\n+\n+\t*length_out = length;\n+\treturn buf;\n+}\n+\n+static u8 *mctp_usblib_test_init_buf(struct kunit *test, size_t length)\n+{\n+\tu8 *buffer;\n+\tsize_t i;\n+\n+\tbuffer = kunit_kzalloc(test, length, GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_NULL(test, buffer);\n+\n+\tfor (i = 0; i \u003c length; i++)\n+\t\tbuffer[i] = i % 256;\n+\n+\treturn buffer;\n+}\n+\n+static void mctp_usblib_test_fill_head(struct mctp_usb_hdr *head, size_t len)\n+{\n+\tlen += HDR_LEN;\n+\thead-\u003eid = cpu_to_be16(MCTP_USB_DMTF_ID);\n+\thead-\u003elen = cpu_to_be16(len \u0026 MCTP_USB_1_1_PKTLEN_MAX);\n+}\n+\n+static struct sk_buff *mctp_usblib_test_init_skb(struct kunit *test,\n+\t\t\t\t\t\t unsigned int length,\n+\t\t\t\t\t\t struct net_device *ndev,\n+\t\t\t\t\t\t void *data)\n+{\n+\tstruct sk_buff *skb;\n+\n+\tskb = __netdev_alloc_skb(ndev, length, GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_NULL(test, skb);\n+\n+\tskb-\u003elen = length;\n+\tmemcpy(skb-\u003edata, data, length);\n+\treturn skb;\n+}\n+\n static netdev_tx_t mctp_usblib_dev_tx(struct sk_buff *skb,\n \t\t\t\t struct net_device *ndev)\n {\n@@ -117,6 +229,7 @@ static int mctp_usblib_test_dst_output(struct mctp_dst *dst,\n static void mctp_usblib_test_fini_action(void *data)\n {\n \tstruct mctp_usblib_test_ctx *ctx = data;\n+\tstruct tx_buff *curr, *temp;\n \n \t/* The device will have been destroyed, so -\u003ert will be unlinked.\n \t * Just ensure that the refcount is as expected.\n@@ -124,6 +237,8 @@ static void mctp_usblib_test_fini_action(void *data)\n \tKUNIT_EXPECT_TRUE(current-\u003ekunit_test,\n \t\t\t refcount_dec_and_test(\u0026ctx-\u003ert.refs));\n \n+\tlist_for_each_entry_safe(curr, temp, \u0026ctx-\u003etx_xfers, list)\n+\t\tkfree(curr);\n \tkfree(ctx);\n }\n \n@@ -139,6 +254,7 @@ static struct mctp_usblib_test_ctx *mctp_usblib_test_init(struct kunit *test)\n \tINIT_LIST_HEAD(\u0026ctx-\u003ert.list);\n \trt = \u0026ctx-\u003ert;\n \trefcount_set(\u0026rt-\u003erefs, 1);\n+\tINIT_LIST_HEAD(\u0026ctx-\u003etx_xfers);\n \n \trc = kunit_add_action_or_reset(test, mctp_usblib_test_fini_action, ctx);\n \tKUNIT_ASSERT_EQ(test, rc, 0);\n@@ -200,11 +316,9 @@ mctp_usblib_test_rx_init(struct kunit *test, bool span)\n \tint rc;\n \n \trx = kzalloc_obj(*rx);\n-\tif (rx) {\n-\t\trc = kunit_add_action_or_reset(test, action_rx_fini, rx);\n-\t\tKUNIT_ASSERT_EQ(test, rc, 0);\n-\t}\n \tKUNIT_ASSERT_NOT_NULL(test, rx);\n+\trc = kunit_add_action_or_reset(test, action_rx_fini, rx);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n \n \trc = mctp_usblib_rx_init(rx, ep_maxpacket, span);\n \tKUNIT_ASSERT_EQ(test, rc, 0);\n@@ -227,6 +341,32 @@ static int mctp_usblib_test_rx_complete(struct net_device *netdev,\n \treturn rc;\n }\n \n+static void action_tx_fini(void *data)\n+{\n+\tstruct mctp_usblib_tx *tx = data;\n+\n+\tmctp_usblib_tx_fini(tx);\n+\tkfree(tx);\n+}\n+\n+static struct mctp_usblib_tx *\n+mctp_usblib_test_tx_init(struct kunit *test,\n+\t\t\t const struct mctp_usblib_tx_ops *ops,\n+\t\t\t void *priv, bool span)\n+{\n+\tstruct mctp_usblib_tx *tx;\n+\tint rc;\n+\n+\ttx = kzalloc_obj(*tx);\n+\tKUNIT_ASSERT_NOT_NULL(test, tx);\n+\trc = kunit_add_action_or_reset(test, action_tx_fini, tx);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\n+\tmctp_usblib_tx_init(tx, ops, priv, true);\n+\n+\treturn tx;\n+}\n+\n /* Single packet, starting on a transfer boundary, contained entirely within\n * the transfer\n */\n@@ -378,29 +518,413 @@ static const struct mctp_usblib_test_pkt_span mctp_usblib_test_pkt_spans[] = {\n \t{ \"1p1x-complete\", 1, { 8 }, 1, { 8 } },\n \t/* Two small packets combined within one transfer */\n \t{ \"2p1x-combined\", 2, { 8, 8 }, 1, { 16 } },\n-\t/* A packet split over two transfers, at the MCTP payload */\n-\t{ \"1p2x-split-payload\", 1, { 16 }, 2, { 8, 8 } },\n-\t/* A packet split over two transfers, at the USB transport header */\n-\t{ \"1p2x-split-usbhdr\", 1, { 16 }, 2, { 2, 14 } },\n-\t/* A packet split over two transfers, at the MCTP header */\n-\t{ \"1p2x-split-mctphdr\", 1, { 16 }, 2, { 6, 10 } },\n \t/* Single packet split over 3 transfers, middle entirely continuation */\n \t{ \"1p3x-split\", 1, { 12 }, 3, { 4, 4, 4 } },\n+\t/* A packet split over 5 transfers, splitting on and between each header. */\n+\t{ \"1p5x-split\", 1, { 12 }, 5, { 3, 1, 1, 3, 4}},\n \t/* Max-sized single transfer */\n \t{ \"1p1x-large\", 1, { 8191 }, 1, { 8191 } },\n \t/* Two large packets, split at the worst-case for allocation, with a\n \t * single byte continuing the span\n \t */\n-\t{ \"2p2x-large-split\", 2, { 8190, 8190 }, 2, { 8191, 8189 } },\n+\t{ \"2p2x-large-split\", 2, { 8190, 8191 }, 2, { 8191, 8190 } },\n+\t/* Three large packets, split at the worst-case for allocation,\n+\t * with a single byte continuing each span\n+\t */\n+\t{ \"3p3x-large-split\", 3, { 8190, 8191, 8191 }, 3, { 8191, 8191, 8190 } },\n };\n \n KUNIT_ARRAY_PARAM(mctp_usblib_test_rx_pkt_span, mctp_usblib_test_pkt_spans,\n \t\t mctp_usblib_test_pkt_span_to_desc);\n \n+static void mctp_usblib_test_rx_split_header(struct kunit *test, size_t offset,\n+\t\t\t\t\t struct mctp_usblib_test_dev *dev,\n+\t\t\t\t\t struct mctp_usblib_rx *rx)\n+{\n+\tstruct sk_buff *skb;\n+\tsize_t buflen, len;\n+\tu8 packet[16];\n+\tvoid *buf;\n+\tint rc;\n+\n+\tlen = sizeof(packet);\n+\tmctp_usblib_test_init_pkt(packet, len, len);\n+\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen, GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\n+\tmemcpy(buf, packet, offset);\n+\tmctp_usblib_rx_complete(dev-\u003endev, rx, offset);\n+\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen,\n+\t\t\t\t GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\tKUNIT_ASSERT_EQ(test, dev-\u003erx_pkts.qlen, 0);\n+\n+\tmemcpy(buf, packet + offset, len - offset);\n+\tmctp_usblib_rx_complete(dev-\u003endev, rx, len - offset);\n+\tKUNIT_EXPECT_EQ(test, dev-\u003erx_pkts.qlen, 1);\n+\n+\tskb = __skb_dequeue(\u0026dev-\u003erx_pkts);\n+\tKUNIT_EXPECT_NOT_NULL(test, skb);\n+\tif (skb)\n+\t\tKUNIT_EXPECT_EQ(test, skb-\u003elen, len - HDR_LEN);\n+}\n+\n+static void mctp_usblib_test_rx_header_splits(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_dev *dev;\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_rx *rx;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\trx = mctp_usblib_test_rx_init(test, true);\n+\tdev = ctx-\u003edev;\n+\n+\t/* Unrolling here so stack traces point to the invocation with the\n+\t * failing length.\n+\t */\n+\tmctp_usblib_test_rx_split_header(test, 1, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 2, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 3, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 4, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 5, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 6, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 7, dev, rx);\n+\tmctp_usblib_test_rx_split_header(test, 8, dev, rx);\n+}\n+\n+/* Test the submission of a packet with an impossibly small value in the\n+ * header's length field. Values less than HDR_LEN are invalid.\n+ */\n+static void mctp_usblib_test_rx_short_packet(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_dev *dev;\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_rx *rx;\n+\tsize_t len, buflen;\n+\tu8 pktbuf[12];\n+\tvoid *buf;\n+\tint rc;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\trx = mctp_usblib_test_rx_init(test, true);\n+\tdev = ctx-\u003edev;\n+\n+\tlen = sizeof(pktbuf);\n+\tmctp_usblib_test_init_pkt(pktbuf, len, HDR_LEN - 1);\n+\n+\tbuflen = 0;\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen, GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\n+\tmemcpy(buf, pktbuf, len);\n+\n+\trc = mctp_usblib_rx_complete(dev-\u003endev, rx, len);\n+\tKUNIT_EXPECT_EQ(test, rc, -EPROTO);\n+\tKUNIT_EXPECT_NULL(test, rx-\u003eskb);\n+\tKUNIT_EXPECT_EQ(test, dev-\u003erx_pkts.qlen, 0);\n+}\n+\n+static void mctp_usblib_test_rx_invalid_dmtf_id(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_dev *dev;\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_rx *rx;\n+\tsize_t len, buflen;\n+\tu8 pktbuf[12];\n+\tvoid *buf;\n+\tint rc;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\trx = mctp_usblib_test_rx_init(test, true);\n+\tdev = ctx-\u003edev;\n+\n+\tlen = sizeof(pktbuf);\n+\tmctp_usblib_test_init_pkt(pktbuf, len, len);\n+\n+\t// Make packet DMTF ID invalid\n+\tpktbuf[1] = ~pktbuf[1];\n+\n+\tbuflen = 0;\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen, GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\n+\tmemcpy(buf, pktbuf, len);\n+\n+\trc = mctp_usblib_rx_complete(dev-\u003endev, rx, len);\n+\tKUNIT_EXPECT_EQ(test, rc, -EPROTO);\n+\tKUNIT_EXPECT_NULL(test, rx-\u003eskb);\n+\tKUNIT_EXPECT_EQ(test, dev-\u003erx_pkts.qlen, 0);\n+}\n+\n+static void mctp_usblib_test_rx_nonspanning_tiny(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_dev *dev;\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_rx *rx;\n+\tsize_t len, buflen;\n+\tu8 pktbuf[3];\n+\tvoid *buf;\n+\tint rc;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\trx = mctp_usblib_test_rx_init(test, false);\n+\tdev = ctx-\u003edev;\n+\n+\tlen = sizeof(pktbuf);\n+\tmctp_usblib_test_init_pkt(pktbuf, len, len);\n+\n+\tbuflen = 0;\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen, GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\n+\tmemcpy(buf, pktbuf, len);\n+\n+\trc = mctp_usblib_rx_complete(dev-\u003endev, rx, len);\n+\tKUNIT_EXPECT_EQ(test, rc, -ENOMSG);\n+\tKUNIT_EXPECT_NULL(test, rx-\u003eskb);\n+\tKUNIT_EXPECT_EQ(test, dev-\u003erx_pkts.qlen, 0);\n+}\n+\n+static void mctp_usblib_test_rx_nonspanning_partial(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_dev *dev;\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_rx *rx;\n+\tsize_t len, buflen;\n+\tu8 pktbuf[20];\n+\tvoid *buf;\n+\tint rc;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\trx = mctp_usblib_test_rx_init(test, false);\n+\tdev = ctx-\u003edev;\n+\n+\tlen = sizeof(pktbuf);\n+\tmctp_usblib_test_init_pkt(pktbuf, len, len + 1);\n+\n+\tbuflen = 0;\n+\trc = mctp_usblib_rx_prepare(dev-\u003endev, rx, \u0026buf, \u0026buflen, GFP_KERNEL);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_GE(test, buflen, len);\n+\n+\tmemcpy(buf, pktbuf, len);\n+\n+\trc = mctp_usblib_rx_complete(dev-\u003endev, rx, len);\n+\tKUNIT_EXPECT_EQ(test, rc, -EPROTO);\n+\tKUNIT_EXPECT_NULL(test, rx-\u003eskb);\n+\tKUNIT_EXPECT_EQ(test, dev-\u003erx_pkts.qlen, 0);\n+}\n+\n+static void mctp_usblib_test_tx_pkt_span(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_tx_ops ops;\n+\tstruct mctp_usblib_tx *tx;\n+\tstruct mctp_usb_hdr head;\n+\tstruct net_device *ndev;\n+\tstruct sk_buff *skb;\n+\tsize_t len, tx_len;\n+\tu8 *buf, *flat_tx;\n+\tint rc;\n+\n+\tlen = 1000;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\tndev = ctx-\u003edev-\u003endev;\n+\n+\tops.send = mctp_usblib_test_tx_send;\n+\n+\ttx = mctp_usblib_test_tx_init(test, \u0026ops, ctx, true);\n+\n+\tbuf = mctp_usblib_test_init_buf(test, len);\n+\tmctp_usblib_test_fill_head(\u0026head, len);\n+\n+\tskb = mctp_usblib_test_init_skb(test, len, ndev, buf);\n+\n+\trc = mctp_usblib_tx_push(ndev, tx, skb, false);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\tKUNIT_ASSERT_FALSE(test, list_empty(\u0026ctx-\u003etx_xfers));\n+\n+\tflat_tx = mctp_usblib_test_flatten_tx_buff(test, \u0026ctx-\u003etx_xfers,\n+\t\t\t\t\t\t \u0026tx_len);\n+\tKUNIT_ASSERT_NOT_NULL(test, flat_tx);\n+\n+\tKUNIT_EXPECT_EQ(test, tx_len, len + HDR_LEN);\n+\tKUNIT_EXPECT_MEMEQ(test, flat_tx, \u0026head, HDR_LEN);\n+\tKUNIT_EXPECT_MEMEQ(test, flat_tx + HDR_LEN, buf, len);\n+}\n+\n+static void mctp_usblib_test_tx_failing_send(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_tx_ops ops;\n+\tstruct mctp_usblib_tx *tx;\n+\tstruct net_device *ndev;\n+\tstruct sk_buff *skb;\n+\tsize_t len;\n+\tu8 *buf;\n+\tint rc;\n+\n+\tlen = 100;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\tndev = ctx-\u003edev-\u003endev;\n+\n+\tops.send = mctp_usblib_test_tx_send_fail;\n+\n+\ttx = mctp_usblib_test_tx_init(test, \u0026ops, ctx, false);\n+\tbuf = mctp_usblib_test_init_buf(test, len);\n+\tskb = mctp_usblib_test_init_skb(test, len, ndev, buf);\n+\n+\t/* Doesn't call ops.send as more packets are expected,\n+\t * so the push shouldn't fail.\n+\t */\n+\trc = mctp_usblib_tx_push(ndev, tx, skb, true);\n+\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\n+\tskb = mctp_usblib_test_init_skb(test, len, ndev, buf);\n+\n+\t/* Calls ops.send as no further packets are expected. */\n+\trc = mctp_usblib_tx_push(ndev, tx, skb, false);\n+\tKUNIT_EXPECT_EQ(test, rc, 0);\n+\tKUNIT_EXPECT_NULL(test, tx-\u003ecur_ctx);\n+\tKUNIT_EXPECT_TRUE(test, list_empty(\u0026ctx-\u003etx_xfers));\n+}\n+\n+/* Test sending multiple packets in the same transfer, followed by one that\n+ * spans multiple subsequent transfers.\n+ */\n+static void mctp_usblib_test_tx_multi_push(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tsize_t i, max_length, tx_length;\n+\tstruct mctp_usblib_tx_ops ops;\n+\tu8 *buf, *flat_tx, *index;\n+\tstruct mctp_usblib_tx *tx;\n+\tstruct net_device *ndev;\n+\tstruct sk_buff *skb;\n+\tconst struct {\n+\t\tsize_t len;\n+\t\tbool more;\n+\t} sends[] = {\n+\t\t{ 1000, true },\n+\t\t{ 500, false },\n+\t\t{ 5000, false },\n+\t};\n+\tint rc;\n+\n+\tstatic_assert(!sends[ARRAY_SIZE(sends) - 1].more,\n+\t\t \"The last push must claim there will be no more\");\n+\n+\tmax_length = 0;\n+\tfor (i = 0; i \u003c ARRAY_SIZE(sends); i++) {\n+\t\tif (sends[i].len \u003e max_length)\n+\t\t\tmax_length = sends[i].len;\n+\t}\n+\n+\tctx = mctp_usblib_test_init(test);\n+\tndev = ctx-\u003edev-\u003endev;\n+\n+\tops.send = mctp_usblib_test_tx_send;\n+\n+\ttx = mctp_usblib_test_tx_init(test, \u0026ops, ctx, true);\n+\tbuf = mctp_usblib_test_init_buf(test, max_length);\n+\n+\tfor (i = 0; i \u003c ARRAY_SIZE(sends); i++) {\n+\t\tskb = mctp_usblib_test_init_skb(test, sends[i].len, ndev, buf);\n+\n+\t\trc = mctp_usblib_tx_push(ndev, tx, skb, sends[i].more);\n+\t\tKUNIT_ASSERT_EQ(test, rc, 0);\n+\t}\n+\tKUNIT_ASSERT_FALSE(test, list_empty(\u0026ctx-\u003etx_xfers));\n+\n+\tflat_tx = mctp_usblib_test_flatten_tx_buff(test, \u0026ctx-\u003etx_xfers,\n+\t\t\t\t\t\t \u0026tx_length);\n+\n+\tfor (i = 0, index = flat_tx; i \u003c ARRAY_SIZE(sends); i++) {\n+\t\tsize_t length_to_check, remaining_bytes;\n+\t\tstruct mctp_usb_hdr head;\n+\n+\t\tif (index - flat_tx \u003e= tx_length - HDR_LEN)\n+\t\t\tbreak;\n+\n+\t\tmctp_usblib_test_fill_head(\u0026head, sends[i].len);\n+\t\tKUNIT_EXPECT_MEMEQ(test, index, \u0026head, HDR_LEN);\n+\t\tindex += HDR_LEN;\n+\t\tremaining_bytes = tx_length - (index - flat_tx);\n+\n+\t\tlength_to_check = sends[i].len;\n+\t\tKUNIT_EXPECT_GE(test, remaining_bytes, length_to_check);\n+\t\tlength_to_check = min(remaining_bytes, length_to_check);\n+\n+\t\tKUNIT_EXPECT_MEMEQ(test, index,\n+\t\t\t\t buf, length_to_check);\n+\n+\t\tindex += length_to_check;\n+\t}\n+\tKUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(sends));\n+}\n+\n+static void mctp_usblib_test_tx_overflow(struct kunit *test)\n+{\n+\tstruct mctp_usblib_test_ctx *ctx;\n+\tstruct mctp_usblib_tx_ops ops;\n+\tstruct pcpu_dstats *dstats;\n+\tstruct mctp_usblib_tx *tx;\n+\tstruct net_device *ndev;\n+\tstruct sk_buff *skb;\n+\tunsigned int start;\n+\tsize_t len, i;\n+\tu64 stats;\n+\tu8 *buf;\n+\tint rc;\n+\n+\tlen = 200;\n+\n+\tctx = mctp_usblib_test_init(test);\n+\tndev = ctx-\u003edev-\u003endev;\n+\n+\tops.send = mctp_usblib_test_tx_send_fail;\n+\n+\ttx = mctp_usblib_test_tx_init(test, \u0026ops, ctx, false);\n+\tbuf = mctp_usblib_test_init_buf(test, len);\n+\n+\tfor (i = 0; i \u003c 3; i++) {\n+\t\tskb = mctp_usblib_test_init_skb(test, len, ndev, buf);\n+\n+\t\trc = mctp_usblib_tx_push(ndev, tx, skb, i != 2);\n+\t\tKUNIT_EXPECT_EQ(test, rc, 0);\n+\t}\n+\n+\tdstats = get_cpu_ptr(ndev-\u003edstats);\n+\tdo {\n+\t\tstart = u64_stats_fetch_begin(\u0026dstats-\u003esyncp);\n+\t\tstats = u64_stats_read(\u0026dstats-\u003etx_drops);\n+\t} while (u64_stats_fetch_retry(\u0026dstats-\u003esyncp, start));\n+\n+\tKUNIT_EXPECT_EQ(test, stats, 3);\n+}\n+\n static struct kunit_case mctp_usblib_test_cases[] = {\n \tKUNIT_CASE(mctp_usblib_test_rx_single),\n \tKUNIT_CASE_PARAM(mctp_usblib_test_rx_pkt_span,\n \t\t\t mctp_usblib_test_rx_pkt_span_gen_params),\n+\tKUNIT_CASE(mctp_usblib_test_rx_header_splits),\n+\tKUNIT_CASE(mctp_usblib_test_rx_short_packet),\n+\tKUNIT_CASE(mctp_usblib_test_rx_invalid_dmtf_id),\n+\tKUNIT_CASE(mctp_usblib_test_rx_nonspanning_tiny),\n+\tKUNIT_CASE(mctp_usblib_test_rx_nonspanning_partial),\n+\tKUNIT_CASE(mctp_usblib_test_tx_pkt_span),\n+\tKUNIT_CASE(mctp_usblib_test_tx_multi_push),\n+\tKUNIT_CASE(mctp_usblib_test_tx_failing_send),\n+\tKUNIT_CASE(mctp_usblib_test_tx_overflow),\n \t{}\n };\n \n"
} |
| 2/1 | 2026/08/31 04:12 | agent | patch-evaluator |
0mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch only adds and updates KUnit test cases in drivers/net/mctp/mctp-usblib-test.c. It does not introduce or modify any core kernel logic, runtime driver execution paths, or fuzzable interfaces.",
"WorthFuzzing": false
}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 ce0bba4044cbf9dcd1bc9a86bd2187fda6fead37
Author: syz-cluster <triage@syzkaller.com>
Date: Mon Aug 31 04:12:34 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/mctp/mctp-usblib-test.c b/drivers/net/mctp/mctp-usblib-test.c
index 9df401a914ff5..b3a2cc5cbd99d 100644
--- a/drivers/net/mctp/mctp-usblib-test.c
+++ b/drivers/net/mctp/mctp-usblib-test.c
@@ -6,6 +6,8 @@
* Copyright (C) 2026 Code Construct Pty Ltd
*/
+#include "linux/percpu-defs.h"
+#include <linux/array_size.h>
#include <uapi/linux/netdevice.h>
#include <linux/netdevice.h>
#include <kunit/test.h>
@@ -14,6 +16,15 @@
#include <net/mctpdevice.h>
#include <linux/usb/mctp-usb.h>
+#define HDR_LEN sizeof(struct mctp_usb_hdr)
+
+struct tx_buff {
+ struct list_head list;
+
+ size_t length;
+ u8 data[] __counted_by(length);
+};
+
struct mctp_usblib_test_dev {
struct net_device *ndev;
struct mctp_dev *mdev;
@@ -22,9 +33,110 @@ struct mctp_usblib_test_dev {
struct mctp_usblib_test_ctx {
struct mctp_usblib_test_dev *dev;
+ struct list_head tx_xfers;
struct mctp_route rt;
};
+static int mctp_usblib_test_tx_send(struct mctp_usblib_tx_ctx *tx_ctx,
+ void *data, size_t len)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ struct tx_buff *new_node;
+ struct net_device *ndev;
+ int rc;
+
+ ctx = mctp_usblib_tx_ctx_priv(tx_ctx);
+ ndev = ctx->dev->ndev;
+ rc = 0;
+
+ new_node = kzalloc_flex(*new_node, data, len, GFP_KERNEL);
+ if (!new_node) {
+ rc = -ENOMEM;
+ goto exit;
+ }
+
+ new_node->length = len;
+ memcpy(&new_node->data, data, len);
+ list_add_tail(&new_node->list, &ctx->tx_xfers);
+
+exit:
+ mctp_usblib_tx_send_complete(tx_ctx, ndev, rc == 0);
+ return rc;
+}
+
+static int mctp_usblib_test_tx_send_fail(struct mctp_usblib_tx_ctx *tx_ctx,
+ void *data, size_t len)
+{
+ return -ENOMEM;
+}
+
+static u8 *mctp_usblib_test_flatten_tx_buff(struct kunit *test,
+ struct list_head *in,
+ size_t *length_out)
+{
+ struct tx_buff *pos;
+ size_t length;
+ u8 *buf, *tail;
+
+ KUNIT_ASSERT_TRUE(test, length_out);
+ KUNIT_ASSERT_TRUE(test, in);
+
+ length = 0;
+ list_for_each_entry(pos, in, list)
+ length = size_add(length, pos->length);
+
+ KUNIT_ASSERT_NE(test, length, 0);
+ KUNIT_ASSERT_NE(test, length, SIZE_MAX);
+
+ buf = kunit_kzalloc(test, length, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, buf);
+
+ tail = buf;
+ list_for_each_entry(pos, in, list) {
+ memcpy(tail, pos->data, pos->length);
+ tail += pos->length;
+ }
+
+ *length_out = length;
+ return buf;
+}
+
+static u8 *mctp_usblib_test_init_buf(struct kunit *test, size_t length)
+{
+ u8 *buffer;
+ size_t i;
+
+ buffer = kunit_kzalloc(test, length, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, buffer);
+
+ for (i = 0; i < length; i++)
+ buffer[i] = i % 256;
+
+ return buffer;
+}
+
+static void mctp_usblib_test_fill_head(struct mctp_usb_hdr *head, size_t len)
+{
+ len += HDR_LEN;
+ head->id = cpu_to_be16(MCTP_USB_DMTF_ID);
+ head->len = cpu_to_be16(len & MCTP_USB_1_1_PKTLEN_MAX);
+}
+
+static struct sk_buff *mctp_usblib_test_init_skb(struct kunit *test,
+ unsigned int length,
+ struct net_device *ndev,
+ void *data)
+{
+ struct sk_buff *skb;
+
+ skb = __netdev_alloc_skb(ndev, length, GFP_KERNEL);
+ KUNIT_ASSERT_NOT_NULL(test, skb);
+
+ skb->len = length;
+ memcpy(skb->data, data, length);
+ return skb;
+}
+
static netdev_tx_t mctp_usblib_dev_tx(struct sk_buff *skb,
struct net_device *ndev)
{
@@ -117,6 +229,7 @@ static int mctp_usblib_test_dst_output(struct mctp_dst *dst,
static void mctp_usblib_test_fini_action(void *data)
{
struct mctp_usblib_test_ctx *ctx = data;
+ struct tx_buff *curr, *temp;
/* The device will have been destroyed, so ->rt will be unlinked.
* Just ensure that the refcount is as expected.
@@ -124,6 +237,8 @@ static void mctp_usblib_test_fini_action(void *data)
KUNIT_EXPECT_TRUE(current->kunit_test,
refcount_dec_and_test(&ctx->rt.refs));
+ list_for_each_entry_safe(curr, temp, &ctx->tx_xfers, list)
+ kfree(curr);
kfree(ctx);
}
@@ -139,6 +254,7 @@ static struct mctp_usblib_test_ctx *mctp_usblib_test_init(struct kunit *test)
INIT_LIST_HEAD(&ctx->rt.list);
rt = &ctx->rt;
refcount_set(&rt->refs, 1);
+ INIT_LIST_HEAD(&ctx->tx_xfers);
rc = kunit_add_action_or_reset(test, mctp_usblib_test_fini_action, ctx);
KUNIT_ASSERT_EQ(test, rc, 0);
@@ -200,11 +316,9 @@ mctp_usblib_test_rx_init(struct kunit *test, bool span)
int rc;
rx = kzalloc_obj(*rx);
- if (rx) {
- rc = kunit_add_action_or_reset(test, action_rx_fini, rx);
- KUNIT_ASSERT_EQ(test, rc, 0);
- }
KUNIT_ASSERT_NOT_NULL(test, rx);
+ rc = kunit_add_action_or_reset(test, action_rx_fini, rx);
+ KUNIT_ASSERT_EQ(test, rc, 0);
rc = mctp_usblib_rx_init(rx, ep_maxpacket, span);
KUNIT_ASSERT_EQ(test, rc, 0);
@@ -227,6 +341,32 @@ static int mctp_usblib_test_rx_complete(struct net_device *netdev,
return rc;
}
+static void action_tx_fini(void *data)
+{
+ struct mctp_usblib_tx *tx = data;
+
+ mctp_usblib_tx_fini(tx);
+ kfree(tx);
+}
+
+static struct mctp_usblib_tx *
+mctp_usblib_test_tx_init(struct kunit *test,
+ const struct mctp_usblib_tx_ops *ops,
+ void *priv, bool span)
+{
+ struct mctp_usblib_tx *tx;
+ int rc;
+
+ tx = kzalloc_obj(*tx);
+ KUNIT_ASSERT_NOT_NULL(test, tx);
+ rc = kunit_add_action_or_reset(test, action_tx_fini, tx);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+
+ mctp_usblib_tx_init(tx, ops, priv, true);
+
+ return tx;
+}
+
/* Single packet, starting on a transfer boundary, contained entirely within
* the transfer
*/
@@ -378,29 +518,413 @@ static const struct mctp_usblib_test_pkt_span mctp_usblib_test_pkt_spans[] = {
{ "1p1x-complete", 1, { 8 }, 1, { 8 } },
/* Two small packets combined within one transfer */
{ "2p1x-combined", 2, { 8, 8 }, 1, { 16 } },
- /* A packet split over two transfers, at the MCTP payload */
- { "1p2x-split-payload", 1, { 16 }, 2, { 8, 8 } },
- /* A packet split over two transfers, at the USB transport header */
- { "1p2x-split-usbhdr", 1, { 16 }, 2, { 2, 14 } },
- /* A packet split over two transfers, at the MCTP header */
- { "1p2x-split-mctphdr", 1, { 16 }, 2, { 6, 10 } },
/* Single packet split over 3 transfers, middle entirely continuation */
{ "1p3x-split", 1, { 12 }, 3, { 4, 4, 4 } },
+ /* A packet split over 5 transfers, splitting on and between each header. */
+ { "1p5x-split", 1, { 12 }, 5, { 3, 1, 1, 3, 4}},
/* Max-sized single transfer */
{ "1p1x-large", 1, { 8191 }, 1, { 8191 } },
/* Two large packets, split at the worst-case for allocation, with a
* single byte continuing the span
*/
- { "2p2x-large-split", 2, { 8190, 8190 }, 2, { 8191, 8189 } },
+ { "2p2x-large-split", 2, { 8190, 8191 }, 2, { 8191, 8190 } },
+ /* Three large packets, split at the worst-case for allocation,
+ * with a single byte continuing each span
+ */
+ { "3p3x-large-split", 3, { 8190, 8191, 8191 }, 3, { 8191, 8191, 8190 } },
};
KUNIT_ARRAY_PARAM(mctp_usblib_test_rx_pkt_span, mctp_usblib_test_pkt_spans,
mctp_usblib_test_pkt_span_to_desc);
+static void mctp_usblib_test_rx_split_header(struct kunit *test, size_t offset,
+ struct mctp_usblib_test_dev *dev,
+ struct mctp_usblib_rx *rx)
+{
+ struct sk_buff *skb;
+ size_t buflen, len;
+ u8 packet[16];
+ void *buf;
+ int rc;
+
+ len = sizeof(packet);
+ mctp_usblib_test_init_pkt(packet, len, len);
+
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen, GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+
+ memcpy(buf, packet, offset);
+ mctp_usblib_rx_complete(dev->ndev, rx, offset);
+
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen,
+ GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+ KUNIT_ASSERT_EQ(test, dev->rx_pkts.qlen, 0);
+
+ memcpy(buf, packet + offset, len - offset);
+ mctp_usblib_rx_complete(dev->ndev, rx, len - offset);
+ KUNIT_EXPECT_EQ(test, dev->rx_pkts.qlen, 1);
+
+ skb = __skb_dequeue(&dev->rx_pkts);
+ KUNIT_EXPECT_NOT_NULL(test, skb);
+ if (skb)
+ KUNIT_EXPECT_EQ(test, skb->len, len - HDR_LEN);
+}
+
+static void mctp_usblib_test_rx_header_splits(struct kunit *test)
+{
+ struct mctp_usblib_test_dev *dev;
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_rx *rx;
+
+ ctx = mctp_usblib_test_init(test);
+ rx = mctp_usblib_test_rx_init(test, true);
+ dev = ctx->dev;
+
+ /* Unrolling here so stack traces point to the invocation with the
+ * failing length.
+ */
+ mctp_usblib_test_rx_split_header(test, 1, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 2, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 3, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 4, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 5, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 6, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 7, dev, rx);
+ mctp_usblib_test_rx_split_header(test, 8, dev, rx);
+}
+
+/* Test the submission of a packet with an impossibly small value in the
+ * header's length field. Values less than HDR_LEN are invalid.
+ */
+static void mctp_usblib_test_rx_short_packet(struct kunit *test)
+{
+ struct mctp_usblib_test_dev *dev;
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_rx *rx;
+ size_t len, buflen;
+ u8 pktbuf[12];
+ void *buf;
+ int rc;
+
+ ctx = mctp_usblib_test_init(test);
+ rx = mctp_usblib_test_rx_init(test, true);
+ dev = ctx->dev;
+
+ len = sizeof(pktbuf);
+ mctp_usblib_test_init_pkt(pktbuf, len, HDR_LEN - 1);
+
+ buflen = 0;
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen, GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+
+ memcpy(buf, pktbuf, len);
+
+ rc = mctp_usblib_rx_complete(dev->ndev, rx, len);
+ KUNIT_EXPECT_EQ(test, rc, -EPROTO);
+ KUNIT_EXPECT_NULL(test, rx->skb);
+ KUNIT_EXPECT_EQ(test, dev->rx_pkts.qlen, 0);
+}
+
+static void mctp_usblib_test_rx_invalid_dmtf_id(struct kunit *test)
+{
+ struct mctp_usblib_test_dev *dev;
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_rx *rx;
+ size_t len, buflen;
+ u8 pktbuf[12];
+ void *buf;
+ int rc;
+
+ ctx = mctp_usblib_test_init(test);
+ rx = mctp_usblib_test_rx_init(test, true);
+ dev = ctx->dev;
+
+ len = sizeof(pktbuf);
+ mctp_usblib_test_init_pkt(pktbuf, len, len);
+
+ // Make packet DMTF ID invalid
+ pktbuf[1] = ~pktbuf[1];
+
+ buflen = 0;
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen, GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+
+ memcpy(buf, pktbuf, len);
+
+ rc = mctp_usblib_rx_complete(dev->ndev, rx, len);
+ KUNIT_EXPECT_EQ(test, rc, -EPROTO);
+ KUNIT_EXPECT_NULL(test, rx->skb);
+ KUNIT_EXPECT_EQ(test, dev->rx_pkts.qlen, 0);
+}
+
+static void mctp_usblib_test_rx_nonspanning_tiny(struct kunit *test)
+{
+ struct mctp_usblib_test_dev *dev;
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_rx *rx;
+ size_t len, buflen;
+ u8 pktbuf[3];
+ void *buf;
+ int rc;
+
+ ctx = mctp_usblib_test_init(test);
+ rx = mctp_usblib_test_rx_init(test, false);
+ dev = ctx->dev;
+
+ len = sizeof(pktbuf);
+ mctp_usblib_test_init_pkt(pktbuf, len, len);
+
+ buflen = 0;
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen, GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+
+ memcpy(buf, pktbuf, len);
+
+ rc = mctp_usblib_rx_complete(dev->ndev, rx, len);
+ KUNIT_EXPECT_EQ(test, rc, -ENOMSG);
+ KUNIT_EXPECT_NULL(test, rx->skb);
+ KUNIT_EXPECT_EQ(test, dev->rx_pkts.qlen, 0);
+}
+
+static void mctp_usblib_test_rx_nonspanning_partial(struct kunit *test)
+{
+ struct mctp_usblib_test_dev *dev;
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_rx *rx;
+ size_t len, buflen;
+ u8 pktbuf[20];
+ void *buf;
+ int rc;
+
+ ctx = mctp_usblib_test_init(test);
+ rx = mctp_usblib_test_rx_init(test, false);
+ dev = ctx->dev;
+
+ len = sizeof(pktbuf);
+ mctp_usblib_test_init_pkt(pktbuf, len, len + 1);
+
+ buflen = 0;
+ rc = mctp_usblib_rx_prepare(dev->ndev, rx, &buf, &buflen, GFP_KERNEL);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_GE(test, buflen, len);
+
+ memcpy(buf, pktbuf, len);
+
+ rc = mctp_usblib_rx_complete(dev->ndev, rx, len);
+ KUNIT_EXPECT_EQ(test, rc, -EPROTO);
+ KUNIT_EXPECT_NULL(test, rx->skb);
+ KUNIT_EXPECT_EQ(test, dev->rx_pkts.qlen, 0);
+}
+
+static void mctp_usblib_test_tx_pkt_span(struct kunit *test)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_tx_ops ops;
+ struct mctp_usblib_tx *tx;
+ struct mctp_usb_hdr head;
+ struct net_device *ndev;
+ struct sk_buff *skb;
+ size_t len, tx_len;
+ u8 *buf, *flat_tx;
+ int rc;
+
+ len = 1000;
+
+ ctx = mctp_usblib_test_init(test);
+ ndev = ctx->dev->ndev;
+
+ ops.send = mctp_usblib_test_tx_send;
+
+ tx = mctp_usblib_test_tx_init(test, &ops, ctx, true);
+
+ buf = mctp_usblib_test_init_buf(test, len);
+ mctp_usblib_test_fill_head(&head, len);
+
+ skb = mctp_usblib_test_init_skb(test, len, ndev, buf);
+
+ rc = mctp_usblib_tx_push(ndev, tx, skb, false);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ KUNIT_ASSERT_FALSE(test, list_empty(&ctx->tx_xfers));
+
+ flat_tx = mctp_usblib_test_flatten_tx_buff(test, &ctx->tx_xfers,
+ &tx_len);
+ KUNIT_ASSERT_NOT_NULL(test, flat_tx);
+
+ KUNIT_EXPECT_EQ(test, tx_len, len + HDR_LEN);
+ KUNIT_EXPECT_MEMEQ(test, flat_tx, &head, HDR_LEN);
+ KUNIT_EXPECT_MEMEQ(test, flat_tx + HDR_LEN, buf, len);
+}
+
+static void mctp_usblib_test_tx_failing_send(struct kunit *test)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_tx_ops ops;
+ struct mctp_usblib_tx *tx;
+ struct net_device *ndev;
+ struct sk_buff *skb;
+ size_t len;
+ u8 *buf;
+ int rc;
+
+ len = 100;
+
+ ctx = mctp_usblib_test_init(test);
+ ndev = ctx->dev->ndev;
+
+ ops.send = mctp_usblib_test_tx_send_fail;
+
+ tx = mctp_usblib_test_tx_init(test, &ops, ctx, false);
+ buf = mctp_usblib_test_init_buf(test, len);
+ skb = mctp_usblib_test_init_skb(test, len, ndev, buf);
+
+ /* Doesn't call ops.send as more packets are expected,
+ * so the push shouldn't fail.
+ */
+ rc = mctp_usblib_tx_push(ndev, tx, skb, true);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+
+ skb = mctp_usblib_test_init_skb(test, len, ndev, buf);
+
+ /* Calls ops.send as no further packets are expected. */
+ rc = mctp_usblib_tx_push(ndev, tx, skb, false);
+ KUNIT_EXPECT_EQ(test, rc, 0);
+ KUNIT_EXPECT_NULL(test, tx->cur_ctx);
+ KUNIT_EXPECT_TRUE(test, list_empty(&ctx->tx_xfers));
+}
+
+/* Test sending multiple packets in the same transfer, followed by one that
+ * spans multiple subsequent transfers.
+ */
+static void mctp_usblib_test_tx_multi_push(struct kunit *test)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ size_t i, max_length, tx_length;
+ struct mctp_usblib_tx_ops ops;
+ u8 *buf, *flat_tx, *index;
+ struct mctp_usblib_tx *tx;
+ struct net_device *ndev;
+ struct sk_buff *skb;
+ const struct {
+ size_t len;
+ bool more;
+ } sends[] = {
+ { 1000, true },
+ { 500, false },
+ { 5000, false },
+ };
+ int rc;
+
+ static_assert(!sends[ARRAY_SIZE(sends) - 1].more,
+ "The last push must claim there will be no more");
+
+ max_length = 0;
+ for (i = 0; i < ARRAY_SIZE(sends); i++) {
+ if (sends[i].len > max_length)
+ max_length = sends[i].len;
+ }
+
+ ctx = mctp_usblib_test_init(test);
+ ndev = ctx->dev->ndev;
+
+ ops.send = mctp_usblib_test_tx_send;
+
+ tx = mctp_usblib_test_tx_init(test, &ops, ctx, true);
+ buf = mctp_usblib_test_init_buf(test, max_length);
+
+ for (i = 0; i < ARRAY_SIZE(sends); i++) {
+ skb = mctp_usblib_test_init_skb(test, sends[i].len, ndev, buf);
+
+ rc = mctp_usblib_tx_push(ndev, tx, skb, sends[i].more);
+ KUNIT_ASSERT_EQ(test, rc, 0);
+ }
+ KUNIT_ASSERT_FALSE(test, list_empty(&ctx->tx_xfers));
+
+ flat_tx = mctp_usblib_test_flatten_tx_buff(test, &ctx->tx_xfers,
+ &tx_length);
+
+ for (i = 0, index = flat_tx; i < ARRAY_SIZE(sends); i++) {
+ size_t length_to_check, remaining_bytes;
+ struct mctp_usb_hdr head;
+
+ if (index - flat_tx >= tx_length - HDR_LEN)
+ break;
+
+ mctp_usblib_test_fill_head(&head, sends[i].len);
+ KUNIT_EXPECT_MEMEQ(test, index, &head, HDR_LEN);
+ index += HDR_LEN;
+ remaining_bytes = tx_length - (index - flat_tx);
+
+ length_to_check = sends[i].len;
+ KUNIT_EXPECT_GE(test, remaining_bytes, length_to_check);
+ length_to_check = min(remaining_bytes, length_to_check);
+
+ KUNIT_EXPECT_MEMEQ(test, index,
+ buf, length_to_check);
+
+ index += length_to_check;
+ }
+ KUNIT_EXPECT_EQ(test, i, ARRAY_SIZE(sends));
+}
+
+static void mctp_usblib_test_tx_overflow(struct kunit *test)
+{
+ struct mctp_usblib_test_ctx *ctx;
+ struct mctp_usblib_tx_ops ops;
+ struct pcpu_dstats *dstats;
+ struct mctp_usblib_tx *tx;
+ struct net_device *ndev;
+ struct sk_buff *skb;
+ unsigned int start;
+ size_t len, i;
+ u64 stats;
+ u8 *buf;
+ int rc;
+
+ len = 200;
+
+ ctx = mctp_usblib_test_init(test);
+ ndev = ctx->dev->ndev;
+
+ ops.send = mctp_usblib_test_tx_send_fail;
+
+ tx = mctp_usblib_test_tx_init(test, &ops, ctx, false);
+ buf = mctp_usblib_test_init_buf(test, len);
+
+ for (i = 0; i < 3; i++) {
+ skb = mctp_usblib_test_init_skb(test, len, ndev, buf);
+
+ rc = mctp_usblib_tx_push(ndev, tx, skb, i != 2);
+ KUNIT_EXPECT_EQ(test, rc, 0);
+ }
+
+ dstats = get_cpu_ptr(ndev->dstats);
+ do {
+ start = u64_stats_fetch_begin(&dstats->syncp);
+ stats = u64_stats_read(&dstats->tx_drops);
+ } while (u64_stats_fetch_retry(&dstats->syncp, start));
+
+ KUNIT_EXPECT_EQ(test, stats, 3);
+}
+
static struct kunit_case mctp_usblib_test_cases[] = {
KUNIT_CASE(mctp_usblib_test_rx_single),
KUNIT_CASE_PARAM(mctp_usblib_test_rx_pkt_span,
mctp_usblib_test_rx_pkt_span_gen_params),
+ KUNIT_CASE(mctp_usblib_test_rx_header_splits),
+ KUNIT_CASE(mctp_usblib_test_rx_short_packet),
+ KUNIT_CASE(mctp_usblib_test_rx_invalid_dmtf_id),
+ KUNIT_CASE(mctp_usblib_test_rx_nonspanning_tiny),
+ KUNIT_CASE(mctp_usblib_test_rx_nonspanning_partial),
+ KUNIT_CASE(mctp_usblib_test_tx_pkt_span),
+ KUNIT_CASE(mctp_usblib_test_tx_multi_push),
+ KUNIT_CASE(mctp_usblib_test_tx_failing_send),
+ KUNIT_CASE(mctp_usblib_test_tx_overflow),
{}
};
|
| 3/2 | 2026/08/31 04:12 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 10394 output: 36 thoughts: 591 Thoughts: **Analyzing the Patch for Fuzzing Suitability** Okay, let's break this down. First, I need to understand this patch. It looks like the change is *only* to `drivers/net/mctp/mctp-usblib-test.c`. But I need to be absolutely sure; let's double-check the commit details to confirm that's the only modified file. Alright, the diff confirms it's just `mctp-usblib-test.c`. Now, the key question: what's in this file? It looks like KUnit test cases are being added. Now, this raises a flag, because I have to determine if these tests constitute "reachable core kernel logic" that's fuzzable. I need to be extremely precise here. Hold on a second, let's verify what the instructions say. They give a very specific set of conditions where a patch should *not* be considered for fuzzing. Documentation, Kconfig, comments, cosmetic logging, constant changes without functional impact, unreachable code in virtualized environments... these are all no-gos. Vendor-specific hardware drivers that can't be emulated are also excluded, and teardown callbacks that are executed only during hot-unplug or sysfs driver unbind operations. Now, back to the KUnit tests. The core question is: are these tests executed as part of *normal* kernel operation, or are they only run during boot/module load? If they're just unit tests run during boot and are not part of runtime kernel logic, syscall entrypoints, or functional drivers, then they're probably *not* suitable for syzkaller-style fuzzing. I need to know if KUnit tests are considered non-functional or test-only. Let's do some digging. Time to search the repository or look at the file itself, and figure out what `drivers/net/mctp/mctp-usblib-test.c` *is*. I'll use a `grep` or just read the file directly, and check if it is part of the runtime driver. Then I can determine if this is worth fuzzing or not. |
| 4/2 | 2026/08/31 04:12 | tool | grepper |
0mArgs:{
"Expression": "mctp-usblib-test",
"PathPrefix": "drivers/net/mctp"
}Results: {
"Output": "drivers/net/mctp/mctp-usblib-test.c-2-/*\ndrivers/net/mctp/mctp-usblib-test.c:3: * mctp-usblib-test.c - MCTP-over-USB (DMTF DSP0283) transport helper library,\ndrivers/net/mctp/mctp-usblib-test.c-4- * unit test definitions.\n--\ndrivers/net/mctp/mctp-usblib.c=621=MODULE_DESCRIPTION(\"MCTP USB transport library\");\n--\ndrivers/net/mctp/mctp-usblib.c-623-#if IS_ENABLED(CONFIG_MCTP_TRANSPORT_USBLIB_TEST)\ndrivers/net/mctp/mctp-usblib.c:624:#include \"mctp-usblib-test.c\"\ndrivers/net/mctp/mctp-usblib.c-625-#endif\n"
} |
| 5/2 | 2026/08/31 04:12 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 11746 output: 25 thoughts: 31 Thoughts: Okay, let's dive into this. Here's my thought process on this: **Checking the MCTP USB Test Configuration** Right, so I need to understand something about the MCTP transport over USB, specifically if there's a test configuration option floating around somewhere. The most logical place to start looking for a definition like that is the main Kconfig file for the MCTP network drivers. Given that this is specifically related to USB, the file `drivers/net/mctp/Kconfig` seems like the most likely candidate for housing a configuration option related to the USB library and testing. I will go there. The specific Kconfig option I'm interested in is `CONFIG_MCTP_TRANSPORT_USBLIB_TEST`. It would make sense for this to be defined there, given this is specific to MCTP transport of USB. |
| 6/2 | 2026/08/31 04:12 | tool | grepper |
0mArgs:{
"Expression": "MCTP_TRANSPORT_USBLIB_TEST"
}Results: {
"Output": "drivers/net/mctp/Kconfig=50=config MCTP_TRANSPORT_USBLIB\n--\ndrivers/net/mctp/Kconfig-59-\ndrivers/net/mctp/Kconfig:60:config MCTP_TRANSPORT_USBLIB_TEST\ndrivers/net/mctp/Kconfig-61- bool \"MCTP usblib tests\" if !KUNIT_ALL_TESTS\n--\ndrivers/net/mctp/mctp-usblib.c=621=MODULE_DESCRIPTION(\"MCTP USB transport library\");\ndrivers/net/mctp/mctp-usblib.c-622-\ndrivers/net/mctp/mctp-usblib.c:623:#if IS_ENABLED(CONFIG_MCTP_TRANSPORT_USBLIB_TEST)\ndrivers/net/mctp/mctp-usblib.c-624-#include \"mctp-usblib-test.c\"\n"
} |
| 7/2 | 2026/08/31 04:12 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 12233 output: 37 thoughts: 22 Thoughts: Here's a summary of my thought process, as requested: **Navigating the MCTP Configuration Landscape** Okay, so I'm thinking I need to dive into the MCTP network driver configuration. Specifically, I'm going to head straight to the `drivers/net/mctp/Kconfig` file. I have a feeling the information I'm looking for is likely hanging around line 60, give or take. I'm going to start there and see what I can find regarding the configuration options. It's usually the best starting point when investigating these sorts of things. |
| 8/2 | 2026/08/31 04:12 | tool | read-file |
0mArgs:{
"File": "drivers/net/mctp/Kconfig",
"FirstLine": 45,
"LineCount": 40
}Results: {
"Contents": " 45:\t\t Provides a driver to access MCTP devices over I3C transport,\n 46:\t\t from DMTF specification DSP0233.\n 47:\t\t A MCTP protocol network device is created for each I3C bus\n 48:\t\t having a \"mctp-controller\" devicetree property.\n 49:\t\n 50:\tconfig MCTP_TRANSPORT_USBLIB\n 51:\t\ttristate \"MCTP over USB common library\"\n 52:\t\tdepends on USB\n 53:\t\thelp\n 54:\t\t Common protocol handling functions for MCTP-over-USB transport\n 55:\t\t implementations, suitable for use in either host- or gadget-side\n 56:\t\t transport driver\n 57:\t\n 58:\t\t This will be automatically enabled by the transport driver.\n 59:\t\n 60:\tconfig MCTP_TRANSPORT_USBLIB_TEST\n 61:\t bool \"MCTP usblib tests\" if !KUNIT_ALL_TESTS\n 62:\t depends on MCTP_TRANSPORT_USBLIB=y \u0026\u0026 KUNIT=y\n 63:\t default KUNIT_ALL_TESTS\n 64:\t\n 65:\tconfig MCTP_TRANSPORT_USB\n 66:\t\ttristate \"MCTP USB transport\"\n 67:\t\tdepends on USB\n 68:\t\tselect MCTP_TRANSPORT_USBLIB\n 69:\t\thelp\n 70:\t\t Provides a driver to access MCTP devices over USB transport,\n 71:\t\t defined by DMTF specification DSP0283.\n 72:\t\n 73:\t\t MCTP-over-USB interfaces are peer-to-peer, so each interface\n 74:\t\t represents a physical connection to one remote MCTP endpoint.\n 75:\t\n 76:\tendmenu\n 77:\t\n 78:\tendif\n"
} |
| 9/2 | 2026/08/31 04:12 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 12906 output: 83 thoughts: 549 Thoughts: **My Assessment of the Patch's Fuzzing Worthiness** Okay, after a close look at this patch, focusing on `drivers/net/mctp/mctp-usblib-test.c`, I've concluded that it's *not* worth fuzzing. The entire modification is contained within that single file, and it's solely dedicated to adding and modifying KUnit test cases. It seems that this patch is entirely about improving the testing of the `mctp-usblib` component. My thinking went like this: I know KUnit tests are unit tests, designed to be executed during boot or module load, specifically when KUnit is enabled. They are a valuable addition for verifying the internal correctness of the code but don't introduce or alter runtime kernel logic or driver functionality that's meant to be fuzzed by a tool like syzkaller. I then revisited the fuzzing guidelines and confirmed that this falls squarely into the category of patches that shouldn't be considered for fuzzing. Specifically, the guidelines state that modifications to test cases, like this one, don't warrant fuzzing. Therefore, I'm confident in the `WorthFuzzing=false` decision. The `Reasoning` will reflect the fact that the patch is isolated to KUnit test cases and doesn't touch any runtime interfaces or driver operational code. The `FocusSymbols` and `EnableConfigs` lists will be empty because, as a test case addition, there aren't any specific kernel symbols or configuration options that are being modified for functional use. I am now calling `set-results` with the appropriate parameters. |
| 10/2 | 2026/08/31 04:12 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The patch only adds and updates KUnit test cases in drivers/net/mctp/mctp-usblib-test.c. It does not introduce or modify any core kernel logic, runtime driver execution paths, or fuzzable interfaces.",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The patch only adds and updates KUnit test cases in drivers/net/mctp/mctp-usblib-test.c. It does not introduce or modify any core kernel logic, runtime driver execution paths, or fuzzable interfaces.",
"WorthFuzzing": false
} |
| 11/1 | 2026/08/31 04:12 | action | If |
0mArgs:{
"WorthFuzzing": false
}Results: null |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|