| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/10/13 22:50 | flow | patch-triage |
2mArgs:null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"KMSANReasoning": "",
"NeedsKMSAN": false,
"Reasoning": "The changes are confined to the IBM Virtual Ethernet driver (ibmveth), which depends on CONFIG_PPC_PSERIES. This code is exclusive to the PowerPC architecture and cannot be compiled or executed on the target architecture (amd64).",
"WorthFuzzing": false
} |
| 1/1 | 2026/10/13 22:50 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 9b041b26fe1121464d62d0a93b01b14a9c69801c\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Tue Oct 13 22:50:39 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c\nindex abebdb1fc2628..e9874dfedf378 100644\n--- a/drivers/net/ethernet/ibm/ibmveth.c\n+++ b/drivers/net/ethernet/ibm/ibmveth.c\n@@ -135,6 +135,13 @@ static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)\n \treturn be32_to_cpu(adapter-\u003erx_queue.queue_addr[adapter-\u003erx_queue.index].length);\n }\n \n+static u64 ibmveth_rxq_correlator(struct ibmveth_adapter *adapter)\n+{\n+\tunsigned int idx = adapter-\u003erx_queue.index;\n+\n+\treturn READ_ONCE(adapter-\u003erx_queue.queue_addr[idx].correlator);\n+}\n+\n static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter)\n {\n \treturn ibmveth_rxq_flags(adapter) \u0026 IBMVETH_RXQ_CSUM_GOOD;\n@@ -443,6 +450,37 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,\n \t}\n }\n \n+/* The correlator comes back from PHYP; a bad one schedules a reset. */\n+static bool ibmveth_rxq_correlator_valid(struct ibmveth_adapter *adapter,\n+\t\t\t\t\t u64 correlator)\n+{\n+\tunsigned int index = correlator \u0026 0xffffffffUL;\n+\tunsigned int pool = correlator \u003e\u003e 32;\n+\n+\t/* An inactive pool keeps its size but has no skbuff array. */\n+\tif (pool \u003c IBMVETH_NUM_BUFF_POOLS \u0026\u0026\n+\t index \u003c adapter-\u003erx_buff_pool[pool].size \u0026\u0026\n+\t adapter-\u003erx_buff_pool[pool].skbuff)\n+\t\treturn true;\n+\n+\tif (net_ratelimit())\n+\t\tnetdev_err(adapter-\u003enetdev,\n+\t\t\t \"invalid RX correlator %llx, resetting\\n\",\n+\t\t\t correlator);\n+\tschedule_work(\u0026adapter-\u003ework);\n+\treturn false;\n+}\n+\n+static void ibmveth_rxq_no_skb(struct ibmveth_adapter *adapter,\n+\t\t\t u64 correlator)\n+{\n+\tif (net_ratelimit())\n+\t\tnetdev_err(adapter-\u003enetdev,\n+\t\t\t \"no buffer for RX correlator %llx, resetting\\n\",\n+\t\t\t correlator);\n+\tschedule_work(\u0026adapter-\u003ework);\n+}\n+\n /**\n * ibmveth_remove_buffer_from_pool - remove a buffer from a pool\n * @adapter: adapter instance\n@@ -451,7 +489,8 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,\n *\n * Return:\n * * %0 - success\n- * * %-EINVAL - correlator maps to pool or index out of range\n+ * * %-EINVAL - correlator maps to pool or index out of range, or to an\n+ * inactive pool\n * * %-EFAULT - pool and index map to null skb\n */\n static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,\n@@ -462,15 +501,12 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,\n \tunsigned int free_index;\n \tstruct sk_buff *skb;\n \n-\tif (WARN_ON(pool \u003e= IBMVETH_NUM_BUFF_POOLS) ||\n-\t WARN_ON(index \u003e= adapter-\u003erx_buff_pool[pool].size)) {\n-\t\tschedule_work(\u0026adapter-\u003ework);\n+\tif (!ibmveth_rxq_correlator_valid(adapter, correlator))\n \t\treturn -EINVAL;\n-\t}\n \n \tskb = adapter-\u003erx_buff_pool[pool].skbuff[index];\n-\tif (WARN_ON(!skb)) {\n-\t\tschedule_work(\u0026adapter-\u003ework);\n+\tif (!skb) {\n+\t\tibmveth_rxq_no_skb(adapter, correlator);\n \t\treturn -EFAULT;\n \t}\n \n@@ -504,51 +540,56 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,\n \treturn 0;\n }\n \n-/* get the current buffer on the rx queue */\n-static inline struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter)\n+/* get the buffer for @correlator, read once from the current rx queue entry */\n+static struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter,\n+\t\t\t\t\t u64 correlator)\n {\n-\tu64 correlator = adapter-\u003erx_queue.queue_addr[adapter-\u003erx_queue.index].correlator;\n \tunsigned int pool = correlator \u003e\u003e 32;\n \tunsigned int index = correlator \u0026 0xffffffffUL;\n+\tstruct sk_buff *skb;\n \n-\tif (WARN_ON(pool \u003e= IBMVETH_NUM_BUFF_POOLS) ||\n-\t WARN_ON(index \u003e= adapter-\u003erx_buff_pool[pool].size)) {\n-\t\tschedule_work(\u0026adapter-\u003ework);\n+\tif (!ibmveth_rxq_correlator_valid(adapter, correlator))\n \t\treturn NULL;\n-\t}\n \n-\treturn adapter-\u003erx_buff_pool[pool].skbuff[index];\n+\tskb = adapter-\u003erx_buff_pool[pool].skbuff[index];\n+\tif (!skb)\n+\t\tibmveth_rxq_no_skb(adapter, correlator);\n+\treturn skb;\n+}\n+\n+static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)\n+{\n+\tif (++adapter-\u003erx_queue.index == adapter-\u003erx_queue.num_slots) {\n+\t\tadapter-\u003erx_queue.index = 0;\n+\t\tadapter-\u003erx_queue.toggle = !adapter-\u003erx_queue.toggle;\n+\t}\n }\n \n /**\n * ibmveth_rxq_harvest_buffer - Harvest buffer from pool\n *\n- * @adapter: pointer to adapter\n- * @reuse: whether to reuse buffer\n+ * @adapter: pointer to adapter\n+ * @correlator: correlator of the current rx queue entry, as read by poll\n+ * @reuse: whether to reuse buffer\n *\n * Context: called from ibmveth_poll\n *\n+ * The ring advances even on error, so poll does not return to a bad\n+ * slot before the scheduled reset can run.\n+ *\n * Return:\n * * %0 - success\n * * other - non-zero return from ibmveth_remove_buffer_from_pool\n */\n static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter,\n-\t\t\t\t bool reuse)\n+\t\t\t\t u64 correlator, bool reuse)\n {\n-\tu64 cor;\n \tint rc;\n \n-\tcor = adapter-\u003erx_queue.queue_addr[adapter-\u003erx_queue.index].correlator;\n-\trc = ibmveth_remove_buffer_from_pool(adapter, cor, reuse);\n-\tif (unlikely(rc))\n-\t\treturn rc;\n+\trc = ibmveth_remove_buffer_from_pool(adapter, correlator, reuse);\n+\tibmveth_rxq_advance(adapter);\n \n-\tif (++adapter-\u003erx_queue.index == adapter-\u003erx_queue.num_slots) {\n-\t\tadapter-\u003erx_queue.index = 0;\n-\t\tadapter-\u003erx_queue.toggle = !adapter-\u003erx_queue.toggle;\n-\t}\n-\n-\treturn 0;\n+\treturn rc;\n }\n \n static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx)\n@@ -628,8 +669,6 @@ static int ibmveth_open(struct net_device *netdev)\n \n \tnetdev_dbg(netdev, \"open starting\\n\");\n \n-\tnapi_enable(\u0026adapter-\u003enapi);\n-\n \tfor(i = 0; i \u003c IBMVETH_NUM_BUFF_POOLS; i++)\n \t\trxq_entries += adapter-\u003erx_buff_pool[i].size;\n \n@@ -717,10 +756,19 @@ static int ibmveth_open(struct net_device *netdev)\n \t\t}\n \t}\n \n+\t/* NAPI can run as soon as it is enabled, from netpoll during the\n+\t * direct close()/open() pairs or from a direct ibmveth_interrupt()\n+\t * call, so enable it only once everything ibmveth_poll() touches\n+\t * exists.\n+\t */\n+\tnapi_enable(\u0026adapter-\u003enapi);\n+\n \tnetdev_dbg(netdev, \"registering irq 0x%x\\n\", netdev-\u003eirq);\n \trc = request_irq(netdev-\u003eirq, ibmveth_interrupt, 0, netdev-\u003ename,\n \t\t\t netdev);\n \tif (rc != 0) {\n+\t\tnapi_disable(\u0026adapter-\u003enapi);\n+\t\tsynchronize_net();\n \t\tnetdev_err(netdev, \"unable to request irq 0x%x, rc %d\\n\",\n \t\t\t netdev-\u003eirq, rc);\n \t\tgoto out_free_buffer_pools;\n@@ -733,6 +781,7 @@ static int ibmveth_open(struct net_device *netdev)\n \n \tnetif_tx_start_all_queues(netdev);\n \n+\tadapter-\u003eopened = true;\n \tnetdev_dbg(netdev, \"open complete\\n\");\n \n \treturn 0;\n@@ -765,7 +814,6 @@ static int ibmveth_open(struct net_device *netdev)\n out_free_buffer_list:\n \tfree_page((unsigned long)adapter-\u003ebuffer_list_addr);\n out:\n-\tnapi_disable(\u0026adapter-\u003enapi);\n \treturn rc;\n }\n \n@@ -776,11 +824,24 @@ static int ibmveth_close(struct net_device *netdev)\n \tlong lpar_rc;\n \tint i;\n \n+\t/* change_mtu, pool sysfs, set_csum and set_tso call close() and\n+\t * open() directly. If that open() fails, IFF_UP stays set and\n+\t * NAPI is disabled; a second close() would hang in napi_disable().\n+\t */\n+\tif (!adapter-\u003eopened)\n+\t\treturn 0;\n+\tadapter-\u003eopened = false;\n+\n \tnetdev_dbg(netdev, \"close starting\\n\");\n \n \tnapi_disable(\u0026adapter-\u003enapi);\n+\t/* napi_disable() returns once ibmveth_poll() has called\n+\t * napi_complete_done(), but the poll still re-enables the\n+\t * interrupt and reads the RX queue after that.\n+\t */\n+\tsynchronize_net();\n \n-\tnetif_tx_stop_all_queues(netdev);\n+\tnetif_tx_disable(netdev);\n \n \th_vio_signal(adapter-\u003evdev-\u003eunit_address, VIO_IRQ_DISABLE);\n \n@@ -827,10 +888,10 @@ static int ibmveth_close(struct net_device *netdev)\n *\n * @w: pointer to work_struct embedded in adapter structure\n *\n- * Context: This routine acquires rtnl_mutex and disables its NAPI through\n- * ibmveth_close. It can't be called directly in a context that has\n- * already acquired rtnl_mutex or disabled its NAPI, or directly from\n- * a poll routine.\n+ * Context: This routine acquires rtnl_mutex and, if the device is open,\n+ * disables its NAPI through ibmveth_close. It can't be called\n+ * directly in a context that has already acquired rtnl_mutex or\n+ * disabled its NAPI, or directly from a poll routine.\n *\n * Return: void\n */\n@@ -1122,12 +1183,13 @@ static int ibmveth_set_channels(struct net_device *netdev,\n \tstruct ibmveth_adapter *adapter = netdev_priv(netdev);\n \tunsigned int old = netdev-\u003ereal_num_tx_queues,\n \t\t goal = channels-\u003etx_count;\n-\tint rc, i;\n+\tint rc, i, alloc_rc = 0;\n \n-\t/* If ndo_open has not been called yet then don't allocate, just set\n-\t * desired netdev_queue's and return\n+\t/* If the device is not open (including a failed close/open with\n+\t * IFF_UP still set) then don't allocate, just set desired\n+\t * netdev_queue's and return\n \t */\n-\tif (!(netdev-\u003eflags \u0026 IFF_UP))\n+\tif (!adapter-\u003eopened)\n \t\treturn netif_set_real_num_tx_queues(netdev, goal);\n \n \t/* We have IBMVETH_MAX_QUEUES netdev_queue's allocated\n@@ -1147,6 +1209,7 @@ static int ibmveth_set_channels(struct net_device *netdev,\n \t\t/* if something goes wrong, free everything we just allocated */\n \t\tnetdev_err(netdev, \"Failed to allocate more tx queues, returning to %d queues\\n\",\n \t\t\t old);\n+\t\talloc_rc = rc;\n \t\tgoal = old;\n \t\told = i;\n \t\tbreak;\n@@ -1157,6 +1220,8 @@ static int ibmveth_set_channels(struct net_device *netdev,\n \t\t\t old);\n \t\tgoal = old;\n \t\told = i;\n+\t} else if (alloc_rc) {\n+\t\trc = alloc_rc;\n \t}\n \t/* Free any that are no longer needed */\n \tfor (i = old; i \u003e goal; i--) {\n@@ -1331,8 +1396,12 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,\n \n }\n \n-static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)\n+/* Returns false when the IP or TCP headers fail the checks; the frame is\n+ * then left unchanged and not marked GSO.\n+ */\n+static bool ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)\n {\n+\tunsigned int gso_type, ip_len;\n \tstruct tcphdr *tcph;\n \tint offset = 0;\n \tint hdr_len;\n@@ -1341,28 +1410,41 @@ static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)\n \tif (skb-\u003eprotocol == htons(ETH_P_IP)) {\n \t\tstruct iphdr *iph = (struct iphdr *)skb-\u003edata;\n \n+\t\tif (skb_headlen(skb) \u003c sizeof(*iph) || iph-\u003eihl \u003c 5)\n+\t\t\treturn false;\n \t\tif (iph-\u003eprotocol == IPPROTO_TCP) {\n+\t\t\t/* only a whole datagram has a TCP header to segment */\n+\t\t\tif (ip_is_fragment(iph))\n+\t\t\t\treturn false;\n \t\t\toffset = iph-\u003eihl * 4;\n-\t\t\tskb_shinfo(skb)-\u003egso_type = SKB_GSO_TCPV4;\n+\t\t\tip_len = ntohs(iph-\u003etot_len);\n+\t\t\tgso_type = SKB_GSO_TCPV4;\n \t\t} else {\n-\t\t\treturn;\n+\t\t\treturn true;\n \t\t}\n \t} else if (skb-\u003eprotocol == htons(ETH_P_IPV6)) {\n \t\tstruct ipv6hdr *iph6 = (struct ipv6hdr *)skb-\u003edata;\n \n+\t\tif (skb_headlen(skb) \u003c sizeof(*iph6))\n+\t\t\treturn false;\n \t\tif (iph6-\u003enexthdr == IPPROTO_TCP) {\n \t\t\toffset = sizeof(struct ipv6hdr);\n-\t\t\tskb_shinfo(skb)-\u003egso_type = SKB_GSO_TCPV6;\n+\t\t\tip_len = offset + ntohs(iph6-\u003epayload_len);\n+\t\t\tgso_type = SKB_GSO_TCPV6;\n \t\t} else {\n-\t\t\treturn;\n+\t\t\treturn true;\n \t\t}\n \t} else {\n-\t\treturn;\n+\t\treturn true;\n \t}\n \t/* if mss is not set through Large Packet bit/mss in rx buffer,\n \t * expect that the mss will be written to the tcp header checksum.\n \t */\n \ttcph = (struct tcphdr *)(skb-\u003edata + offset);\n+\tif (skb_headlen(skb) \u003c offset + sizeof(*tcph) || tcph-\u003edoff \u003c 5 ||\n+\t ip_len != skb_headlen(skb) || ip_len \u003c= offset + tcph-\u003edoff * 4)\n+\t\treturn false;\n+\tskb_shinfo(skb)-\u003egso_type = gso_type;\n \tif (lrg_pkt) {\n \t\tskb_shinfo(skb)-\u003egso_size = mss;\n \t} else if (offset) {\n@@ -1371,11 +1453,18 @@ static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)\n \t}\n \n \tif (skb_shinfo(skb)-\u003egso_size) {\n+\t\t/* chosen by the sending partition: at least the floor\n+\t\t * virtio_net_hdr_to_skb() uses, and never GSO_BY_FRAGS\n+\t\t */\n+\t\tskb_shinfo(skb)-\u003egso_size =\n+\t\t\tclamp_t(u16, skb_shinfo(skb)-\u003egso_size,\n+\t\t\t\tTCP_MIN_GSO_SIZE, GSO_BY_FRAGS - 1);\n \t\thdr_len = offset + tcph-\u003edoff * 4;\n \t\tskb_shinfo(skb)-\u003egso_segs =\n-\t\t\t\tDIV_ROUND_UP(skb-\u003elen - hdr_len,\n+\t\t\t\tDIV_ROUND_UP(ip_len - hdr_len,\n \t\t\t\t\t skb_shinfo(skb)-\u003egso_size);\n \t}\n+\treturn true;\n }\n \n static void ibmveth_rx_csum_helper(struct sk_buff *skb,\n@@ -1392,6 +1481,10 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,\n \n \tif (skb_proto == ETH_P_IP) {\n \t\tiph = (struct iphdr *)skb-\u003edata;\n+\t\tif (skb_headlen(skb) \u003c sizeof(*iph) || iph-\u003eihl \u003c 5 ||\n+\t\t skb_headlen(skb) \u003c iph-\u003eihl * 4 ||\n+\t\t (iph-\u003eprotocol == IPPROTO_TCP \u0026\u0026 ip_is_fragment(iph)))\n+\t\t\tgoto bad_hdr;\n \n \t\t/* If the IP checksum is not offloaded and if the packet\n \t\t * is large send, the checksum must be rebuilt.\n@@ -1406,6 +1499,8 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,\n \t\tiph_proto = iph-\u003eprotocol;\n \t} else if (skb_proto == ETH_P_IPV6) {\n \t\tiph6 = (struct ipv6hdr *)skb-\u003edata;\n+\t\tif (skb_headlen(skb) \u003c sizeof(*iph6))\n+\t\t\tgoto bad_hdr;\n \t\tiphlen = sizeof(struct ipv6hdr);\n \t\tiph_proto = iph6-\u003enexthdr;\n \t}\n@@ -1428,6 +1523,8 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,\n \tif (iph_proto == IPPROTO_TCP) {\n \t\tstruct tcphdr *tcph = (struct tcphdr *)(skb-\u003edata + iphlen);\n \n+\t\tif (skb_headlen(skb) \u003c iphlen + sizeof(*tcph))\n+\t\t\tgoto bad_hdr;\n \t\tif (tcph-\u003echeck == 0x0000) {\n \t\t\t/* Recompute TCP pseudo header checksum */\n \t\t\ttcphdrlen = skb-\u003elen - iphlen;\n@@ -1445,6 +1542,13 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,\n \t\t\tskb_reset_network_header(skb);\n \t\t}\n \t}\n+\treturn;\n+\n+bad_hdr:\n+\t/* headers do not fit the frame, or a fragment has no whole TCP\n+\t * segment; let the stack check it\n+\t */\n+\tskb-\u003eip_summed = CHECKSUM_NONE;\n }\n \n static int ibmveth_poll(struct napi_struct *napi, int budget)\n@@ -1454,31 +1558,60 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \tstruct net_device *netdev = adapter-\u003enetdev;\n \tint frames_processed = 0;\n \tunsigned long lpar_rc;\n+\tu64 correlator;\n \tu16 mss = 0;\n+\tint rc;\n \n-restart_poll:\n \twhile (frames_processed \u003c budget) {\n \t\tif (!ibmveth_rxq_pending_buffer(adapter))\n \t\t\tbreak;\n \n \t\tsmp_rmb();\n+\t\tcorrelator = ibmveth_rxq_correlator(adapter);\n \t\tif (!ibmveth_rxq_buffer_valid(adapter)) {\n \t\t\twmb(); /* suggested by larson1 */\n \t\t\tadapter-\u003erx_invalid_buffer++;\n \t\t\tnetdev_dbg(netdev, \"recycling invalid buffer\\n\");\n-\t\t\tif (unlikely(ibmveth_rxq_harvest_buffer(adapter, true)))\n-\t\t\t\tbreak;\n+\t\t\trc = ibmveth_rxq_harvest_buffer(adapter, correlator, true);\n+\t\t\tif (unlikely(rc)) {\n+\t\t\t\tnetdev-\u003estats.rx_dropped++;\n+\t\t\t\tframes_processed++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \t\t} else {\n \t\t\tstruct sk_buff *skb, *new_skb;\n \t\t\tint length = ibmveth_rxq_frame_length(adapter);\n \t\t\tint offset = ibmveth_rxq_frame_offset(adapter);\n \t\t\tint csum_good = ibmveth_rxq_csum_good(adapter);\n \t\t\tint lrg_pkt = ibmveth_rxq_large_packet(adapter);\n+\t\t\tunsigned int pool, room, off, len;\n \t\t\t__sum16 iph_check = 0;\n \n-\t\t\tskb = ibmveth_rxq_get_buffer(adapter);\n-\t\t\tif (unlikely(!skb))\n-\t\t\t\tbreak;\n+\t\t\tskb = ibmveth_rxq_get_buffer(adapter, correlator);\n+\t\t\tif (unlikely(!skb)) {\n+\t\t\t\tibmveth_rxq_advance(adapter);\n+\t\t\t\tnetdev-\u003estats.rx_dropped++;\n+\t\t\t\tframes_processed++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n+\n+\t\t\tpool = correlator \u003e\u003e 32;\n+\t\t\troom = min_t(unsigned int, skb_tailroom(skb),\n+\t\t\t\t adapter-\u003erx_buff_pool[pool].buff_size);\n+\t\t\toff = offset;\n+\t\t\tlen = length;\n+\t\t\tif (unlikely(len \u003c ETH_HLEN || off \u003e= room ||\n+\t\t\t\t len \u003e room - off)) {\n+\t\t\t\tif (net_ratelimit())\n+\t\t\t\t\tnetdev_err(netdev,\n+\t\t\t\t\t\t \"bad RX frame offset %u length %u (buffer %u), dropping\\n\",\n+\t\t\t\t\t\t off, len, room);\n+\t\t\t\tibmveth_rxq_harvest_buffer(adapter, correlator,\n+\t\t\t\t\t\t\t true);\n+\t\t\t\tnetdev-\u003estats.rx_dropped++;\n+\t\t\t\tframes_processed++;\n+\t\t\t\tcontinue;\n+\t\t\t}\n \n \t\t\t/* if the large packet bit is set in the rx queue\n \t\t\t * descriptor, the mss will be written by PHYP eight\n@@ -1502,12 +1635,25 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \t\t\t\tif (rx_flush)\n \t\t\t\t\tibmveth_flush_buffer(skb-\u003edata,\n \t\t\t\t\t\tlength + offset);\n-\t\t\t\tif (unlikely(ibmveth_rxq_harvest_buffer(adapter, true)))\n-\t\t\t\t\tbreak;\n+\t\t\t\trc = ibmveth_rxq_harvest_buffer(adapter,\n+\t\t\t\t\t\t\t\tcorrelator,\n+\t\t\t\t\t\t\t\ttrue);\n+\t\t\t\tif (unlikely(rc)) {\n+\t\t\t\t\tdev_kfree_skb_any(new_skb);\n+\t\t\t\t\tnetdev-\u003estats.rx_dropped++;\n+\t\t\t\t\tframes_processed++;\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n \t\t\t\tskb = new_skb;\n \t\t\t} else {\n-\t\t\t\tif (unlikely(ibmveth_rxq_harvest_buffer(adapter, false)))\n-\t\t\t\t\tbreak;\n+\t\t\t\trc = ibmveth_rxq_harvest_buffer(adapter,\n+\t\t\t\t\t\t\t\tcorrelator,\n+\t\t\t\t\t\t\t\tfalse);\n+\t\t\t\tif (unlikely(rc)) {\n+\t\t\t\t\tnetdev-\u003estats.rx_dropped++;\n+\t\t\t\t\tframes_processed++;\n+\t\t\t\t\tcontinue;\n+\t\t\t\t}\n \t\t\t\tskb_reserve(skb, offset);\n \t\t\t}\n \n@@ -1517,7 +1663,8 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \t\t\t/* PHYP without PLSO support places a -1 in the ip\n \t\t\t * checksum for large send frames.\n \t\t\t */\n-\t\t\tif (skb-\u003eprotocol == cpu_to_be16(ETH_P_IP)) {\n+\t\t\tif (skb-\u003eprotocol == cpu_to_be16(ETH_P_IP) \u0026\u0026\n+\t\t\t skb_headlen(skb) \u003e= sizeof(struct iphdr)) {\n \t\t\t\tstruct iphdr *iph = (struct iphdr *)skb-\u003edata;\n \n \t\t\t\tiph_check = iph-\u003echeck;\n@@ -1525,7 +1672,8 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \n \t\t\tif ((length \u003e netdev-\u003emtu + ETH_HLEN) ||\n \t\t\t lrg_pkt || iph_check == 0xffff) {\n-\t\t\t\tibmveth_rx_mss_helper(skb, mss, lrg_pkt);\n+\t\t\t\tif (!ibmveth_rx_mss_helper(skb, mss, lrg_pkt))\n+\t\t\t\t\tcsum_good = 0;\n \t\t\t\tadapter-\u003erx_large_packets++;\n \t\t\t}\n \n@@ -1542,7 +1690,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \t\t}\n \t}\n \n-\tibmveth_replenish_task(adapter);\n+\t/* netpoll polls with budget 0 for TX only, and is not serialized\n+\t * with a NAPI poll that was already running when it was set up\n+\t */\n+\tif (budget)\n+\t\tibmveth_replenish_task(adapter);\n \n \tif (frames_processed == budget)\n \t\tgoto out;\n@@ -1559,10 +1711,13 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)\n \t\tgoto out;\n \t}\n \n-\tif (ibmveth_rxq_pending_buffer(adapter) \u0026\u0026 napi_schedule(napi)) {\n+\t/* Mask before queueing, as ibmveth_interrupt() does: a threaded\n+\t * NAPI can start polling, and unmask, as soon as it is queued.\n+\t */\n+\tif (ibmveth_rxq_pending_buffer(adapter) \u0026\u0026 napi_schedule_prep(napi)) {\n \t\tlpar_rc = h_vio_signal(adapter-\u003evdev-\u003eunit_address,\n \t\t\t\t VIO_IRQ_DISABLE);\n-\t\tgoto restart_poll;\n+\t\t__napi_schedule(napi);\n \t}\n \n out:\n@@ -1682,14 +1837,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)\n \treturn -EINVAL;\n }\n \n-#ifdef CONFIG_NET_POLL_CONTROLLER\n-static void ibmveth_poll_controller(struct net_device *dev)\n-{\n-\tibmveth_replenish_task(netdev_priv(dev));\n-\tibmveth_interrupt(dev-\u003eirq, dev);\n-}\n-#endif\n-\n /**\n * ibmveth_get_desired_dma - Calculate IO memory desired by the driver\n *\n@@ -1791,11 +1938,42 @@ static const struct net_device_ops ibmveth_netdev_ops = {\n \t.ndo_validate_addr\t= eth_validate_addr,\n \t.ndo_set_mac_address = ibmveth_set_mac_addr,\n \t.ndo_features_check\t= ibmveth_features_check,\n-#ifdef CONFIG_NET_POLL_CONTROLLER\n-\t.ndo_poll_controller\t= ibmveth_poll_controller,\n-#endif\n };\n \n+/**\n+ * ibmveth_pool_kobj_release - Mark a pool kobject finished\n+ * @kobj: kobject embedded in the pool\n+ *\n+ * The pool kobjects live in netdev_priv(), so the last put must wait\n+ * for this before free_netdev().\n+ */\n+static void ibmveth_pool_kobj_release(struct kobject *kobj)\n+{\n+\tstruct ibmveth_buff_pool *pool = container_of(kobj,\n+\t\t\t\t\t\t struct ibmveth_buff_pool,\n+\t\t\t\t\t\t kobj);\n+\n+\tcomplete(\u0026pool-\u003ereleased);\n+}\n+\n+/**\n+ * ibmveth_put_pool_kobjs - Drop the pool kobjects and wait for release\n+ * @adapter: ibmveth adapter\n+ *\n+ * With CONFIG_DEBUG_KOBJECT_RELEASE the cleanup, including removing the\n+ * sysfs files, runs later from a work item in the kobject; wait for it\n+ * so free_netdev() cannot free the pools first.\n+ */\n+static void ibmveth_put_pool_kobjs(struct ibmveth_adapter *adapter)\n+{\n+\tint i;\n+\n+\tfor (i = 0; i \u003c IBMVETH_NUM_BUFF_POOLS; i++)\n+\t\tkobject_put(\u0026adapter-\u003erx_buff_pool[i].kobj);\n+\tfor (i = 0; i \u003c IBMVETH_NUM_BUFF_POOLS; i++)\n+\t\twait_for_completion(\u0026adapter-\u003erx_buff_pool[i].released);\n+}\n+\n static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)\n {\n \tint rc, i, mac_len;\n@@ -1906,6 +2084,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)\n \t\tibmveth_init_buffer_pool(\u0026adapter-\u003erx_buff_pool[i], i,\n \t\t\t\t\t pool_count[i], pool_size[i],\n \t\t\t\t\t pool_active[i]);\n+\t\tinit_completion(\u0026adapter-\u003erx_buff_pool[i].released);\n \t\terror = kobject_init_and_add(kobj, \u0026ktype_veth_pool,\n \t\t\t\t\t \u0026dev-\u003edev.kobj, \"pool%d\", i);\n \t\tif (!error)\n@@ -1917,8 +2096,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)\n \tif (rc) {\n \t\tnetdev_dbg(netdev, \"failed to set number of tx queues rc=%d\\n\",\n \t\t\t rc);\n-\t\tfree_netdev(netdev);\n-\t\treturn rc;\n+\t\tgoto err_put_pools;\n \t}\n \tadapter-\u003etx_ltb_size = PAGE_ALIGN(IBMVETH_MAX_TX_BUF_SIZE);\n \tfor (i = 0; i \u003c IBMVETH_MAX_QUEUES; i++)\n@@ -1933,25 +2111,27 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)\n \n \tif (rc) {\n \t\tnetdev_dbg(netdev, \"failed to register netdev rc=%d\\n\", rc);\n-\t\tfree_netdev(netdev);\n-\t\treturn rc;\n+\t\tgoto err_put_pools;\n \t}\n \n \tnetdev_dbg(netdev, \"registered\\n\");\n \n \treturn 0;\n+\n+err_put_pools:\n+\tibmveth_put_pool_kobjs(adapter);\n+\tfree_netdev(netdev);\n+\treturn rc;\n }\n \n static void ibmveth_remove(struct vio_dev *dev)\n {\n \tstruct net_device *netdev = dev_get_drvdata(\u0026dev-\u003edev);\n \tstruct ibmveth_adapter *adapter = netdev_priv(netdev);\n-\tint i;\n \n-\tcancel_work_sync(\u0026adapter-\u003ework);\n+\tdisable_work_sync(\u0026adapter-\u003ework);\n \n-\tfor (i = 0; i \u003c IBMVETH_NUM_BUFF_POOLS; i++)\n-\t\tkobject_put(\u0026adapter-\u003erx_buff_pool[i].kobj);\n+\tibmveth_put_pool_kobjs(adapter);\n \n \tunregister_netdev(netdev);\n \n@@ -2127,7 +2307,7 @@ static const struct sysfs_ops veth_pool_ops = {\n };\n \n static struct kobj_type ktype_veth_pool = {\n-\t.release = NULL,\n+\t.release = ibmveth_pool_kobj_release,\n \t.sysfs_ops = \u0026veth_pool_ops,\n \t.default_groups = veth_pool_groups,\n };\n@@ -2198,8 +2378,7 @@ static void ibmveth_reset_kunit(struct work_struct *w)\n * @test: pointer to kunit structure\n *\n * Tests the error returns from ibmveth_remove_buffer_from_pool.\n- * ibmveth_remove_buffer_from_pool also calls WARN_ON, so dmesg should be\n- * checked to see that these warnings happened.\n+ * Each error also logs a ratelimited netdev_err.\n *\n * Return: void\n */\n@@ -2208,6 +2387,7 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)\n \tstruct ibmveth_adapter *adapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);\n \tstruct ibmveth_buff_pool *pool;\n \tu64 correlator;\n+\tint ret;\n \n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);\n \n@@ -2231,6 +2411,13 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)\n \tKUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));\n \tKUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));\n \n+\t/* Pool 2 is in range but has no skbuff array, like an inactive pool. */\n+\tcorrelator = ((u64)2 \u003c\u003c 32) | 0;\n+\tret = ibmveth_remove_buffer_from_pool(adapter, correlator, false);\n+\tKUNIT_EXPECT_EQ(test, -EINVAL, ret);\n+\tret = ibmveth_remove_buffer_from_pool(adapter, correlator, true);\n+\tKUNIT_EXPECT_EQ(test, -EINVAL, ret);\n+\n \tcorrelator = (u64)0 | 0;\n \tpool-\u003eskbuff[0] = NULL;\n \tKUNIT_EXPECT_EQ(test, -EFAULT, ibmveth_remove_buffer_from_pool(adapter, correlator, false));\n@@ -2243,9 +2430,8 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)\n * ibmveth_rxq_get_buffer_test - unit test for ibmveth_rxq_get_buffer\n * @test: pointer to kunit structure\n *\n- * Tests ibmveth_rxq_get_buffer. ibmveth_rxq_get_buffer also calls WARN_ON for\n- * the NULL returns, so dmesg should be checked to see that these warnings\n- * happened.\n+ * Tests ibmveth_rxq_get_buffer. Each NULL return also logs a ratelimited\n+ * netdev_err.\n *\n * Return: void\n */\n@@ -2254,6 +2440,7 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)\n \tstruct ibmveth_adapter *adapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);\n \tstruct sk_buff *skb = kunit_kzalloc(test, sizeof(*skb), GFP_KERNEL);\n \tstruct ibmveth_buff_pool *pool;\n+\tu64 cor;\n \n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);\n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb);\n@@ -2277,21 +2464,322 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)\n \tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool-\u003eskbuff);\n \n \tadapter-\u003erx_queue.queue_addr[0].correlator = (u64)IBMVETH_NUM_BUFF_POOLS \u003c\u003c 32 | 0;\n-\tKUNIT_EXPECT_PTR_EQ(test, NULL, ibmveth_rxq_get_buffer(adapter));\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tKUNIT_EXPECT_PTR_EQ(test, NULL,\n+\t\t\t ibmveth_rxq_get_buffer(adapter, cor));\n \n \tadapter-\u003erx_queue.queue_addr[0].correlator = (u64)0 \u003c\u003c 32 | adapter-\u003erx_buff_pool[0].size;\n-\tKUNIT_EXPECT_PTR_EQ(test, NULL, ibmveth_rxq_get_buffer(adapter));\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tKUNIT_EXPECT_PTR_EQ(test, NULL,\n+\t\t\t ibmveth_rxq_get_buffer(adapter, cor));\n+\n+\t/* Pool 2 is in range but has no skbuff array, like an inactive pool. */\n+\tadapter-\u003erx_queue.queue_addr[0].correlator = (u64)2 \u003c\u003c 32 | 0;\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tKUNIT_EXPECT_PTR_EQ(test, NULL,\n+\t\t\t ibmveth_rxq_get_buffer(adapter, cor));\n \n \tpool-\u003eskbuff[0] = skb;\n \tadapter-\u003erx_queue.queue_addr[0].correlator = (u64)0 \u003c\u003c 32 | 0;\n-\tKUNIT_EXPECT_PTR_EQ(test, skb, ibmveth_rxq_get_buffer(adapter));\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tKUNIT_EXPECT_PTR_EQ(test, skb,\n+\t\t\t ibmveth_rxq_get_buffer(adapter, cor));\n+\n+\tflush_work(\u0026adapter-\u003ework);\n+}\n+\n+/**\n+ * ibmveth_rxq_harvest_buffer_test - unit test for ibmveth_rxq_harvest_buffer\n+ * @test: pointer to kunit structure\n+ *\n+ * A bad correlator must still advance the RX ring, wrapping and flipping\n+ * the toggle at the end. This covers the harvest path; the advance after\n+ * ibmveth_rxq_get_buffer() fails in ibmveth_poll() is not tested here.\n+ *\n+ * Return: void\n+ */\n+static void ibmveth_rxq_harvest_buffer_test(struct kunit *test)\n+{\n+\tstruct ibmveth_adapter *adapter;\n+\tstruct ibmveth_buff_pool *pool;\n+\tu64 cor;\n+\tint ret;\n+\n+\tadapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);\n+\n+\tINIT_WORK(\u0026adapter-\u003ework, ibmveth_reset_kunit);\n+\n+\tadapter-\u003erx_queue.num_slots = 2;\n+\tadapter-\u003erx_queue.index = 0;\n+\tadapter-\u003erx_queue.toggle = 1;\n+\tadapter-\u003erx_queue.queue_addr =\n+\t\tkunit_kcalloc(test, 2, sizeof(struct ibmveth_rx_q_entry),\n+\t\t\t GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter-\u003erx_queue.queue_addr);\n+\n+\t/* Set sane values for buffer pools */\n+\tfor (int i = 0; i \u003c IBMVETH_NUM_BUFF_POOLS; i++)\n+\t\tibmveth_init_buffer_pool(\u0026adapter-\u003erx_buff_pool[i], i,\n+\t\t\t\t\t pool_count[i], pool_size[i],\n+\t\t\t\t\t pool_active[i]);\n+\n+\tpool = \u0026adapter-\u003erx_buff_pool[0];\n+\tpool-\u003eskbuff = kunit_kcalloc(test, pool-\u003esize, sizeof(void *),\n+\t\t\t\t GFP_KERNEL);\n+\tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool-\u003eskbuff);\n+\n+\t/* Slot 0: pool out of range. Slot 1: valid, but no skb. */\n+\tadapter-\u003erx_queue.queue_addr[0].correlator =\n+\t\t(u64)IBMVETH_NUM_BUFF_POOLS \u003c\u003c 32 | 0;\n+\tadapter-\u003erx_queue.queue_addr[1].correlator = (u64)0 \u003c\u003c 32 | 0;\n+\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tret = ibmveth_rxq_harvest_buffer(adapter, cor, true);\n+\tKUNIT_EXPECT_EQ(test, -EINVAL, ret);\n+\tKUNIT_EXPECT_EQ(test, 1ULL, adapter-\u003erx_queue.index);\n+\tKUNIT_EXPECT_EQ(test, 1ULL, adapter-\u003erx_queue.toggle);\n+\n+\tcor = ibmveth_rxq_correlator(adapter);\n+\tret = ibmveth_rxq_harvest_buffer(adapter, cor, true);\n+\tKUNIT_EXPECT_EQ(test, -EFAULT, ret);\n+\tKUNIT_EXPECT_EQ(test, 0ULL, adapter-\u003erx_queue.index);\n+\tKUNIT_EXPECT_EQ(test, 0ULL, adapter-\u003erx_queue.toggle);\n \n \tflush_work(\u0026adapter-\u003ework);\n }\n \n+KUNIT_DEFINE_ACTION_WRAPPER(ibmveth_kfree_skb, kfree_skb, struct sk_buff *);\n+\n+/* A TCP frame after eth_type_trans(): IP header, 20 byte TCP header and\n+ * payload bytes of data, with the IP length matching the frame.\n+ */\n+static struct sk_buff *ibmveth_test_tcp_skb(struct kunit *test, bool ipv6,\n+\t\t\t\t\t unsigned int payload)\n+{\n+\tunsigned int iplen = ipv6 ? sizeof(struct ipv6hdr) :\n+\t\t\t\t sizeof(struct iphdr);\n+\tunsigned int len = iplen + sizeof(struct tcphdr) + payload;\n+\tstruct sk_buff *skb = alloc_skb(len, GFP_KERNEL);\n+\tstruct tcphdr *tcph;\n+\n+\tKUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb);\n+\tKUNIT_ASSERT_EQ(test, 0, kunit_add_action_or_reset(test,\n+\t\t\t\t\t\t\t ibmveth_kfree_skb,\n+\t\t\t\t\t\t\t skb));\n+\tskb_put_zero(skb, len);\n+\tif (ipv6) {\n+\t\tstruct ipv6hdr *iph6 = (struct ipv6hdr *)skb-\u003edata;\n+\n+\t\tskb-\u003eprotocol = htons(ETH_P_IPV6);\n+\t\tiph6-\u003eversion = 6;\n+\t\tiph6-\u003enexthdr = IPPROTO_TCP;\n+\t\tiph6-\u003epayload_len = htons(len - iplen);\n+\t} else {\n+\t\tstruct iphdr *iph = (struct iphdr *)skb-\u003edata;\n+\n+\t\tskb-\u003eprotocol = htons(ETH_P_IP);\n+\t\tiph-\u003eversion = 4;\n+\t\tiph-\u003eihl = 5;\n+\t\tiph-\u003eprotocol = IPPROTO_TCP;\n+\t\tiph-\u003etot_len = htons(len);\n+\t}\n+\ttcph = (struct tcphdr *)(skb-\u003edata + iplen);\n+\ttcph-\u003edoff = 5;\n+\treturn skb;\n+}\n+\n+/**\n+ * ibmveth_rx_mss_helper_test - unit test for ibmveth_rx_mss_helper\n+ * @test: pointer to kunit structure\n+ *\n+ * Large send frames get gso_size from the descriptor or the TCP checksum\n+ * field, clamped, and gso_segs from the IP length. Frames whose headers\n+ * do not fit, whose IP length is not the frame length, with no TCP\n+ * payload within the IP length, or that are IPv4 fragments, are refused\n+ * and left without GSO.\n+ *\n+ * Return: void\n+ */\n+static void ibmveth_rx_mss_helper_test(struct kunit *test)\n+{\n+\tstruct sk_buff *skb;\n+\tstruct tcphdr *tcph;\n+\tstruct iphdr *iph;\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\ttcph = (struct tcphdr *)(skb-\u003edata + sizeof(*iph));\n+\ttcph-\u003echeck = (__force __sum16)htons(1448);\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 0, 0));\n+\tKUNIT_EXPECT_EQ(test, SKB_GSO_TCPV4, skb_shinfo(skb)-\u003egso_type);\n+\tKUNIT_EXPECT_EQ(test, 1448, skb_shinfo(skb)-\u003egso_size);\n+\tKUNIT_EXPECT_EQ(test, 2, skb_shinfo(skb)-\u003egso_segs);\n+\tKUNIT_EXPECT_EQ(test, 0, (__force u16)tcph-\u003echeck);\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1000, 1));\n+\tKUNIT_EXPECT_EQ(test, 1000, skb_shinfo(skb)-\u003egso_size);\n+\tKUNIT_EXPECT_EQ(test, 3, skb_shinfo(skb)-\u003egso_segs);\n+\n+\tskb = ibmveth_test_tcp_skb(test, true, 2896);\n+\ttcph = (struct tcphdr *)(skb-\u003edata + sizeof(struct ipv6hdr));\n+\ttcph-\u003echeck = (__force __sum16)htons(1448);\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 0, 0));\n+\tKUNIT_EXPECT_EQ(test, SKB_GSO_TCPV6, skb_shinfo(skb)-\u003egso_type);\n+\tKUNIT_EXPECT_EQ(test, 1448, skb_shinfo(skb)-\u003egso_size);\n+\tKUNIT_EXPECT_EQ(test, 2, skb_shinfo(skb)-\u003egso_segs);\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1, 1));\n+\tKUNIT_EXPECT_EQ(test, TCP_MIN_GSO_SIZE, skb_shinfo(skb)-\u003egso_size);\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, GSO_BY_FRAGS, 1));\n+\tKUNIT_EXPECT_EQ(test, GSO_BY_FRAGS - 1, skb_shinfo(skb)-\u003egso_size);\n+\n+\t/* refused: ihl 0, doff 4, IP length past the frame. With ihl 0 the\n+\t * TCP header would overlap the IP header; saddr makes its doff 5.\n+\t */\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct iphdr *)skb-\u003edata)-\u003eihl = 0;\n+\t((struct iphdr *)skb-\u003edata)-\u003esaddr = htonl(0x50000000);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct tcphdr *)(skb-\u003edata + sizeof(*iph)))-\u003edoff = 4;\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct iphdr *)skb-\u003edata)-\u003etot_len = htons(skb-\u003elen + 1);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\n+\t/* refused: bytes past the IP length, its large send fields left\n+\t * alone; gso_segs from the IP length would undercount them\n+\t */\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct iphdr *)skb-\u003edata)-\u003etot_len = htons(skb-\u003elen - 100);\n+\ttcph = (struct tcphdr *)(skb-\u003edata + sizeof(*iph));\n+\ttcph-\u003echeck = (__force __sum16)htons(1448);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 0, 0));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\tKUNIT_EXPECT_EQ(test, 1448, ntohs((__force __be16)tcph-\u003echeck));\n+\n+\t/* refused: a fragment past the first, its payload left alone */\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct iphdr *)skb-\u003edata)-\u003efrag_off = htons(185);\n+\ttcph = (struct tcphdr *)(skb-\u003edata + sizeof(*iph));\n+\ttcph-\u003echeck = (__force __sum16)htons(1448);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 0, 0));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\tKUNIT_EXPECT_EQ(test, 1448, ntohs((__force __be16)tcph-\u003echeck));\n+\n+\t/* refused: only Ethernet padding past the TCP header */\n+\tskb = ibmveth_test_tcp_skb(test, false, 6);\n+\t((struct iphdr *)skb-\u003edata)-\u003etot_len = htons(40);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\n+\tskb = ibmveth_test_tcp_skb(test, true, 2896);\n+\t((struct ipv6hdr *)skb-\u003edata)-\u003epayload_len = 0;\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\n+\t/* refused: no TCP payload, with the IP length matching the frame */\n+\tskb = ibmveth_test_tcp_skb(test, false, 0);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\n+\tskb = ibmveth_test_tcp_skb(test, true, 0);\n+\tKUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+\n+\t/* not TCP: accepted and left alone */\n+\tskb = ibmveth_test_tcp_skb(test, false, 2896);\n+\t((struct iphdr *)skb-\u003edata)-\u003eprotocol = IPPROTO_UDP;\n+\tKUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1448, 1));\n+\tKUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)-\u003egso_size);\n+}\n+\n+/**\n+ * ibmveth_rx_csum_helper_test - unit test for ibmveth_rx_csum_helper\n+ * @test: pointer to kunit structure\n+ *\n+ * A large send IPv4 header checksum of 0xffff is rebuilt. Headers that\n+ * do not fit the frame, an IPv4 ihl below 5, or a TCP fragment, clear\n+ * CHECKSUM_UNNECESSARY instead of being read.\n+ *\n+ * Return: void\n+ */\n+static void ibmveth_rx_csum_helper_test(struct kunit *test)\n+{\n+\tstruct sk_buff *skb;\n+\tstruct tcphdr *tcph;\n+\tstruct iphdr *iph;\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 100);\n+\tiph = (struct iphdr *)skb-\u003edata;\n+\tiph-\u003echeck = (__force __sum16)0xffff;\n+\ttcph = (struct tcphdr *)(skb-\u003edata + sizeof(*iph));\n+\ttcph-\u003echeck = (__force __sum16)htons(1);\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, 0, (__force u16)ip_fast_csum(iph, iph-\u003eihl));\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_UNNECESSARY, (int)skb-\u003eip_summed);\n+\n+\tskb = ibmveth_test_tcp_skb(test, false, 100);\n+\tiph = (struct iphdr *)skb-\u003edata;\n+\tiph-\u003eihl = 0;\n+\tiph-\u003echeck = (__force __sum16)0xffff;\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb-\u003eip_summed);\n+\tKUNIT_EXPECT_EQ(test, 0xffff, (__force u16)iph-\u003echeck);\n+\n+\t/* IPv4 options past the frame; UDP, so no TCP check follows */\n+\tskb = ibmveth_test_tcp_skb(test, false, 0);\n+\tiph = (struct iphdr *)skb-\u003edata;\n+\tiph-\u003eprotocol = IPPROTO_UDP;\n+\tiph-\u003eihl = 15;\n+\tiph-\u003echeck = (__force __sum16)0xffff;\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb-\u003eip_summed);\n+\n+\t/* a TCP fragment past the first: header and payload left alone */\n+\tskb = ibmveth_test_tcp_skb(test, false, 100);\n+\tiph = (struct iphdr *)skb-\u003edata;\n+\tiph-\u003efrag_off = htons(185);\n+\tiph-\u003echeck = (__force __sum16)0xffff;\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb-\u003eip_summed);\n+\tKUNIT_EXPECT_EQ(test, 0xffff, (__force u16)iph-\u003echeck);\n+\tKUNIT_EXPECT_EQ(test, 0,\n+\t\t\t(__force u16)((struct tcphdr *)(skb-\u003edata +\n+\t\t\t\t\t\t\tsizeof(*iph)))-\u003echeck);\n+\n+\t/* TCP header past the frame */\n+\tskb = ibmveth_test_tcp_skb(test, false, 0);\n+\tskb_trim(skb, sizeof(struct iphdr));\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb-\u003eip_summed);\n+\n+\t/* IPv6 header past the frame; UDP, so no TCP check follows */\n+\tskb = ibmveth_test_tcp_skb(test, true, 0);\n+\t((struct ipv6hdr *)skb-\u003edata)-\u003enexthdr = IPPROTO_UDP;\n+\tskb_trim(skb, sizeof(struct ipv6hdr) - 1);\n+\tskb-\u003eip_summed = CHECKSUM_UNNECESSARY;\n+\tibmveth_rx_csum_helper(skb, NULL);\n+\tKUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb-\u003eip_summed);\n+}\n+\n static struct kunit_case ibmveth_test_cases[] = {\n \tKUNIT_CASE(ibmveth_remove_buffer_from_pool_test),\n \tKUNIT_CASE(ibmveth_rxq_get_buffer_test),\n+\tKUNIT_CASE(ibmveth_rxq_harvest_buffer_test),\n+\tKUNIT_CASE(ibmveth_rx_mss_helper_test),\n+\tKUNIT_CASE(ibmveth_rx_csum_helper_test),\n \t{}\n };\n \ndiff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h\nindex d87713668ed30..be0939caa328e 100644\n--- a/drivers/net/ethernet/ibm/ibmveth.h\n+++ b/drivers/net/ethernet/ibm/ibmveth.h\n@@ -14,6 +14,8 @@\n #ifndef _IBMVETH_H\n #define _IBMVETH_H\n \n+#include \u003clinux/completion.h\u003e\n+\n /* constants for H_MULTICAST_CTRL */\n #define IbmVethMcastReceptionModifyBit 0x80000UL\n #define IbmVethMcastReceptionEnableBit 0x20000UL\n@@ -143,6 +145,7 @@ struct ibmveth_buff_pool {\n struct sk_buff **skbuff;\n int active;\n struct kobject kobj;\n+\tstruct completion released;\n };\n \n struct ibmveth_rx_q {\n@@ -172,6 +175,8 @@ struct ibmveth_adapter {\n \tint rx_csum;\n \tint large_send;\n \tbool is_active_trunk;\n+\t/* Set by a successful ibmveth_open(), cleared by ibmveth_close(). */\n+\tbool opened;\n \tunsigned int rx_buffers_per_hcall;\n \n \tu64 fw_ipv6_csum_support;\n"
} |
| 2/1 | 2026/10/13 22:50 | agent | patch-evaluator |
2mModel:core Args: null Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The changes are confined to the IBM Virtual Ethernet driver (ibmveth), which depends on CONFIG_PPC_PSERIES. This code is exclusive to the PowerPC architecture and cannot be compiled or executed on the target architecture (amd64).",
"WorthFuzzing": false
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any '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: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 9b041b26fe1121464d62d0a93b01b14a9c69801c
Author: syz-cluster <triage@syzkaller.com>
Date: Tue Oct 13 22:50:39 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index abebdb1fc2628..e9874dfedf378 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -135,6 +135,13 @@ static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length);
}
+static u64 ibmveth_rxq_correlator(struct ibmveth_adapter *adapter)
+{
+ unsigned int idx = adapter->rx_queue.index;
+
+ return READ_ONCE(adapter->rx_queue.queue_addr[idx].correlator);
+}
+
static inline int ibmveth_rxq_csum_good(struct ibmveth_adapter *adapter)
{
return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_CSUM_GOOD;
@@ -443,6 +450,37 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,
}
}
+/* The correlator comes back from PHYP; a bad one schedules a reset. */
+static bool ibmveth_rxq_correlator_valid(struct ibmveth_adapter *adapter,
+ u64 correlator)
+{
+ unsigned int index = correlator & 0xffffffffUL;
+ unsigned int pool = correlator >> 32;
+
+ /* An inactive pool keeps its size but has no skbuff array. */
+ if (pool < IBMVETH_NUM_BUFF_POOLS &&
+ index < adapter->rx_buff_pool[pool].size &&
+ adapter->rx_buff_pool[pool].skbuff)
+ return true;
+
+ if (net_ratelimit())
+ netdev_err(adapter->netdev,
+ "invalid RX correlator %llx, resetting\n",
+ correlator);
+ schedule_work(&adapter->work);
+ return false;
+}
+
+static void ibmveth_rxq_no_skb(struct ibmveth_adapter *adapter,
+ u64 correlator)
+{
+ if (net_ratelimit())
+ netdev_err(adapter->netdev,
+ "no buffer for RX correlator %llx, resetting\n",
+ correlator);
+ schedule_work(&adapter->work);
+}
+
/**
* ibmveth_remove_buffer_from_pool - remove a buffer from a pool
* @adapter: adapter instance
@@ -451,7 +489,8 @@ static void ibmveth_free_buffer_pool(struct ibmveth_adapter *adapter,
*
* Return:
* * %0 - success
- * * %-EINVAL - correlator maps to pool or index out of range
+ * * %-EINVAL - correlator maps to pool or index out of range, or to an
+ * inactive pool
* * %-EFAULT - pool and index map to null skb
*/
static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
@@ -462,15 +501,12 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
unsigned int free_index;
struct sk_buff *skb;
- if (WARN_ON(pool >= IBMVETH_NUM_BUFF_POOLS) ||
- WARN_ON(index >= adapter->rx_buff_pool[pool].size)) {
- schedule_work(&adapter->work);
+ if (!ibmveth_rxq_correlator_valid(adapter, correlator))
return -EINVAL;
- }
skb = adapter->rx_buff_pool[pool].skbuff[index];
- if (WARN_ON(!skb)) {
- schedule_work(&adapter->work);
+ if (!skb) {
+ ibmveth_rxq_no_skb(adapter, correlator);
return -EFAULT;
}
@@ -504,51 +540,56 @@ static int ibmveth_remove_buffer_from_pool(struct ibmveth_adapter *adapter,
return 0;
}
-/* get the current buffer on the rx queue */
-static inline struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter)
+/* get the buffer for @correlator, read once from the current rx queue entry */
+static struct sk_buff *ibmveth_rxq_get_buffer(struct ibmveth_adapter *adapter,
+ u64 correlator)
{
- u64 correlator = adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator;
unsigned int pool = correlator >> 32;
unsigned int index = correlator & 0xffffffffUL;
+ struct sk_buff *skb;
- if (WARN_ON(pool >= IBMVETH_NUM_BUFF_POOLS) ||
- WARN_ON(index >= adapter->rx_buff_pool[pool].size)) {
- schedule_work(&adapter->work);
+ if (!ibmveth_rxq_correlator_valid(adapter, correlator))
return NULL;
- }
- return adapter->rx_buff_pool[pool].skbuff[index];
+ skb = adapter->rx_buff_pool[pool].skbuff[index];
+ if (!skb)
+ ibmveth_rxq_no_skb(adapter, correlator);
+ return skb;
+}
+
+static void ibmveth_rxq_advance(struct ibmveth_adapter *adapter)
+{
+ if (++adapter->rx_queue.index == adapter->rx_queue.num_slots) {
+ adapter->rx_queue.index = 0;
+ adapter->rx_queue.toggle = !adapter->rx_queue.toggle;
+ }
}
/**
* ibmveth_rxq_harvest_buffer - Harvest buffer from pool
*
- * @adapter: pointer to adapter
- * @reuse: whether to reuse buffer
+ * @adapter: pointer to adapter
+ * @correlator: correlator of the current rx queue entry, as read by poll
+ * @reuse: whether to reuse buffer
*
* Context: called from ibmveth_poll
*
+ * The ring advances even on error, so poll does not return to a bad
+ * slot before the scheduled reset can run.
+ *
* Return:
* * %0 - success
* * other - non-zero return from ibmveth_remove_buffer_from_pool
*/
static int ibmveth_rxq_harvest_buffer(struct ibmveth_adapter *adapter,
- bool reuse)
+ u64 correlator, bool reuse)
{
- u64 cor;
int rc;
- cor = adapter->rx_queue.queue_addr[adapter->rx_queue.index].correlator;
- rc = ibmveth_remove_buffer_from_pool(adapter, cor, reuse);
- if (unlikely(rc))
- return rc;
+ rc = ibmveth_remove_buffer_from_pool(adapter, correlator, reuse);
+ ibmveth_rxq_advance(adapter);
- if (++adapter->rx_queue.index == adapter->rx_queue.num_slots) {
- adapter->rx_queue.index = 0;
- adapter->rx_queue.toggle = !adapter->rx_queue.toggle;
- }
-
- return 0;
+ return rc;
}
static void ibmveth_free_tx_ltb(struct ibmveth_adapter *adapter, int idx)
@@ -628,8 +669,6 @@ static int ibmveth_open(struct net_device *netdev)
netdev_dbg(netdev, "open starting\n");
- napi_enable(&adapter->napi);
-
for(i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
rxq_entries += adapter->rx_buff_pool[i].size;
@@ -717,10 +756,19 @@ static int ibmveth_open(struct net_device *netdev)
}
}
+ /* NAPI can run as soon as it is enabled, from netpoll during the
+ * direct close()/open() pairs or from a direct ibmveth_interrupt()
+ * call, so enable it only once everything ibmveth_poll() touches
+ * exists.
+ */
+ napi_enable(&adapter->napi);
+
netdev_dbg(netdev, "registering irq 0x%x\n", netdev->irq);
rc = request_irq(netdev->irq, ibmveth_interrupt, 0, netdev->name,
netdev);
if (rc != 0) {
+ napi_disable(&adapter->napi);
+ synchronize_net();
netdev_err(netdev, "unable to request irq 0x%x, rc %d\n",
netdev->irq, rc);
goto out_free_buffer_pools;
@@ -733,6 +781,7 @@ static int ibmveth_open(struct net_device *netdev)
netif_tx_start_all_queues(netdev);
+ adapter->opened = true;
netdev_dbg(netdev, "open complete\n");
return 0;
@@ -765,7 +814,6 @@ static int ibmveth_open(struct net_device *netdev)
out_free_buffer_list:
free_page((unsigned long)adapter->buffer_list_addr);
out:
- napi_disable(&adapter->napi);
return rc;
}
@@ -776,11 +824,24 @@ static int ibmveth_close(struct net_device *netdev)
long lpar_rc;
int i;
+ /* change_mtu, pool sysfs, set_csum and set_tso call close() and
+ * open() directly. If that open() fails, IFF_UP stays set and
+ * NAPI is disabled; a second close() would hang in napi_disable().
+ */
+ if (!adapter->opened)
+ return 0;
+ adapter->opened = false;
+
netdev_dbg(netdev, "close starting\n");
napi_disable(&adapter->napi);
+ /* napi_disable() returns once ibmveth_poll() has called
+ * napi_complete_done(), but the poll still re-enables the
+ * interrupt and reads the RX queue after that.
+ */
+ synchronize_net();
- netif_tx_stop_all_queues(netdev);
+ netif_tx_disable(netdev);
h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
@@ -827,10 +888,10 @@ static int ibmveth_close(struct net_device *netdev)
*
* @w: pointer to work_struct embedded in adapter structure
*
- * Context: This routine acquires rtnl_mutex and disables its NAPI through
- * ibmveth_close. It can't be called directly in a context that has
- * already acquired rtnl_mutex or disabled its NAPI, or directly from
- * a poll routine.
+ * Context: This routine acquires rtnl_mutex and, if the device is open,
+ * disables its NAPI through ibmveth_close. It can't be called
+ * directly in a context that has already acquired rtnl_mutex or
+ * disabled its NAPI, or directly from a poll routine.
*
* Return: void
*/
@@ -1122,12 +1183,13 @@ static int ibmveth_set_channels(struct net_device *netdev,
struct ibmveth_adapter *adapter = netdev_priv(netdev);
unsigned int old = netdev->real_num_tx_queues,
goal = channels->tx_count;
- int rc, i;
+ int rc, i, alloc_rc = 0;
- /* If ndo_open has not been called yet then don't allocate, just set
- * desired netdev_queue's and return
+ /* If the device is not open (including a failed close/open with
+ * IFF_UP still set) then don't allocate, just set desired
+ * netdev_queue's and return
*/
- if (!(netdev->flags & IFF_UP))
+ if (!adapter->opened)
return netif_set_real_num_tx_queues(netdev, goal);
/* We have IBMVETH_MAX_QUEUES netdev_queue's allocated
@@ -1147,6 +1209,7 @@ static int ibmveth_set_channels(struct net_device *netdev,
/* if something goes wrong, free everything we just allocated */
netdev_err(netdev, "Failed to allocate more tx queues, returning to %d queues\n",
old);
+ alloc_rc = rc;
goal = old;
old = i;
break;
@@ -1157,6 +1220,8 @@ static int ibmveth_set_channels(struct net_device *netdev,
old);
goal = old;
old = i;
+ } else if (alloc_rc) {
+ rc = alloc_rc;
}
/* Free any that are no longer needed */
for (i = old; i > goal; i--) {
@@ -1331,8 +1396,12 @@ static netdev_tx_t ibmveth_start_xmit(struct sk_buff *skb,
}
-static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
+/* Returns false when the IP or TCP headers fail the checks; the frame is
+ * then left unchanged and not marked GSO.
+ */
+static bool ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
{
+ unsigned int gso_type, ip_len;
struct tcphdr *tcph;
int offset = 0;
int hdr_len;
@@ -1341,28 +1410,41 @@ static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
if (skb->protocol == htons(ETH_P_IP)) {
struct iphdr *iph = (struct iphdr *)skb->data;
+ if (skb_headlen(skb) < sizeof(*iph) || iph->ihl < 5)
+ return false;
if (iph->protocol == IPPROTO_TCP) {
+ /* only a whole datagram has a TCP header to segment */
+ if (ip_is_fragment(iph))
+ return false;
offset = iph->ihl * 4;
- skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
+ ip_len = ntohs(iph->tot_len);
+ gso_type = SKB_GSO_TCPV4;
} else {
- return;
+ return true;
}
} else if (skb->protocol == htons(ETH_P_IPV6)) {
struct ipv6hdr *iph6 = (struct ipv6hdr *)skb->data;
+ if (skb_headlen(skb) < sizeof(*iph6))
+ return false;
if (iph6->nexthdr == IPPROTO_TCP) {
offset = sizeof(struct ipv6hdr);
- skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
+ ip_len = offset + ntohs(iph6->payload_len);
+ gso_type = SKB_GSO_TCPV6;
} else {
- return;
+ return true;
}
} else {
- return;
+ return true;
}
/* if mss is not set through Large Packet bit/mss in rx buffer,
* expect that the mss will be written to the tcp header checksum.
*/
tcph = (struct tcphdr *)(skb->data + offset);
+ if (skb_headlen(skb) < offset + sizeof(*tcph) || tcph->doff < 5 ||
+ ip_len != skb_headlen(skb) || ip_len <= offset + tcph->doff * 4)
+ return false;
+ skb_shinfo(skb)->gso_type = gso_type;
if (lrg_pkt) {
skb_shinfo(skb)->gso_size = mss;
} else if (offset) {
@@ -1371,11 +1453,18 @@ static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
}
if (skb_shinfo(skb)->gso_size) {
+ /* chosen by the sending partition: at least the floor
+ * virtio_net_hdr_to_skb() uses, and never GSO_BY_FRAGS
+ */
+ skb_shinfo(skb)->gso_size =
+ clamp_t(u16, skb_shinfo(skb)->gso_size,
+ TCP_MIN_GSO_SIZE, GSO_BY_FRAGS - 1);
hdr_len = offset + tcph->doff * 4;
skb_shinfo(skb)->gso_segs =
- DIV_ROUND_UP(skb->len - hdr_len,
+ DIV_ROUND_UP(ip_len - hdr_len,
skb_shinfo(skb)->gso_size);
}
+ return true;
}
static void ibmveth_rx_csum_helper(struct sk_buff *skb,
@@ -1392,6 +1481,10 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
if (skb_proto == ETH_P_IP) {
iph = (struct iphdr *)skb->data;
+ if (skb_headlen(skb) < sizeof(*iph) || iph->ihl < 5 ||
+ skb_headlen(skb) < iph->ihl * 4 ||
+ (iph->protocol == IPPROTO_TCP && ip_is_fragment(iph)))
+ goto bad_hdr;
/* If the IP checksum is not offloaded and if the packet
* is large send, the checksum must be rebuilt.
@@ -1406,6 +1499,8 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
iph_proto = iph->protocol;
} else if (skb_proto == ETH_P_IPV6) {
iph6 = (struct ipv6hdr *)skb->data;
+ if (skb_headlen(skb) < sizeof(*iph6))
+ goto bad_hdr;
iphlen = sizeof(struct ipv6hdr);
iph_proto = iph6->nexthdr;
}
@@ -1428,6 +1523,8 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
if (iph_proto == IPPROTO_TCP) {
struct tcphdr *tcph = (struct tcphdr *)(skb->data + iphlen);
+ if (skb_headlen(skb) < iphlen + sizeof(*tcph))
+ goto bad_hdr;
if (tcph->check == 0x0000) {
/* Recompute TCP pseudo header checksum */
tcphdrlen = skb->len - iphlen;
@@ -1445,6 +1542,13 @@ static void ibmveth_rx_csum_helper(struct sk_buff *skb,
skb_reset_network_header(skb);
}
}
+ return;
+
+bad_hdr:
+ /* headers do not fit the frame, or a fragment has no whole TCP
+ * segment; let the stack check it
+ */
+ skb->ip_summed = CHECKSUM_NONE;
}
static int ibmveth_poll(struct napi_struct *napi, int budget)
@@ -1454,31 +1558,60 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
struct net_device *netdev = adapter->netdev;
int frames_processed = 0;
unsigned long lpar_rc;
+ u64 correlator;
u16 mss = 0;
+ int rc;
-restart_poll:
while (frames_processed < budget) {
if (!ibmveth_rxq_pending_buffer(adapter))
break;
smp_rmb();
+ correlator = ibmveth_rxq_correlator(adapter);
if (!ibmveth_rxq_buffer_valid(adapter)) {
wmb(); /* suggested by larson1 */
adapter->rx_invalid_buffer++;
netdev_dbg(netdev, "recycling invalid buffer\n");
- if (unlikely(ibmveth_rxq_harvest_buffer(adapter, true)))
- break;
+ rc = ibmveth_rxq_harvest_buffer(adapter, correlator, true);
+ if (unlikely(rc)) {
+ netdev->stats.rx_dropped++;
+ frames_processed++;
+ continue;
+ }
} else {
struct sk_buff *skb, *new_skb;
int length = ibmveth_rxq_frame_length(adapter);
int offset = ibmveth_rxq_frame_offset(adapter);
int csum_good = ibmveth_rxq_csum_good(adapter);
int lrg_pkt = ibmveth_rxq_large_packet(adapter);
+ unsigned int pool, room, off, len;
__sum16 iph_check = 0;
- skb = ibmveth_rxq_get_buffer(adapter);
- if (unlikely(!skb))
- break;
+ skb = ibmveth_rxq_get_buffer(adapter, correlator);
+ if (unlikely(!skb)) {
+ ibmveth_rxq_advance(adapter);
+ netdev->stats.rx_dropped++;
+ frames_processed++;
+ continue;
+ }
+
+ pool = correlator >> 32;
+ room = min_t(unsigned int, skb_tailroom(skb),
+ adapter->rx_buff_pool[pool].buff_size);
+ off = offset;
+ len = length;
+ if (unlikely(len < ETH_HLEN || off >= room ||
+ len > room - off)) {
+ if (net_ratelimit())
+ netdev_err(netdev,
+ "bad RX frame offset %u length %u (buffer %u), dropping\n",
+ off, len, room);
+ ibmveth_rxq_harvest_buffer(adapter, correlator,
+ true);
+ netdev->stats.rx_dropped++;
+ frames_processed++;
+ continue;
+ }
/* if the large packet bit is set in the rx queue
* descriptor, the mss will be written by PHYP eight
@@ -1502,12 +1635,25 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
if (rx_flush)
ibmveth_flush_buffer(skb->data,
length + offset);
- if (unlikely(ibmveth_rxq_harvest_buffer(adapter, true)))
- break;
+ rc = ibmveth_rxq_harvest_buffer(adapter,
+ correlator,
+ true);
+ if (unlikely(rc)) {
+ dev_kfree_skb_any(new_skb);
+ netdev->stats.rx_dropped++;
+ frames_processed++;
+ continue;
+ }
skb = new_skb;
} else {
- if (unlikely(ibmveth_rxq_harvest_buffer(adapter, false)))
- break;
+ rc = ibmveth_rxq_harvest_buffer(adapter,
+ correlator,
+ false);
+ if (unlikely(rc)) {
+ netdev->stats.rx_dropped++;
+ frames_processed++;
+ continue;
+ }
skb_reserve(skb, offset);
}
@@ -1517,7 +1663,8 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
/* PHYP without PLSO support places a -1 in the ip
* checksum for large send frames.
*/
- if (skb->protocol == cpu_to_be16(ETH_P_IP)) {
+ if (skb->protocol == cpu_to_be16(ETH_P_IP) &&
+ skb_headlen(skb) >= sizeof(struct iphdr)) {
struct iphdr *iph = (struct iphdr *)skb->data;
iph_check = iph->check;
@@ -1525,7 +1672,8 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
if ((length > netdev->mtu + ETH_HLEN) ||
lrg_pkt || iph_check == 0xffff) {
- ibmveth_rx_mss_helper(skb, mss, lrg_pkt);
+ if (!ibmveth_rx_mss_helper(skb, mss, lrg_pkt))
+ csum_good = 0;
adapter->rx_large_packets++;
}
@@ -1542,7 +1690,11 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
}
}
- ibmveth_replenish_task(adapter);
+ /* netpoll polls with budget 0 for TX only, and is not serialized
+ * with a NAPI poll that was already running when it was set up
+ */
+ if (budget)
+ ibmveth_replenish_task(adapter);
if (frames_processed == budget)
goto out;
@@ -1559,10 +1711,13 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
goto out;
}
- if (ibmveth_rxq_pending_buffer(adapter) && napi_schedule(napi)) {
+ /* Mask before queueing, as ibmveth_interrupt() does: a threaded
+ * NAPI can start polling, and unmask, as soon as it is queued.
+ */
+ if (ibmveth_rxq_pending_buffer(adapter) && napi_schedule_prep(napi)) {
lpar_rc = h_vio_signal(adapter->vdev->unit_address,
VIO_IRQ_DISABLE);
- goto restart_poll;
+ __napi_schedule(napi);
}
out:
@@ -1682,14 +1837,6 @@ static int ibmveth_change_mtu(struct net_device *dev, int new_mtu)
return -EINVAL;
}
-#ifdef CONFIG_NET_POLL_CONTROLLER
-static void ibmveth_poll_controller(struct net_device *dev)
-{
- ibmveth_replenish_task(netdev_priv(dev));
- ibmveth_interrupt(dev->irq, dev);
-}
-#endif
-
/**
* ibmveth_get_desired_dma - Calculate IO memory desired by the driver
*
@@ -1791,11 +1938,42 @@ static const struct net_device_ops ibmveth_netdev_ops = {
.ndo_validate_addr = eth_validate_addr,
.ndo_set_mac_address = ibmveth_set_mac_addr,
.ndo_features_check = ibmveth_features_check,
-#ifdef CONFIG_NET_POLL_CONTROLLER
- .ndo_poll_controller = ibmveth_poll_controller,
-#endif
};
+/**
+ * ibmveth_pool_kobj_release - Mark a pool kobject finished
+ * @kobj: kobject embedded in the pool
+ *
+ * The pool kobjects live in netdev_priv(), so the last put must wait
+ * for this before free_netdev().
+ */
+static void ibmveth_pool_kobj_release(struct kobject *kobj)
+{
+ struct ibmveth_buff_pool *pool = container_of(kobj,
+ struct ibmveth_buff_pool,
+ kobj);
+
+ complete(&pool->released);
+}
+
+/**
+ * ibmveth_put_pool_kobjs - Drop the pool kobjects and wait for release
+ * @adapter: ibmveth adapter
+ *
+ * With CONFIG_DEBUG_KOBJECT_RELEASE the cleanup, including removing the
+ * sysfs files, runs later from a work item in the kobject; wait for it
+ * so free_netdev() cannot free the pools first.
+ */
+static void ibmveth_put_pool_kobjs(struct ibmveth_adapter *adapter)
+{
+ int i;
+
+ for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
+ kobject_put(&adapter->rx_buff_pool[i].kobj);
+ for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
+ wait_for_completion(&adapter->rx_buff_pool[i].released);
+}
+
static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
{
int rc, i, mac_len;
@@ -1906,6 +2084,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
pool_count[i], pool_size[i],
pool_active[i]);
+ init_completion(&adapter->rx_buff_pool[i].released);
error = kobject_init_and_add(kobj, &ktype_veth_pool,
&dev->dev.kobj, "pool%d", i);
if (!error)
@@ -1917,8 +2096,7 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
if (rc) {
netdev_dbg(netdev, "failed to set number of tx queues rc=%d\n",
rc);
- free_netdev(netdev);
- return rc;
+ goto err_put_pools;
}
adapter->tx_ltb_size = PAGE_ALIGN(IBMVETH_MAX_TX_BUF_SIZE);
for (i = 0; i < IBMVETH_MAX_QUEUES; i++)
@@ -1933,25 +2111,27 @@ static int ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
if (rc) {
netdev_dbg(netdev, "failed to register netdev rc=%d\n", rc);
- free_netdev(netdev);
- return rc;
+ goto err_put_pools;
}
netdev_dbg(netdev, "registered\n");
return 0;
+
+err_put_pools:
+ ibmveth_put_pool_kobjs(adapter);
+ free_netdev(netdev);
+ return rc;
}
static void ibmveth_remove(struct vio_dev *dev)
{
struct net_device *netdev = dev_get_drvdata(&dev->dev);
struct ibmveth_adapter *adapter = netdev_priv(netdev);
- int i;
- cancel_work_sync(&adapter->work);
+ disable_work_sync(&adapter->work);
- for (i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
- kobject_put(&adapter->rx_buff_pool[i].kobj);
+ ibmveth_put_pool_kobjs(adapter);
unregister_netdev(netdev);
@@ -2127,7 +2307,7 @@ static const struct sysfs_ops veth_pool_ops = {
};
static struct kobj_type ktype_veth_pool = {
- .release = NULL,
+ .release = ibmveth_pool_kobj_release,
.sysfs_ops = &veth_pool_ops,
.default_groups = veth_pool_groups,
};
@@ -2198,8 +2378,7 @@ static void ibmveth_reset_kunit(struct work_struct *w)
* @test: pointer to kunit structure
*
* Tests the error returns from ibmveth_remove_buffer_from_pool.
- * ibmveth_remove_buffer_from_pool also calls WARN_ON, so dmesg should be
- * checked to see that these warnings happened.
+ * Each error also logs a ratelimited netdev_err.
*
* Return: void
*/
@@ -2208,6 +2387,7 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
struct ibmveth_adapter *adapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);
struct ibmveth_buff_pool *pool;
u64 correlator;
+ int ret;
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);
@@ -2231,6 +2411,13 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
KUNIT_EXPECT_EQ(test, -EINVAL, ibmveth_remove_buffer_from_pool(adapter, correlator, true));
+ /* Pool 2 is in range but has no skbuff array, like an inactive pool. */
+ correlator = ((u64)2 << 32) | 0;
+ ret = ibmveth_remove_buffer_from_pool(adapter, correlator, false);
+ KUNIT_EXPECT_EQ(test, -EINVAL, ret);
+ ret = ibmveth_remove_buffer_from_pool(adapter, correlator, true);
+ KUNIT_EXPECT_EQ(test, -EINVAL, ret);
+
correlator = (u64)0 | 0;
pool->skbuff[0] = NULL;
KUNIT_EXPECT_EQ(test, -EFAULT, ibmveth_remove_buffer_from_pool(adapter, correlator, false));
@@ -2243,9 +2430,8 @@ static void ibmveth_remove_buffer_from_pool_test(struct kunit *test)
* ibmveth_rxq_get_buffer_test - unit test for ibmveth_rxq_get_buffer
* @test: pointer to kunit structure
*
- * Tests ibmveth_rxq_get_buffer. ibmveth_rxq_get_buffer also calls WARN_ON for
- * the NULL returns, so dmesg should be checked to see that these warnings
- * happened.
+ * Tests ibmveth_rxq_get_buffer. Each NULL return also logs a ratelimited
+ * netdev_err.
*
* Return: void
*/
@@ -2254,6 +2440,7 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)
struct ibmveth_adapter *adapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);
struct sk_buff *skb = kunit_kzalloc(test, sizeof(*skb), GFP_KERNEL);
struct ibmveth_buff_pool *pool;
+ u64 cor;
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb);
@@ -2277,21 +2464,322 @@ static void ibmveth_rxq_get_buffer_test(struct kunit *test)
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
adapter->rx_queue.queue_addr[0].correlator = (u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
- KUNIT_EXPECT_PTR_EQ(test, NULL, ibmveth_rxq_get_buffer(adapter));
+ cor = ibmveth_rxq_correlator(adapter);
+ KUNIT_EXPECT_PTR_EQ(test, NULL,
+ ibmveth_rxq_get_buffer(adapter, cor));
adapter->rx_queue.queue_addr[0].correlator = (u64)0 << 32 | adapter->rx_buff_pool[0].size;
- KUNIT_EXPECT_PTR_EQ(test, NULL, ibmveth_rxq_get_buffer(adapter));
+ cor = ibmveth_rxq_correlator(adapter);
+ KUNIT_EXPECT_PTR_EQ(test, NULL,
+ ibmveth_rxq_get_buffer(adapter, cor));
+
+ /* Pool 2 is in range but has no skbuff array, like an inactive pool. */
+ adapter->rx_queue.queue_addr[0].correlator = (u64)2 << 32 | 0;
+ cor = ibmveth_rxq_correlator(adapter);
+ KUNIT_EXPECT_PTR_EQ(test, NULL,
+ ibmveth_rxq_get_buffer(adapter, cor));
pool->skbuff[0] = skb;
adapter->rx_queue.queue_addr[0].correlator = (u64)0 << 32 | 0;
- KUNIT_EXPECT_PTR_EQ(test, skb, ibmveth_rxq_get_buffer(adapter));
+ cor = ibmveth_rxq_correlator(adapter);
+ KUNIT_EXPECT_PTR_EQ(test, skb,
+ ibmveth_rxq_get_buffer(adapter, cor));
+
+ flush_work(&adapter->work);
+}
+
+/**
+ * ibmveth_rxq_harvest_buffer_test - unit test for ibmveth_rxq_harvest_buffer
+ * @test: pointer to kunit structure
+ *
+ * A bad correlator must still advance the RX ring, wrapping and flipping
+ * the toggle at the end. This covers the harvest path; the advance after
+ * ibmveth_rxq_get_buffer() fails in ibmveth_poll() is not tested here.
+ *
+ * Return: void
+ */
+static void ibmveth_rxq_harvest_buffer_test(struct kunit *test)
+{
+ struct ibmveth_adapter *adapter;
+ struct ibmveth_buff_pool *pool;
+ u64 cor;
+ int ret;
+
+ adapter = kunit_kzalloc(test, sizeof(*adapter), GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter);
+
+ INIT_WORK(&adapter->work, ibmveth_reset_kunit);
+
+ adapter->rx_queue.num_slots = 2;
+ adapter->rx_queue.index = 0;
+ adapter->rx_queue.toggle = 1;
+ adapter->rx_queue.queue_addr =
+ kunit_kcalloc(test, 2, sizeof(struct ibmveth_rx_q_entry),
+ GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adapter->rx_queue.queue_addr);
+
+ /* Set sane values for buffer pools */
+ for (int i = 0; i < IBMVETH_NUM_BUFF_POOLS; i++)
+ ibmveth_init_buffer_pool(&adapter->rx_buff_pool[i], i,
+ pool_count[i], pool_size[i],
+ pool_active[i]);
+
+ pool = &adapter->rx_buff_pool[0];
+ pool->skbuff = kunit_kcalloc(test, pool->size, sizeof(void *),
+ GFP_KERNEL);
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pool->skbuff);
+
+ /* Slot 0: pool out of range. Slot 1: valid, but no skb. */
+ adapter->rx_queue.queue_addr[0].correlator =
+ (u64)IBMVETH_NUM_BUFF_POOLS << 32 | 0;
+ adapter->rx_queue.queue_addr[1].correlator = (u64)0 << 32 | 0;
+
+ cor = ibmveth_rxq_correlator(adapter);
+ ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
+ KUNIT_EXPECT_EQ(test, -EINVAL, ret);
+ KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue.index);
+ KUNIT_EXPECT_EQ(test, 1ULL, adapter->rx_queue.toggle);
+
+ cor = ibmveth_rxq_correlator(adapter);
+ ret = ibmveth_rxq_harvest_buffer(adapter, cor, true);
+ KUNIT_EXPECT_EQ(test, -EFAULT, ret);
+ KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue.index);
+ KUNIT_EXPECT_EQ(test, 0ULL, adapter->rx_queue.toggle);
flush_work(&adapter->work);
}
+KUNIT_DEFINE_ACTION_WRAPPER(ibmveth_kfree_skb, kfree_skb, struct sk_buff *);
+
+/* A TCP frame after eth_type_trans(): IP header, 20 byte TCP header and
+ * payload bytes of data, with the IP length matching the frame.
+ */
+static struct sk_buff *ibmveth_test_tcp_skb(struct kunit *test, bool ipv6,
+ unsigned int payload)
+{
+ unsigned int iplen = ipv6 ? sizeof(struct ipv6hdr) :
+ sizeof(struct iphdr);
+ unsigned int len = iplen + sizeof(struct tcphdr) + payload;
+ struct sk_buff *skb = alloc_skb(len, GFP_KERNEL);
+ struct tcphdr *tcph;
+
+ KUNIT_ASSERT_NOT_ERR_OR_NULL(test, skb);
+ KUNIT_ASSERT_EQ(test, 0, kunit_add_action_or_reset(test,
+ ibmveth_kfree_skb,
+ skb));
+ skb_put_zero(skb, len);
+ if (ipv6) {
+ struct ipv6hdr *iph6 = (struct ipv6hdr *)skb->data;
+
+ skb->protocol = htons(ETH_P_IPV6);
+ iph6->version = 6;
+ iph6->nexthdr = IPPROTO_TCP;
+ iph6->payload_len = htons(len - iplen);
+ } else {
+ struct iphdr *iph = (struct iphdr *)skb->data;
+
+ skb->protocol = htons(ETH_P_IP);
+ iph->version = 4;
+ iph->ihl = 5;
+ iph->protocol = IPPROTO_TCP;
+ iph->tot_len = htons(len);
+ }
+ tcph = (struct tcphdr *)(skb->data + iplen);
+ tcph->doff = 5;
+ return skb;
+}
+
+/**
+ * ibmveth_rx_mss_helper_test - unit test for ibmveth_rx_mss_helper
+ * @test: pointer to kunit structure
+ *
+ * Large send frames get gso_size from the descriptor or the TCP checksum
+ * field, clamped, and gso_segs from the IP length. Frames whose headers
+ * do not fit, whose IP length is not the frame length, with no TCP
+ * payload within the IP length, or that are IPv4 fragments, are refused
+ * and left without GSO.
+ *
+ * Return: void
+ */
+static void ibmveth_rx_mss_helper_test(struct kunit *test)
+{
+ struct sk_buff *skb;
+ struct tcphdr *tcph;
+ struct iphdr *iph;
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ tcph = (struct tcphdr *)(skb->data + sizeof(*iph));
+ tcph->check = (__force __sum16)htons(1448);
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 0, 0));
+ KUNIT_EXPECT_EQ(test, SKB_GSO_TCPV4, skb_shinfo(skb)->gso_type);
+ KUNIT_EXPECT_EQ(test, 1448, skb_shinfo(skb)->gso_size);
+ KUNIT_EXPECT_EQ(test, 2, skb_shinfo(skb)->gso_segs);
+ KUNIT_EXPECT_EQ(test, 0, (__force u16)tcph->check);
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1000, 1));
+ KUNIT_EXPECT_EQ(test, 1000, skb_shinfo(skb)->gso_size);
+ KUNIT_EXPECT_EQ(test, 3, skb_shinfo(skb)->gso_segs);
+
+ skb = ibmveth_test_tcp_skb(test, true, 2896);
+ tcph = (struct tcphdr *)(skb->data + sizeof(struct ipv6hdr));
+ tcph->check = (__force __sum16)htons(1448);
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 0, 0));
+ KUNIT_EXPECT_EQ(test, SKB_GSO_TCPV6, skb_shinfo(skb)->gso_type);
+ KUNIT_EXPECT_EQ(test, 1448, skb_shinfo(skb)->gso_size);
+ KUNIT_EXPECT_EQ(test, 2, skb_shinfo(skb)->gso_segs);
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1, 1));
+ KUNIT_EXPECT_EQ(test, TCP_MIN_GSO_SIZE, skb_shinfo(skb)->gso_size);
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, GSO_BY_FRAGS, 1));
+ KUNIT_EXPECT_EQ(test, GSO_BY_FRAGS - 1, skb_shinfo(skb)->gso_size);
+
+ /* refused: ihl 0, doff 4, IP length past the frame. With ihl 0 the
+ * TCP header would overlap the IP header; saddr makes its doff 5.
+ */
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct iphdr *)skb->data)->ihl = 0;
+ ((struct iphdr *)skb->data)->saddr = htonl(0x50000000);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct tcphdr *)(skb->data + sizeof(*iph)))->doff = 4;
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct iphdr *)skb->data)->tot_len = htons(skb->len + 1);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+
+ /* refused: bytes past the IP length, its large send fields left
+ * alone; gso_segs from the IP length would undercount them
+ */
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct iphdr *)skb->data)->tot_len = htons(skb->len - 100);
+ tcph = (struct tcphdr *)(skb->data + sizeof(*iph));
+ tcph->check = (__force __sum16)htons(1448);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 0, 0));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+ KUNIT_EXPECT_EQ(test, 1448, ntohs((__force __be16)tcph->check));
+
+ /* refused: a fragment past the first, its payload left alone */
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct iphdr *)skb->data)->frag_off = htons(185);
+ tcph = (struct tcphdr *)(skb->data + sizeof(*iph));
+ tcph->check = (__force __sum16)htons(1448);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 0, 0));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+ KUNIT_EXPECT_EQ(test, 1448, ntohs((__force __be16)tcph->check));
+
+ /* refused: only Ethernet padding past the TCP header */
+ skb = ibmveth_test_tcp_skb(test, false, 6);
+ ((struct iphdr *)skb->data)->tot_len = htons(40);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+
+ skb = ibmveth_test_tcp_skb(test, true, 2896);
+ ((struct ipv6hdr *)skb->data)->payload_len = 0;
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+
+ /* refused: no TCP payload, with the IP length matching the frame */
+ skb = ibmveth_test_tcp_skb(test, false, 0);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+
+ skb = ibmveth_test_tcp_skb(test, true, 0);
+ KUNIT_EXPECT_FALSE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+
+ /* not TCP: accepted and left alone */
+ skb = ibmveth_test_tcp_skb(test, false, 2896);
+ ((struct iphdr *)skb->data)->protocol = IPPROTO_UDP;
+ KUNIT_EXPECT_TRUE(test, ibmveth_rx_mss_helper(skb, 1448, 1));
+ KUNIT_EXPECT_EQ(test, 0, skb_shinfo(skb)->gso_size);
+}
+
+/**
+ * ibmveth_rx_csum_helper_test - unit test for ibmveth_rx_csum_helper
+ * @test: pointer to kunit structure
+ *
+ * A large send IPv4 header checksum of 0xffff is rebuilt. Headers that
+ * do not fit the frame, an IPv4 ihl below 5, or a TCP fragment, clear
+ * CHECKSUM_UNNECESSARY instead of being read.
+ *
+ * Return: void
+ */
+static void ibmveth_rx_csum_helper_test(struct kunit *test)
+{
+ struct sk_buff *skb;
+ struct tcphdr *tcph;
+ struct iphdr *iph;
+
+ skb = ibmveth_test_tcp_skb(test, false, 100);
+ iph = (struct iphdr *)skb->data;
+ iph->check = (__force __sum16)0xffff;
+ tcph = (struct tcphdr *)(skb->data + sizeof(*iph));
+ tcph->check = (__force __sum16)htons(1);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, 0, (__force u16)ip_fast_csum(iph, iph->ihl));
+ KUNIT_EXPECT_EQ(test, CHECKSUM_UNNECESSARY, (int)skb->ip_summed);
+
+ skb = ibmveth_test_tcp_skb(test, false, 100);
+ iph = (struct iphdr *)skb->data;
+ iph->ihl = 0;
+ iph->check = (__force __sum16)0xffff;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb->ip_summed);
+ KUNIT_EXPECT_EQ(test, 0xffff, (__force u16)iph->check);
+
+ /* IPv4 options past the frame; UDP, so no TCP check follows */
+ skb = ibmveth_test_tcp_skb(test, false, 0);
+ iph = (struct iphdr *)skb->data;
+ iph->protocol = IPPROTO_UDP;
+ iph->ihl = 15;
+ iph->check = (__force __sum16)0xffff;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb->ip_summed);
+
+ /* a TCP fragment past the first: header and payload left alone */
+ skb = ibmveth_test_tcp_skb(test, false, 100);
+ iph = (struct iphdr *)skb->data;
+ iph->frag_off = htons(185);
+ iph->check = (__force __sum16)0xffff;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb->ip_summed);
+ KUNIT_EXPECT_EQ(test, 0xffff, (__force u16)iph->check);
+ KUNIT_EXPECT_EQ(test, 0,
+ (__force u16)((struct tcphdr *)(skb->data +
+ sizeof(*iph)))->check);
+
+ /* TCP header past the frame */
+ skb = ibmveth_test_tcp_skb(test, false, 0);
+ skb_trim(skb, sizeof(struct iphdr));
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb->ip_summed);
+
+ /* IPv6 header past the frame; UDP, so no TCP check follows */
+ skb = ibmveth_test_tcp_skb(test, true, 0);
+ ((struct ipv6hdr *)skb->data)->nexthdr = IPPROTO_UDP;
+ skb_trim(skb, sizeof(struct ipv6hdr) - 1);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ ibmveth_rx_csum_helper(skb, NULL);
+ KUNIT_EXPECT_EQ(test, CHECKSUM_NONE, (int)skb->ip_summed);
+}
+
static struct kunit_case ibmveth_test_cases[] = {
KUNIT_CASE(ibmveth_remove_buffer_from_pool_test),
KUNIT_CASE(ibmveth_rxq_get_buffer_test),
+ KUNIT_CASE(ibmveth_rxq_harvest_buffer_test),
+ KUNIT_CASE(ibmveth_rx_mss_helper_test),
+ KUNIT_CASE(ibmveth_rx_csum_helper_test),
{}
};
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index d87713668ed30..be0939caa328e 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -14,6 +14,8 @@
#ifndef _IBMVETH_H
#define _IBMVETH_H
+#include <linux/completion.h>
+
/* constants for H_MULTICAST_CTRL */
#define IbmVethMcastReceptionModifyBit 0x80000UL
#define IbmVethMcastReceptionEnableBit 0x20000UL
@@ -143,6 +145,7 @@ struct ibmveth_buff_pool {
struct sk_buff **skbuff;
int active;
struct kobject kobj;
+ struct completion released;
};
struct ibmveth_rx_q {
@@ -172,6 +175,8 @@ struct ibmveth_adapter {
int rx_csum;
int large_send;
bool is_active_trunk;
+ /* Set by a successful ibmveth_open(), cleared by ibmveth_close(). */
+ bool opened;
unsigned int rx_buffers_per_hcall;
u64 fw_ipv6_csum_support;
|
| 3/2 | 2026/10/13 22:50 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18436 output: 18 thoughts: 112 Thoughts: **Analyzing a Patch for Fuzzing Potential** Okay, let's dive into this. The task is to assess if this patch warrants fuzzing attention on amd64. First things first, let's examine the modified files: `drivers/net/ethernet/ibm/ibmveth.c` and `drivers/net/ethernet/ibm/ibmveth.h`. Hold on a second... `ibmveth`? I need to refresh my memory on this. Ah, right! It's the IBM Virtual Ethernet driver, specifically for IBM POWER systems, pSeries, and PAPR environments. That's a niche driver, but potentially interesting from a security perspective since it's likely not as widely scrutinized as more common ethernet drivers. Now, let's quickly check the Kconfig files to see how `IBMVETH` is configured. This will give me a better understanding of its build options and dependencies, which will inform my fuzzing strategy. I need to know where it's used and how it's enabled to understand if a bug in this driver could be triggered in a general purpose amd64 machine. |
| 4/2 | 2026/10/13 22:52 | tool | grepper |
0mArgs:{
"Expression": "config IBMVETH"
}Results: {
"Output": "drivers/net/ethernet/ibm/Kconfig=18=if NET_VENDOR_IBM\ndrivers/net/ethernet/ibm/Kconfig-19-\ndrivers/net/ethernet/ibm/Kconfig:20:config IBMVETH\ndrivers/net/ethernet/ibm/Kconfig-21-\ttristate \"IBM LAN Virtual Ethernet support\"\n--\ndrivers/net/ethernet/ibm/Kconfig-29-\ndrivers/net/ethernet/ibm/Kconfig:30:config IBMVETH_KUNIT_TEST\ndrivers/net/ethernet/ibm/Kconfig-31-\tbool \"KUnit test for IBM LAN Virtual Ethernet support\" if !KUNIT_ALL_TESTS\n"
} |
| 5/2 | 2026/10/13 22:52 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18983 output: 38 thoughts: 23 Thoughts: Here's a summary of my thought process, tailored for an expert like you: **Diving into the IBM Ethernet Kconfig** Okay, let's get down to brass tacks. I'm thinking we need to zero in on the `drivers/net/ethernet/ibm/Kconfig` file. Specifically, I suspect the meat of what we're looking for lies around line 20. This Kconfig file is where the core configuration options for the IBM Ethernet drivers are defined, so it's the logical place to start digging. I'm anticipating we'll find some critical settings there, most likely related to the specific aspect we're currently troubleshooting or enhancing. Time to get my hands dirty and dissect that section! |
| 6/2 | 2026/10/13 22:53 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/ibm/Kconfig",
"FirstLine": 18,
"LineCount": 25
}Results: {
"Contents": " 18:\tif NET_VENDOR_IBM\n 19:\t\n 20:\tconfig IBMVETH\n 21:\t\ttristate \"IBM LAN Virtual Ethernet support\"\n 22:\t\tdepends on PPC_PSERIES\n 23:\t\thelp\n 24:\t\t This driver supports virtual ethernet adapters on newer IBM iSeries\n 25:\t\t and pSeries systems.\n 26:\t\n 27:\t\t To compile this driver as a module, choose M here. The module will\n 28:\t\t be called ibmveth.\n 29:\t\n 30:\tconfig IBMVETH_KUNIT_TEST\n 31:\t\tbool \"KUnit test for IBM LAN Virtual Ethernet support\" if !KUNIT_ALL_TESTS\n 32:\t\tdepends on KUNIT\n 33:\t\tdepends on KUNIT=y \u0026\u0026 IBMVETH=y\n 34:\t\tdefault KUNIT_ALL_TESTS\n 35:\t\thelp\n 36:\t\t This builds unit tests for the IBM LAN Virtual Ethernet driver.\n 37:\t\n 38:\t\t For more information on KUnit and unit tests in general, please refer\n 39:\t\t to the KUnit documentation in Documentation/dev-tools/kunit/.\n 40:\t\n 41:\t\t If unsure, say N.\n 42:\t\n"
} |
| 7/2 | 2026/10/13 22:53 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19538 output: 20 thoughts: 101 Thoughts: **Investigating a Potential Configuration Issue** Okay, so I'm looking at this `config IBMVETH` setting, and it's marked as dependent on `PPC_PSERIES`. My initial thought is to make sure this is accurate, as I'm working with an amd64 target. Let's see... The target architecture is, in fact, amd64. That raises a red flag immediately. Can IBMVETH even be compiled, or operate, on an amd64 system? Right, line 22 confirms the dependency: `depends on PPC_PSERIES`. That's the key. Now, the more pertinent question: can `PPC_PSERIES` even *be* selected on an amd64 architecture? I need to track down where `PPC_PSERIES` is defined to confirm whether this configuration is even logically sound, and I need to do so quickly. Let's check where `PPC_PSERIES` is defined. |
| 8/2 | 2026/10/13 22:53 | tool | grepper |
0mArgs:{
"Expression": "config PPC_PSERIES"
}Results: {
"Output": "arch/powerpc/platforms/pseries/Kconfig-1-# SPDX-License-Identifier: GPL-2.0\narch/powerpc/platforms/pseries/Kconfig:2:config PPC_PSERIES\narch/powerpc/platforms/pseries/Kconfig-3-\tdepends on PPC64 \u0026\u0026 PPC_BOOK3S\n--\narch/powerpc/platforms/pseries/Kconfig=92=config LPARCFG\n--\narch/powerpc/platforms/pseries/Kconfig-98-\narch/powerpc/platforms/pseries/Kconfig:99:config PPC_PSERIES_DEBUG\narch/powerpc/platforms/pseries/Kconfig-100-\tdepends on PPC_PSERIES \u0026\u0026 PPC_EARLY_DEBUG\n"
} |
| 9/2 | 2026/10/13 22:53 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20061 output: 30 thoughts: 679 Thoughts: **Analyzing the Suitability of IBMVETH for Fuzzing on amd64** Okay, so I'm digging into this `PPC_PSERIES` and `IBMVETH` situation. It's clear that `PPC_PSERIES` is tied to `PPC64 && PPC_BOOK3S`, as defined in `arch/powerpc/platforms/pseries/Kconfig`. This is definitively PowerPC-specific architecture stuff. The question is, can we even *compile* or enable `ibmveth` on amd64 (x86_64)? Let's not get ahead of ourselves. What about `IBMVETH_KUNIT_TEST`? Where does that fit in? Since the ultimate target is amd64, the KUnit tests are of little use. Can KUNIT tests even run on UML or x86? But wait, `IBMVETH_KUNIT_TEST` hinges on `IBMVETH=y`, which, in turn, depends on `PPC_PSERIES`. Let's not jump to conclusions about KUnit. I should check the KUnit documentation or if `COMPILE_TEST` is even a configuration option for `IBMVETH`. Hmm, does `IBMVETH` have a dependency like `PPC_PSERIES || COMPILE_TEST`? Let's get the definitive answer by checking lines 20-25 of `drivers/net/ethernet/ibm/Kconfig`: ``` config IBMVETH tristate "IBM LAN Virtual Ethernet support" depends on PPC_PSERIES ``` Nope, no sign of `COMPILE_TEST` in there! And even if it *could* compile-test, KUnit tests are essentially self-tests, and syzkaller *doesn't* fuzz KUnit tests. The target architecture, as defined in the context, is amd64. Okay, let's re-read the relevant section – Section 2, specifically the negative criteria. It outlines scenarios where we should return `WorthFuzzing=false`. The relevant part is: *"Code paths exclusive to architectures other than the target architecture."* So, let's connect the dots: The target architecture is amd64. `IBMVETH` depends on `PPC_PSERIES`, which, we know, depends on `PPC64 && PPC_BOOK3S`. Given that dependency chain, compiling it on amd64 is simply impossible. Now, let's check further to be absolutely sure. Can `ibmveth.c` use any symbols or headers that only exist on ppc64? I'll look at the includes and symbols within `ibmveth.c`. Specifically, I see: `#include <asm/vio.h>` and `#include <asm/hvcall.h>`. The critical question is, does x86 have any equivalent of `asm/hvcall.h` or `asm/vio.h`? |
| 10/2 | 2026/10/13 22:53 | tool | grepper |
0mError:no matches Args: {
"Expression": "hvcall\\.h",
"PathPrefixes": [
"arch/x86"
]
}Results: {
"error": "no matches"
} |
| 11/2 | 2026/10/13 22:53 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21432 output: 27 thoughts: 36 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating the Absence of `asm/hvcall.h` on x86 Architecture** Hmm, this is curious. I was just looking at `arch/x86` and, as I recall, there's no `asm/hvcall.h` header file to be found in the standard locations. That's unusual, and it's a critical piece that needs to be addressed for our work on the x86 hypervisor interface to proceed. I need to be sure. My next step is obvious. Let's trace it down. Time to verify the location of `asm/hvcall.h` in our source tree. This is a critical debugging step when dealing with any custom architecture or modified kernel. |
| 12/2 | 2026/10/13 22:53 | tool | grepper |
0mArgs:{
"Expression": "hvcall\\.h",
"PathPrefixes": [
"arch/"
]
}Results: {
"Output": "arch/powerpc/include/asm/book3s/64/tlbflush-radix.h-4-\narch/powerpc/include/asm/book3s/64/tlbflush-radix.h:5:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/book3s/64/tlbflush-radix.h-6-\n--\narch/powerpc/include/asm/guest-state-buffer.h-7-\narch/powerpc/include/asm/guest-state-buffer.h:8:#include \"asm/hvcall.h\"\narch/powerpc/include/asm/guest-state-buffer.h-9-#include \u003clinux/gfp.h\u003e\n--\narch/powerpc/include/asm/kvm_host.h-25-#include \u003casm/cacheflush.h\u003e\narch/powerpc/include/asm/kvm_host.h:26:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/kvm_host.h-27-#include \u003casm/mce.h\u003e\n--\narch/powerpc/include/asm/paravirt.h-9-#include \u003casm/lppaca.h\u003e\narch/powerpc/include/asm/paravirt.h:10:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/paravirt.h-11-#endif\n--\narch/powerpc/include/asm/plpar_wrappers.h-10-\narch/powerpc/include/asm/plpar_wrappers.h:11:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/plpar_wrappers.h-12-#include \u003casm/paca.h\u003e\n--\narch/powerpc/include/asm/ultravisor-api.h-10-\narch/powerpc/include/asm/ultravisor-api.h:11:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/ultravisor-api.h-12-\n--\narch/powerpc/include/asm/vio.h-19-\narch/powerpc/include/asm/vio.h:20:#include \u003casm/hvcall.h\u003e\narch/powerpc/include/asm/vio.h-21-\n--\narch/powerpc/kernel/asm-offsets.c-42-#include \u003casm/mmu.h\u003e\narch/powerpc/kernel/asm-offsets.c:43:#include \u003casm/hvcall.h\u003e\narch/powerpc/kernel/asm-offsets.c-44-#include \u003casm/xics.h\u003e\n--\narch/powerpc/kernel/dawr.c-12-#include \u003casm/machdep.h\u003e\narch/powerpc/kernel/dawr.c:13:#include \u003casm/hvcall.h\u003e\narch/powerpc/kernel/dawr.c-14-#include \u003casm/firmware.h\u003e\n--\narch/powerpc/kernel/head_64.S-32-#include \u003casm/setup.h\u003e\narch/powerpc/kernel/head_64.S:33:#include \u003casm/hvcall.h\u003e\narch/powerpc/kernel/head_64.S-34-#include \u003casm/thread_info.h\u003e\n--\narch/powerpc/kernel/hw_breakpoint.c-25-#include \u003casm/debug.h\u003e\narch/powerpc/kernel/hw_breakpoint.c:26:#include \u003casm/hvcall.h\u003e\narch/powerpc/kernel/hw_breakpoint.c-27-#include \u003casm/inst.h\u003e\n--\narch/powerpc/kernel/sysfs.c-17-#include \u003casm/cputable.h\u003e\narch/powerpc/kernel/sysfs.c:18:#include \u003casm/hvcall.h\u003e\narch/powerpc/kernel/sysfs.c-19-#include \u003casm/machdep.h\u003e\n--\narch/powerpc/kvm/book3s_64_mmu_hv.c-23-#include \u003casm/book3s/64/mmu-hash.h\u003e\narch/powerpc/kvm/book3s_64_mmu_hv.c:24:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_64_mmu_hv.c-25-#include \u003casm/synch.h\u003e\n--\narch/powerpc/kvm/book3s_64_vio.c-27-#include \u003casm/book3s/64/mmu-hash.h\u003e\narch/powerpc/kvm/book3s_64_vio.c:28:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_64_vio.c-29-#include \u003casm/synch.h\u003e\n--\narch/powerpc/kvm/book3s_hv.c-66-#include \u003casm/page.h\u003e\narch/powerpc/kvm/book3s_hv.c:67:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_hv.c-68-#include \u003casm/switch_to.h\u003e\n--\narch/powerpc/kvm/book3s_hv_nestedv2.c-22-#include \u003casm/kvm_book3s.h\u003e\narch/powerpc/kvm/book3s_hv_nestedv2.c:23:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_hv_nestedv2.c-24-#include \u003casm/pgalloc.h\u003e\n--\narch/powerpc/kvm/book3s_hv_rm_mmu.c-19-#include \u003casm/book3s/64/mmu-hash.h\u003e\narch/powerpc/kvm/book3s_hv_rm_mmu.c:20:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_hv_rm_mmu.c-21-#include \u003casm/synch.h\u003e\n--\narch/powerpc/kvm/book3s_hv_rm_xics.c-14-#include \u003casm/kvm_ppc.h\u003e\narch/powerpc/kvm/book3s_hv_rm_xics.c:15:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_hv_rm_xics.c-16-#include \u003casm/xics.h\u003e\n--\narch/powerpc/kvm/book3s_hv_rmhandlers.S-22-#include \u003casm/ptrace.h\u003e\narch/powerpc/kvm/book3s_hv_rmhandlers.S:23:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_hv_rmhandlers.S-24-#include \u003casm/asm-offsets.h\u003e\n--\narch/powerpc/kvm/book3s_rtas.c-13-#include \u003casm/kvm_ppc.h\u003e\narch/powerpc/kvm/book3s_rtas.c:14:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_rtas.c-15-#include \u003casm/rtas.h\u003e\n--\narch/powerpc/kvm/book3s_xics.c-17-#include \u003casm/kvm_ppc.h\u003e\narch/powerpc/kvm/book3s_xics.c:18:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_xics.c-19-#include \u003casm/xics.h\u003e\n--\narch/powerpc/kvm/book3s_xive.c-19-#include \u003casm/kvm_ppc.h\u003e\narch/powerpc/kvm/book3s_xive.c:20:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_xive.c-21-#include \u003casm/xics.h\u003e\n--\narch/powerpc/kvm/book3s_xive_native.c-18-#include \u003casm/kvm_ppc.h\u003e\narch/powerpc/kvm/book3s_xive_native.c:19:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/book3s_xive_native.c-20-#include \u003casm/xive.h\u003e\n--\narch/powerpc/kvm/guest-state-buffer.c-2-\narch/powerpc/kvm/guest-state-buffer.c:3:#include \"asm/hvcall.h\"\narch/powerpc/kvm/guest-state-buffer.c-4-#include \u003clinux/log2.h\u003e\n--\narch/powerpc/kvm/powerpc.c-31-#ifdef CONFIG_PPC_PSERIES\narch/powerpc/kvm/powerpc.c:32:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/powerpc.c-33-#include \u003casm/plpar_wrappers.h\u003e\n--\narch/powerpc/kvm/trace_hv.h-6-#include \"trace_book3s.h\"\narch/powerpc/kvm/trace_hv.h:7:#include \u003casm/hvcall.h\u003e\narch/powerpc/kvm/trace_hv.h-8-#include \u003casm/kvm_asm.h\u003e\n--\narch/powerpc/lib/locks.c-17-#if defined(CONFIG_PPC_SPLPAR)\narch/powerpc/lib/locks.c:18:#include \u003casm/hvcall.h\u003e\narch/powerpc/lib/locks.c-19-#include \u003casm/smp.h\u003e\n--\narch/powerpc/mm/numa.c-33-#include \u003casm/paca.h\u003e\narch/powerpc/mm/numa.c:34:#include \u003casm/hvcall.h\u003e\narch/powerpc/mm/numa.c-35-#include \u003casm/setup.h\u003e\n--\narch/powerpc/perf/hv-24x7.c-19-#include \u003casm/firmware.h\u003e\narch/powerpc/perf/hv-24x7.c:20:#include \u003casm/hvcall.h\u003e\narch/powerpc/perf/hv-24x7.c-21-#include \u003casm/io.h\u003e\n--\narch/powerpc/perf/hv-common.c-2-#include \u003casm/io.h\u003e\narch/powerpc/perf/hv-common.c:3:#include \u003casm/hvcall.h\u003e\narch/powerpc/perf/hv-common.c-4-\n--\narch/powerpc/perf/hv-gpci.c-15-#include \u003casm/firmware.h\u003e\narch/powerpc/perf/hv-gpci.c:16:#include \u003casm/hvcall.h\u003e\narch/powerpc/perf/hv-gpci.c-17-#include \u003casm/io.h\u003e\n--\narch/powerpc/platforms/powernv/opal-wrappers.S-9-#include \u003casm/ppc_asm.h\u003e\narch/powerpc/platforms/powernv/opal-wrappers.S:10:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/powernv/opal-wrappers.S-11-#include \u003casm/asm-offsets.h\u003e\n--\narch/powerpc/platforms/pseries/cmm.c-24-#include \u003casm/firmware.h\u003e\narch/powerpc/platforms/pseries/cmm.c:25:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/cmm.c-26-#include \u003casm/mmu.h\u003e\n--\narch/powerpc/platforms/pseries/hvCall.S-6-#include \u003clinux/jump_label.h\u003e\narch/powerpc/platforms/pseries/hvCall.S:7:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/hvCall.S-8-#include \u003casm/processor.h\u003e\n--\narch/powerpc/platforms/pseries/hvCall_inst.c-12-#include \u003clinux/cpumask.h\u003e\narch/powerpc/platforms/pseries/hvCall_inst.c:13:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/hvCall_inst.c-14-#include \u003casm/firmware.h\u003e\n--\narch/powerpc/platforms/pseries/hvconsole.c-15-#include \u003clinux/errno.h\u003e\narch/powerpc/platforms/pseries/hvconsole.c:16:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/hvconsole.c-17-#include \u003casm/hvconsole.h\u003e\n--\narch/powerpc/platforms/pseries/hvcserver.c-14-\narch/powerpc/platforms/pseries/hvcserver.c:15:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/hvcserver.c-16-#include \u003casm/hvcserver.h\u003e\n--\narch/powerpc/platforms/pseries/lparcfg.c-28-#include \u003casm/lppaca.h\u003e\narch/powerpc/platforms/pseries/lparcfg.c:29:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/lparcfg.c-30-#include \u003casm/firmware.h\u003e\n--\narch/powerpc/platforms/pseries/papr_platform_attributes.c-22-\narch/powerpc/platforms/pseries/papr_platform_attributes.c:23:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/papr_platform_attributes.c-24-#include \u003casm/machdep.h\u003e\n--\narch/powerpc/platforms/pseries/plpks.c-48-#include \u003clinux/bitfield.h\u003e\narch/powerpc/platforms/pseries/plpks.c:49:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/plpks.c-50-#include \u003casm/machdep.h\u003e\n--\narch/powerpc/platforms/pseries/pseries_energy.c-20-#include \u003casm/page.h\u003e\narch/powerpc/platforms/pseries/pseries_energy.c:21:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/pseries_energy.c-22-#include \u003casm/firmware.h\u003e\n--\narch/powerpc/platforms/pseries/suspend.c-11-#include \u003casm/firmware.h\u003e\narch/powerpc/platforms/pseries/suspend.c:12:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/suspend.c-13-#include \u003casm/machdep.h\u003e\n--\narch/powerpc/platforms/pseries/vas.c-16-#include \u003casm/machdep.h\u003e\narch/powerpc/platforms/pseries/vas.c:17:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/vas.c-18-#include \u003casm/plpar_wrappers.h\u003e\n--\narch/powerpc/platforms/pseries/vio.c-35-#include \u003casm/page.h\u003e\narch/powerpc/platforms/pseries/vio.c:36:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/vio.c-37-#include \u003casm/machdep.h\u003e\n--\narch/powerpc/platforms/pseries/vphn.c=25=static int vphn_unpack_associativity(const long *packed, __be32 *unpacked)\n--\narch/powerpc/platforms/pseries/vphn.c-76-#ifdef __KERNEL__\narch/powerpc/platforms/pseries/vphn.c:77:#include \u003casm/hvcall.h\u003e\narch/powerpc/platforms/pseries/vphn.c-78-\n--\narch/powerpc/sysdev/xics/icp-hv.c-18-#include \u003casm/io.h\u003e\narch/powerpc/sysdev/xics/icp-hv.c:19:#include \u003casm/hvcall.h\u003e\narch/powerpc/sysdev/xics/icp-hv.c-20-\n--\narch/powerpc/sysdev/xive/spapr.c-32-#include \u003casm/xive-regs.h\u003e\narch/powerpc/sysdev/xive/spapr.c:33:#include \u003casm/hvcall.h\u003e\narch/powerpc/sysdev/xive/spapr.c-34-#include \u003casm/svm.h\u003e\n--\narch/powerpc/xmon/xmon.c-56-#ifdef CONFIG_PPC64\narch/powerpc/xmon/xmon.c:57:#include \u003casm/hvcall.h\u003e\narch/powerpc/xmon/xmon.c-58-#include \u003casm/paca.h\u003e\n"
} |
| 13/2 | 2026/10/13 22:53 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25891 output: 82 thoughts: 387 Thoughts: **Analysis of the Patch: WorthFuzzing = False** Okay, let's break this down. My initial assessment is that this patch doesn't warrant fuzzing, and here's why. The core of this patch modifies `drivers/net/ethernet/ibm/ibmveth.[ch]`. Now, `asm/hvcall.h` is exclusively in `arch/powerpc`, and `IBMVETH` relies on `PPC_PSERIES`. Given that our target architecture is amd64, it's clear that this `IBMVETH` code is PowerPC-specific – particularly `ppc64`, since `PPC_PSERIES` implies we're dealing with pSeries hardware. This means the modified code will not even compile, let alone execute, on our amd64 target. To be absolutely sure, let's revisit Section 2 of the fuzzing criteria. Specifically, the "Unreachable execution paths" category. We're looking for code that's only executed under specific circumstances that we won't encounter. This patch's modification of a driver exclusive to a different architecture falls precisely into the "Code paths exclusive to architectures other than the target architecture" bullet point. Perfect. I’m also checking for any common files touched in the patch and that are relevant, but the diff only shows changes in `drivers/net/ethernet/ibm/ibmveth.c` and `drivers/net/ethernet/ibm/ibmveth.h`. No other files are implicated. Therefore, my conclusion is: * `WorthFuzzing`: false * `Reasoning`: The patch modifies the `ibmveth` driver, which depends on `CONFIG_PPC_PSERIES` and is exclusive to the PowerPC architecture. Since the target architecture is amd64, the modified code cannot be built or executed. This puts us squarely into the unreachable execution paths criteria, meaning fuzzing would be pointless. * `EnableConfigs`: \[ ] * `FocusSymbols`: \[ ] There's no ambiguity here. I'm satisfied with this determination, and I'll invoke `set-results`. |
| 14/2 | 2026/10/13 22:53 | tool | set-results |
0mArgs:{
"EnableConfigs": [],
"FocusSymbols": [],
"Reasoning": "The changes are confined to the IBM Virtual Ethernet driver (ibmveth), which depends on CONFIG_PPC_PSERIES. This code is exclusive to the PowerPC architecture and cannot be compiled or executed on the target architecture (amd64).",
"WorthFuzzing": false
}Results: {
"EnableConfigs": null,
"FocusSymbols": [],
"Reasoning": "The changes are confined to the IBM Virtual Ethernet driver (ibmveth), which depends on CONFIG_PPC_PSERIES. This code is exclusive to the PowerPC architecture and cannot be compiled or executed on the target architecture (amd64).",
"WorthFuzzing": false
} |
| 15/1 | 2026/10/13 22:53 | 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) |
|---|