AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/11/14 05:13 flow patch-triage
3m Args:
null

Results:
{
  "EnableConfigs": [
    "NET_IPGRE",
    "NET_IPGRE_DEMUX",
    "NET_IP_TUNNEL",
    "NET_IPGRE_BROADCAST",
    "IPV6_GRE",
    "IPV6_TUNNEL",
    "IPV6_SIT"
  ],
  "FocusSymbols": [
    "gre_parse_header",
    "ip_tunnel_rcv",
    "ip_tunnel_xmit",
    "ip_md_tunnel_xmit",
    "ipgre_rcv",
    "ipgre_xmit",
    "erspan_rcv",
    "erspan_xmit",
    "gre_tap_xmit",
    "ip6gre_rcv",
    "ip6erspan_rcv",
    "ip6_tnl_rcv",
    "ipxip6_rcv",
    "ipip6_tunnel_xmit"
  ],
  "KMSANReasoning": "The patch series introduces detailed skb drop reasons (enum skb_drop_reason) and replaces kfree_skb() with kfree_skb_reason() across IPv4 and IPv6 GRE, ERSPAN, and generic IP tunnel receive and transmit paths.\n\nKMSAN vs KASAN Applicability:\n1. No uninitialized memory or info-leak risks: The patch does not expose any uninitialized data or kernel memory to user space (no copy_to_user, netlink attributes, ioctl output, or socket options are introduced or modified). Drop reasons are internal kernel tracepoint arguments passed to kfree_skb_reason().\n2. Variable initialization: All newly introduced local variables (e.g., `enum skb_drop_reason reason`) are either initialized at declaration or explicitly assigned along every code path prior to being read or passed to kfree_skb_reason().\n3. Data structures: The `struct tnl_ptk_info tpi` parsed by `gre_parse_header()` has all relevant fields populated on success and is not read on failure paths. No new heap/stack allocations or complex structures are created.\n4. Any potential bugs in header bounds calculation or parsing would manifest as buffer overruns or invalid pointer dereferences, which are covered by KASAN and standard sanitizers rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies core networking tunnel code (GRE, ERSPAN, SIT, and generic IP/IPv6 tunnels) to return detailed skb drop reasons rather than generic error codes. It changes the signature and return semantics of gre_parse_header() and ip_tunnel_encap(), and updates packet receive and transmit routines across net/ipv4 and net/ipv6. This reachable code handles untrusted packet input and tunnel configurations, making it relevant for fuzzing to discover regressions or crashes with malformed tunnel headers, sequence numbers, checksums, and encapsulation options.",
  "WorthFuzzing": true
}

1/1 2026/11/14 05:13 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit 1539401cda3b1821003d9f832e0ad9248abccfbf\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Sat Nov 14 05:13:51 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h\nindex fa2fe89905573a..fb6f3d8da960c7 100644\n--- a/include/net/dropreason-core.h\n+++ b/include/net/dropreason-core.h\n@@ -128,6 +128,10 @@\n \tFN(PSP_INPUT)\t\t\t\\\n \tFN(PSP_OUTPUT)\t\t\t\\\n \tFN(RECURSION_LIMIT)\t\t\\\n+\tFN(TUNNEL_OPT_MISMATCH)\t\t\\\n+\tFN(TUNNEL_OLD_SEQ)\t\t\\\n+\tFN(GRE_CSUM)\t\t\t\\\n+\tFN(TUNNEL_ENCAP)\t\t\\\n \tFNe(MAX)\n \n /**\n@@ -535,11 +539,13 @@ enum skb_drop_reason {\n \t * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:\n \t * 1) VXLAN reserved fields are not zero\n \t * 2) VXLAN \"I\" flag is not set\n+\t * 3) GRE version is not supported or the routing bit is set\n \t */\n \tSKB_DROP_REASON_TUNNEL_INVALID_HDR,\n \t/**\n \t * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the\n-\t * packet, e.g. no VXLAN device for its VNI\n+\t * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its\n+\t * endpoints and key\n \t */\n \tSKB_DROP_REASON_TUNNEL_NOT_FOUND,\n \t/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */\n@@ -612,6 +618,29 @@ enum skb_drop_reason {\n \t * itself.\n \t */\n \tSKB_DROP_REASON_RECURSION_LIMIT,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_OPT_MISMATCH: the tunnel options carried by\n+\t * the packet do not match the tunnel configuration, e.g. a GRE tunnel\n+\t * configured with 'icsum' or 'iseq' received a packet with no checksum\n+\t * or no sequence number, or a GRE tunnel without 'icsum' received a\n+\t * packet with a checksum.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_OPT_MISMATCH,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_OLD_SEQ: the sequence number carried by the\n+\t * packet is older than the one expected by the tunnel, e.g. the packet\n+\t * was reordered in the network or by the receive processing, or the\n+\t * remote endpoint restarted and reset its sequence numbering.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_OLD_SEQ,\n+\t/** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */\n+\tSKB_DROP_REASON_GRE_CSUM,\n+\t/**\n+\t * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation\n+\t * header of a tunnel, e.g. an unknown or unregistered encapsulation\n+\t * type.\n+\t */\n+\tSKB_DROP_REASON_TUNNEL_ENCAP,\n \t/**\n \t * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which\n \t * shouldn't be used as a real 'reason' - only for tracing code gen\ndiff --git a/include/net/gre.h b/include/net/gre.h\nindex b55f67ecd2fc4b..b5dbe00ab15ef7 100644\n--- a/include/net/gre.h\n+++ b/include/net/gre.h\n@@ -32,8 +32,9 @@ struct gre_protocol {\n int gre_add_protocol(const struct gre_protocol *proto, u8 version);\n int gre_del_protocol(const struct gre_protocol *proto, u8 version);\n \n-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t     bool *csum_err, __be16 proto, int nhs);\n+enum skb_drop_reason\n+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n+\t\t bool ignore_csum_err, __be16 proto, int nhs);\n \n static inline bool netif_is_gretap(const struct net_device *dev)\n {\ndiff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h\nindex 5cccf4c0e6913a..87046ba50d45bb 100644\n--- a/include/net/ip_tunnels.h\n+++ b/include/net/ip_tunnels.h\n@@ -207,10 +207,6 @@ struct tnl_ptk_info {\n \tint hdr_len;\n };\n \n-#define PACKET_RCVD\t0\n-#define PACKET_REJECT\t1\n-#define PACKET_NEXT\t2\n-\n #define IP_TNL_HASH_BITS   7\n #define IP_TNL_HASH_SIZE   (1 \u003c\u003c IP_TNL_HASH_BITS)\n \n@@ -545,18 +541,18 @@ static inline int ip_encap_hlen(struct ip_tunnel_encap *e)\n \treturn hlen;\n }\n \n-static inline int ip_tunnel_encap(struct sk_buff *skb,\n-\t\t\t\t  struct ip_tunnel_encap *e,\n-\t\t\t\t  u8 *protocol, struct flowi4 *fl4)\n+static inline enum skb_drop_reason\n+ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel_encap *e,\n+\t\tu8 *protocol, struct flowi4 *fl4)\n {\n \tconst struct ip_tunnel_encap_ops *ops;\n \tint ret = -EINVAL;\n \n \tif (e-\u003etype == TUNNEL_ENCAP_NONE)\n-\t\treturn 0;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \n \tif (e-\u003etype \u003e= MAX_IPTUN_ENCAP_OPS)\n-\t\treturn -EINVAL;\n+\t\treturn SKB_DROP_REASON_TUNNEL_ENCAP;\n \n \trcu_read_lock();\n \tops = rcu_dereference(iptun_encaps[e-\u003etype]);\n@@ -564,7 +560,11 @@ static inline int ip_tunnel_encap(struct sk_buff *skb,\n \t\tret = ops-\u003ebuild_header(skb, e, protocol, fl4);\n \trcu_read_unlock();\n \n-\treturn ret;\n+\tif (!ret)\n+\t\treturn SKB_NOT_DROPPED_YET;\n+\tif (ret == -ENOMEM)\n+\t\treturn SKB_DROP_REASON_NOMEM;\n+\treturn SKB_DROP_REASON_TUNNEL_ENCAP;\n }\n \n /* Extract dsfield from inner protocol */\ndiff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c\nindex 96fd7dc6d82dd0..6c1d1fe914b895 100644\n--- a/net/ipv4/gre_demux.c\n+++ b/net/ipv4/gre_demux.c\n@@ -56,28 +56,47 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)\n }\n EXPORT_SYMBOL_GPL(gre_del_protocol);\n \n-/* Fills in tpi and returns header length to be pulled.\n- * Note that caller must use pskb_may_pull() before pulling GRE header.\n+/**\n+ * gre_parse_header() - parse the GRE header of a packet\n+ * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n+ * @tpi: filled in with the fields of the header, and with the length of\n+ *\tthe header to be pulled in tpi-\u003ehdr_len\n+ * @ignore_csum_err: do not reject the header when its checksum does not\n+ *\tmatch. The ICMP error handlers set it, as they only get a part of the\n+ *\toriginal packet; the checksum is still computed and the rest of the\n+ *\theader is parsed.\n+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or\n+ *\tETH_P_IPV6\n+ * @nhs: the offset of the GRE header from skb-\u003edata\n+ *\n+ * The caller must use pskb_may_pull() before pulling the GRE header.\n+ *\n+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n+ * header is rejected.\n  */\n-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t     bool *csum_err, __be16 proto, int nhs)\n+enum skb_drop_reason\n+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n+\t\t bool ignore_csum_err, __be16 proto, int nhs)\n {\n \tconst struct gre_base_hdr *greh;\n+\tenum skb_drop_reason reason;\n \t__be32 *options;\n \tint hdr_len;\n \n-\tif (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))\n-\t\treturn -EINVAL;\n+\treason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));\n+\tif (unlikely(reason))\n+\t\treturn reason;\n \n \tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n \tif (unlikely(greh-\u003eflags \u0026 (GRE_VERSION | GRE_ROUTING)))\n-\t\treturn -EINVAL;\n+\t\treturn SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n \n \tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\n \thdr_len = gre_calc_hlen(tpi-\u003eflags);\n \n-\tif (!pskb_may_pull(skb, nhs + hdr_len))\n-\t\treturn -EINVAL;\n+\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\n+\tif (reason)\n+\t\treturn reason;\n \n \tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n \ttpi-\u003eproto = greh-\u003eprotocol;\n@@ -87,9 +106,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\tif (!skb_checksum_simple_validate(skb)) {\n \t\t\tskb_checksum_try_convert(skb, IPPROTO_GRE,\n \t\t\t\t\t\t null_compute_pseudo);\n-\t\t} else if (csum_err) {\n-\t\t\t*csum_err = true;\n-\t\t\treturn -EINVAL;\n+\t\t} else if (!ignore_csum_err) {\n+\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n \t\t}\n \n \t\toptions++;\n@@ -117,7 +135,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\tval = skb_header_pointer(skb, nhs + hdr_len,\n \t\t\t\t\t sizeof(_val), \u0026_val);\n \t\tif (!val)\n-\t\t\treturn -EINVAL;\n+\t\t\treturn SKB_DROP_REASON_PKT_TOO_SMALL;\n \t\ttpi-\u003eproto = proto;\n \t\tif ((*val \u0026 0xF0) != 0x40)\n \t\t\thdr_len += 4;\n@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t    greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n \t\tstruct erspan_base_hdr *ershdr;\n \n-\t\tif (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))\n-\t\t\treturn -EINVAL;\n+\t\treason = pskb_may_pull_reason(skb,\n+\t\t\t\t\t      nhs + hdr_len + sizeof(*ershdr));\n+\t\tif (reason)\n+\t\t\treturn reason;\n \n \t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\n \t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n \t}\n \n-\treturn hdr_len;\n+\treturn SKB_NOT_DROPPED_YET;\n }\n EXPORT_SYMBOL(gre_parse_header);\n \n static int gre_rcv(struct sk_buff *skb)\n {\n \tconst struct gre_protocol *proto;\n+\tenum skb_drop_reason reason;\n \tu8 ver;\n \tint ret;\n \n-\tif (!pskb_may_pull(skb, 12))\n+\treason = pskb_may_pull_reason(skb, 12);\n+\tif (reason)\n \t\tgoto drop;\n \n \tver = skb-\u003edata[1]\u00260x7f;\n-\tif (ver \u003e= GREPROTO_MAX)\n+\tif (ver \u003e= GREPROTO_MAX) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n \t\tgoto drop;\n+\t}\n \n \trcu_read_lock();\n \tproto = rcu_dereference(gre_proto[ver]);\n@@ -167,11 +191,11 @@ static int gre_rcv(struct sk_buff *skb)\n drop_nohandler:\n \trcu_read_unlock();\n \tdev_core_stats_rx_nohandler_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);\n \treturn NET_RX_DROP;\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn NET_RX_DROP;\n }\n \ndiff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c\nindex 5485586fa0e625..71e087a7afcf00 100644\n--- a/net/ipv4/ip_gre.c\n+++ b/net/ipv4/ip_gre.c\n@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)\n \tconst int code = icmp_hdr(skb)-\u003ecode;\n \tstruct tnl_ptk_info tpi;\n \n-\tif (gre_parse_header(skb, \u0026tpi, NULL, htons(ETH_P_IP),\n-\t\t\t     iph-\u003eihl * 4) \u003c 0)\n+\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\n+\t\t\t     iph-\u003eihl * 4))\n \t\treturn;\n \n \tif (type == ICMP_DEST_UNREACH \u0026\u0026 code == ICMP_FRAG_NEEDED) {\n@@ -264,9 +264,11 @@ static bool is_erspan_type1(int gre_hdr_len)\n \treturn gre_hdr_len == 4;\n }\n \n-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n-\t\t      int gre_hdr_len)\n+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n+\t\t\t\t       struct tnl_ptk_info *tpi,\n+\t\t\t\t       int gre_hdr_len)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct net *net = dev_net(skb-\u003edev);\n \tstruct metadata_dst *tun_dst = NULL;\n \tstruct erspan_base_hdr *ershdr;\n@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\ttunnel = ip_tunnel_lookup(itn, skb-\u003edev-\u003eifindex, flags,\n \t\t\t\t\t  iph-\u003esaddr, iph-\u003edaddr, 0);\n \t} else {\n-\t\tif (unlikely(!pskb_may_pull(skb,\n-\t\t\t\t\t    gre_hdr_len + sizeof(*ershdr))))\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = pskb_may_pull_reason(skb,\n+\t\t\t\t\t      gre_hdr_len + sizeof(*ershdr));\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\n \n \t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + gre_hdr_len);\n \t\tver = ershdr-\u003ever;\n@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\telse\n \t\t\tlen = gre_hdr_len + erspan_hdr_len(ver);\n \n-\t\tif (unlikely(!pskb_may_pull(skb, len)))\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = pskb_may_pull_reason(skb, len);\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\n \n-\t\tif (__iptunnel_pull_header(skb,\n-\t\t\t\t\t   len,\n-\t\t\t\t\t   htons(ETH_P_TEB),\n-\t\t\t\t\t   false, false))\n+\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\n+\t\t\t\t\t\tfalse, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \n \t\tif (tunnel-\u003ecollect_md) {\n@@ -328,7 +331,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \t\t\ttun_dst = ip_tun_rx_dst(skb, flags,\n \t\t\t\t\t\ttun_id, sizeof(*md));\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\t/* MUST set options_len before referencing options */\n \t\t\tinfo = \u0026tun_dst-\u003eu.tun_info;\n@@ -354,18 +357,21 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n \n \t\tskb_reset_mac_header(skb);\n \t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\tkfree_skb_reason(skb, reason);\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n-\t\t       struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)\n+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\n+\t\t\t\t\tconst struct tnl_ptk_info *tpi,\n+\t\t\t\t\tstruct ip_tunnel_net *itn,\n+\t\t\t\t\tint hdr_len, bool raw_proto)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct metadata_dst *tun_dst = NULL;\n \tconst struct iphdr *iph;\n \tstruct ip_tunnel *tunnel;\n@@ -377,8 +383,9 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n \tif (tunnel) {\n \t\tconst struct iphdr *tnl_params;\n \n-\t\tif (__iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\n-\t\t\t\t\t   raw_proto, false))\n+\t\treason = __iptunnel_pull_header(skb, hdr_len, tpi-\u003eproto,\n+\t\t\t\t\t\traw_proto, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \n \t\t/* Special case for ipgre_header_parse(), which expects the\n@@ -401,75 +408,80 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n \t\t\ttun_id = key32_to_tunnel_id(tpi-\u003ekey);\n \t\t\ttun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \t\t}\n \n \t\tip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n-\treturn PACKET_NEXT;\n+\treturn SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n \n drop:\n-\tkfree_skb(skb);\n-\treturn PACKET_RCVD;\n+\tkfree_skb_reason(skb, reason);\n+\treturn SKB_NOT_DROPPED_YET;\n }\n \n-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,\n-\t\t     int hdr_len)\n+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,\n+\t\t\t\t      const struct tnl_ptk_info *tpi,\n+\t\t\t\t      int hdr_len)\n {\n \tstruct net *net = dev_net(skb-\u003edev);\n+\tenum skb_drop_reason reason;\n \tstruct ip_tunnel_net *itn;\n-\tint res;\n \n \tif (tpi-\u003eproto == htons(ETH_P_TEB))\n \t\titn = net_generic(net, gre_tap_net_id);\n \telse\n \t\titn = net_generic(net, ipgre_net_id);\n \n-\tres = __ipgre_rcv(skb, tpi, itn, hdr_len, false);\n-\tif (res == PACKET_NEXT \u0026\u0026 tpi-\u003eproto == htons(ETH_P_TEB)) {\n+\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);\n+\tif (reason == SKB_DROP_REASON_TUNNEL_NOT_FOUND \u0026\u0026\n+\t    tpi-\u003eproto == htons(ETH_P_TEB)) {\n \t\t/* ipgre tunnels in collect metadata mode should receive\n \t\t * also ETH_P_TEB traffic.\n \t\t */\n \t\titn = net_generic(net, ipgre_net_id);\n-\t\tres = __ipgre_rcv(skb, tpi, itn, hdr_len, true);\n+\t\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);\n \t}\n-\treturn res;\n+\treturn reason;\n }\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct tnl_ptk_info tpi;\n-\tbool csum_err = false;\n-\tint hdr_len;\n \n #ifdef CONFIG_NET_IPGRE_BROADCAST\n \tif (ipv4_is_multicast(ip_hdr(skb)-\u003edaddr)) {\n \t\t/* Looped back packet, drop it! */\n-\t\tif (rt_is_output_route(skb_rtable(skb)))\n+\t\tif (rt_is_output_route(skb_rtable(skb))) {\n+\t\t\treason = SKB_DROP_REASON_NOT_SPECIFIED;\n \t\t\tgoto drop;\n+\t\t}\n \t}\n #endif\n \n-\thdr_len = gre_parse_header(skb, \u0026tpi, \u0026csum_err, htons(ETH_P_IP), 0);\n-\tif (hdr_len \u003c 0)\n+\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\n+\tif (reason)\n \t\tgoto drop;\n \n \tif (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||\n \t\t     tpi.proto == htons(ETH_P_ERSPAN2))) {\n-\t\tif (erspan_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\t\treason = erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\t\tif (!reason)\n \t\t\treturn 0;\n \t\tgoto out;\n \t}\n \n-\tif (ipgre_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\treason = ipgre_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\tif (!reason)\n \t\treturn 0;\n \n out:\n \ticmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -496,6 +508,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)\n static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t__be16 proto)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \tstruct ip_tunnel_info *tun_info;\n@@ -504,19 +517,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t     ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t     ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \n \tkey = \u0026tun_info-\u003ekey;\n \ttunnel_hlen = gre_calc_hlen(key-\u003etun_flags);\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \t/* Push Tunnel header. */\n \tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,\n-\t\t\t\t\t      tunnel-\u003eparms.o_flags)))\n+\t\t\t\t\t      tunnel-\u003eparms.o_flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \t__set_bit(IP_TUNNEL_CSUM_BIT, flags);\n \t__set_bit(IP_TUNNEL_KEY_BIT, flags);\n@@ -533,12 +552,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,\n \treturn;\n \n err_free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n }\n \n static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \tstruct ip_tunnel_info *tun_info;\n@@ -552,29 +572,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t     ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t     ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \n \tkey = \u0026tun_info-\u003ekey;\n-\tif (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info-\u003ekey.tun_flags))\n+\tif (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info-\u003ekey.tun_flags)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n-\tif (tun_info-\u003eoptions_len \u003c sizeof(*md))\n+\t}\n+\tif (tun_info-\u003eoptions_len \u003c sizeof(*md)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto err_free_skb;\n+\t}\n \tmd = ip_tunnel_info_opts(tun_info);\n \n \t/* ERSPAN has fixed 8 byte GRE header */\n \tversion = md-\u003eversion;\n \ttunnel_hlen = 8 + erspan_hdr_len(version);\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n-\tif (gre_handle_offloads(skb, false))\n+\tif (gre_handle_offloads(skb, false)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto err_free_skb;\n+\t}\n \n \tif (skb-\u003elen \u003e dev-\u003emtu + dev-\u003ehard_header_len) {\n-\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len))\n+\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto err_free_skb;\n+\t\t}\n \t\ttruncate = true;\n \t}\n \n@@ -606,6 +638,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \t\t\t\t       truncate, true);\n \t\tproto = htons(ETH_P_ERSPAN2);\n \t} else {\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto err_free_skb;\n \t}\n \n@@ -618,7 +651,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)\n \treturn;\n \n err_free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n }\n \n@@ -652,8 +685,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n \tconst struct iphdr *tnl_params;\n+\tenum skb_drop_reason reason;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -664,10 +699,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \tif (dev-\u003eheader_ops) {\n \t\tint pull_len = tunnel-\u003ehlen + sizeof(struct iphdr);\n \n-\t\tif (skb_cow_head(skb, 0))\n+\t\tif (skb_cow_head(skb, 0)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \n-\t\tif (!pskb_may_pull(skb, pull_len))\n+\t\treason = pskb_may_pull_reason(skb, pull_len);\n+\t\tif (reason)\n \t\t\tgoto free_skb;\n \n \t\ttnl_params = (const struct iphdr *)skb-\u003edata;\n@@ -677,25 +715,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,\n \t\tskb_reset_mac_header(skb);\n \n \t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL \u0026\u0026\n-\t\t    skb_checksum_start(skb) \u003c skb-\u003edata)\n+\t\t    skb_checksum_start(skb) \u003c skb-\u003edata) {\n+\t\t\treason = SKB_DROP_REASON_SKB_CSUM;\n \t\t\tgoto free_skb;\n+\t\t}\n \t} else {\n-\t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\t\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \n \t\ttnl_params = \u0026tunnel-\u003eparms.iph;\n \t}\n \n \tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n \n-\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))\n+\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \t__gre_xmit(skb, dev, tnl_params, skb-\u003eprotocol, flags);\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -705,10 +749,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n {\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n+\tenum skb_drop_reason reason;\n \tbool truncate = false;\n \t__be16 proto;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -716,15 +762,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \t\treturn NETDEV_TX_OK;\n \t}\n \n-\tif (gre_handle_offloads(skb, false))\n+\tif (gre_handle_offloads(skb, false)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \tif (skb-\u003elen \u003e dev-\u003emtu + dev-\u003ehard_header_len) {\n-\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len))\n+\t\tif (pskb_trim(skb, dev-\u003emtu + dev-\u003ehard_header_len)) {\n+\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\tgoto free_skb;\n+\t\t}\n \t\ttruncate = true;\n \t}\n \n@@ -745,6 +797,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \t\t\t\t       truncate, true);\n \t\tproto = htons(ETH_P_ERSPAN2);\n \t} else {\n+\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\tgoto free_skb;\n \t}\n \n@@ -753,7 +806,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\n@@ -763,8 +816,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n {\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tIP_TUNNEL_DECLARE_FLAGS(flags);\n+\tenum skb_drop_reason reason;\n \n-\tif (!pskb_inet_may_pull(skb))\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason)\n \t\tgoto free_skb;\n \n \tif (tunnel-\u003ecollect_md) {\n@@ -774,17 +829,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,\n \n \tip_tunnel_flags_copy(flags, tunnel-\u003eparms.o_flags);\n \n-\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))\n+\tif (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n-\tif (skb_cow_head(skb, dev-\u003eneeded_headroom))\n+\tif (skb_cow_head(skb, dev-\u003eneeded_headroom)) {\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto free_skb;\n+\t}\n \n \t__gre_xmit(skb, dev, \u0026tunnel-\u003eparms.iph, htons(ETH_P_TEB), flags);\n \treturn NETDEV_TX_OK;\n \n free_skb:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \tDEV_STATS_INC(dev, tx_dropped);\n \treturn NETDEV_TX_OK;\n }\ndiff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c\nindex 0875474a578a4a..924d02d0cc7bf3 100644\n--- a/net/ipv4/ip_tunnel.c\n+++ b/net/ipv4/ip_tunnel.c\n@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t\t  const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,\n \t\t  bool log_ecn_error)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tconst struct iphdr *iph = ip_hdr(skb);\n \tint nh, err;\n \n@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t    test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n \t\tgoto drop;\n \t}\n \n \tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n-\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags) ||\n-\t\t    (tunnel-\u003ei_seqno \u0026\u0026 (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0)) {\n+\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n+\t\t\tgoto drop;\n+\t\t}\n+\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n+\t\t    (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;\n \t\t\tgoto drop;\n \t\t}\n \t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \n \tskb_set_network_header(skb, (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) ? ETH_HLEN : 0);\n \n-\tif (!pskb_inet_may_pull(skb)) {\n+\treason = pskb_inet_may_pull_reason(skb);\n+\tif (reason) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\tgoto drop;\n@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n \t\tif (err \u003e 1) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n \t\t\tgoto drop;\n \t\t}\n \t}\n@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,\n drop:\n \tif (tun_dst)\n \t\tdst_release((struct dst_entry *)tun_dst);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n EXPORT_SYMBOL_GPL(ip_tunnel_rcv);\n@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,\n void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t       u8 proto, int tunnel_hlen)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tu32 headroom = sizeof(struct iphdr);\n \tstruct ip_tunnel_info *tun_info;\n@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \ttun_info = skb_tunnel_info(skb);\n \tif (unlikely(!tun_info || !(tun_info-\u003emode \u0026 IP_TUNNEL_INFO_TX) ||\n-\t\t     ip_tunnel_info_af(tun_info) != AF_INET))\n+\t\t     ip_tunnel_info_af(tun_info) != AF_INET)) {\n+\t\treason = SKB_DROP_REASON_TUNNEL_TXINFO;\n \t\tgoto tx_error;\n+\t}\n \tkey = \u0026tun_info-\u003ekey;\n \tmemset(\u0026(IPCB(skb)-\u003eopt), 0, sizeof(IPCB(skb)-\u003eopt));\n \tinner_iph = (const struct iphdr *)skb_inner_network_header(skb);\n@@ -608,7 +622,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (!tunnel_hlen)\n \t\ttunnel_hlen = ip_encap_hlen(\u0026tun_info-\u003eencap);\n \n-\tif (ip_tunnel_encap(skb, \u0026tun_info-\u003eencap, \u0026proto, \u0026fl4) \u003c 0)\n+\treason = ip_tunnel_encap(skb, \u0026tun_info-\u003eencap, \u0026proto, \u0026fl4);\n+\tif (reason)\n \t\tgoto tx_error;\n \n \tuse_cache = ip_tunnel_dst_cache_usable(skb, tun_info);\n@@ -618,6 +633,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\trt = ip_route_output_key(tunnel-\u003enet, \u0026fl4);\n \t\tif (IS_ERR(rt)) {\n \t\t\tDEV_STATS_INC(dev, tx_carrier_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \t\tif (use_cache)\n@@ -627,6 +643,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (rt-\u003edst.dev == dev) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, collisions);\n+\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\tgoto tx_error;\n \t}\n \n@@ -635,6 +652,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,\n \t\t\t    key-\u003eu.ipv4.dst, true)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n \t\tgoto tx_error;\n \t}\n \n@@ -652,6 +670,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \theadroom += LL_RESERVED_SPACE(rt-\u003edst.dev) + rt-\u003edst.header_len;\n \tif (skb_cow_head(skb, headroom)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_NOMEM;\n \t\tgoto tx_dropped;\n \t}\n \n@@ -666,13 +685,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n tx_dropped:\n \tDEV_STATS_INC(dev, tx_dropped);\n kfree:\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n }\n EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);\n \n void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t    const struct iphdr *tnl_params, u8 protocol)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip_tunnel *tunnel = netdev_priv(dev);\n \tstruct ip_tunnel_info *tun_info = NULL;\n \tconst struct iphdr *inner_iph;\n@@ -700,6 +720,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\tif (!skb_dst(skb)) {\n \t\t\tDEV_STATS_INC(dev, tx_fifo_errors);\n+\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\tgoto tx_error;\n \t\t}\n \n@@ -713,9 +734,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t} else if (payload_protocol == htons(ETH_P_IP)) {\n \t\t\trt = skb_rtable(skb);\n \t\t\tdst = rt_nexthop(rt, inner_iph-\u003edaddr);\n-\t\t}\n #if IS_ENABLED(CONFIG_IPV6)\n-\t\telse if (payload_protocol == htons(ETH_P_IPV6)) {\n+\t\t} else if (payload_protocol == htons(ETH_P_IPV6)) {\n \t\t\tconst struct in6_addr *addr6;\n \t\t\tstruct neighbour *neigh;\n \t\t\tbool do_tx_error_icmp;\n@@ -723,8 +743,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\t\tneigh = dst_neigh_lookup(skb_dst(skb),\n \t\t\t\t\t\t \u0026ipv6_hdr(skb)-\u003edaddr);\n-\t\t\tif (!neigh)\n+\t\t\tif (!neigh) {\n+\t\t\t\treason = SKB_DROP_REASON_NEIGH_CREATEFAIL;\n \t\t\t\tgoto tx_error;\n+\t\t\t}\n \n \t\t\taddr6 = (const struct in6_addr *)\u0026neigh-\u003eprimary_key;\n \t\t\taddr_type = ipv6_addr_type(addr6);\n@@ -741,12 +763,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t\tdst = addr6-\u003es6_addr32[3];\n \t\t\t}\n \t\t\tneigh_release(neigh);\n-\t\t\tif (do_tx_error_icmp)\n+\t\t\tif (do_tx_error_icmp) {\n+\t\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\t\tgoto tx_error_icmp;\n-\t\t}\n+\t\t\t}\n #endif\n-\t\telse\n+\t\t} else {\n+\t\t\treason = SKB_DROP_REASON_NO_TX_TARGET;\n \t\t\tgoto tx_error;\n+\t\t}\n \n \t\tif (!md)\n \t\t\tconnected = false;\n@@ -769,7 +794,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \t\t\t    tunnel-\u003enet, READ_ONCE(tunnel-\u003eparms.link),\n \t\t\t    tunnel-\u003efwmark, skb_get_hash(skb), 0);\n \n-\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4) \u003c 0)\n+\treason = ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4);\n+\tif (reason)\n \t\tgoto tx_error;\n \n \tif (connected \u0026\u0026 md) {\n@@ -787,6 +813,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \t\tif (IS_ERR(rt)) {\n \t\t\tDEV_STATS_INC(dev, tx_carrier_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_OUTNOROUTES;\n \t\t\tgoto tx_error;\n \t\t}\n \t\tif (use_cache)\n@@ -800,6 +827,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (rt-\u003edst.dev == dev) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, collisions);\n+\t\treason = SKB_DROP_REASON_RECURSION_LIMIT;\n \t\tgoto tx_error;\n \t}\n \n@@ -809,6 +837,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \n \tif (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {\n \t\tip_rt_put(rt);\n+\t\treason = SKB_DROP_REASON_PKT_TOO_BIG;\n \t\tgoto tx_error;\n \t}\n \n@@ -843,7 +872,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n \tif (skb_cow_head(skb, max_headroom)) {\n \t\tip_rt_put(rt);\n \t\tDEV_STATS_INC(dev, tx_dropped);\n-\t\tkfree_skb(skb);\n+\t\tkfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);\n \t\treturn;\n \t}\n \n@@ -859,7 +888,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n #endif\n tx_error:\n \tDEV_STATS_INC(dev, tx_errors);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n }\n EXPORT_SYMBOL_GPL(ip_tunnel_xmit);\n \ndiff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c\nindex b5d6ed8f0c3697..eae170ea0ba66d 100644\n--- a/net/ipv6/ip6_gre.c\n+++ b/net/ipv6/ip6_gre.c\n@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n \tstruct tnl_ptk_info tpi;\n \tstruct ip6_tnl *t;\n \n-\tif (gre_parse_header(skb, \u0026tpi, NULL, htons(ETH_P_IPV6),\n-\t\t\t     offset) \u003c 0)\n+\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\n+\t\t\t     offset))\n \t\treturn -EINVAL;\n \n \tipv6h = (const struct ipv6hdr *)skb-\u003edata;\n@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n \treturn 0;\n }\n \n-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)\n+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,\n+\t\t\t\t       const struct tnl_ptk_info *tpi)\n {\n \tconst struct ipv6hdr *ipv6h;\n \tstruct ip6_tnl *tunnel;\n@@ -471,31 +472,33 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)\n \n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\n \t\t} else {\n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n \t\t}\n \n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n \n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n }\n \n-static int ip6erspan_rcv(struct sk_buff *skb,\n-\t\t\t struct tnl_ptk_info *tpi,\n-\t\t\t int gre_hdr_len)\n+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n+\t\t\t\t\t  struct tnl_ptk_info *tpi,\n+\t\t\t\t\t  int gre_hdr_len)\n {\n \tstruct erspan_base_hdr *ershdr;\n \tconst struct ipv6hdr *ipv6h;\n+\tenum skb_drop_reason reason;\n \tstruct erspan_md2 *md2;\n \tstruct ip6_tnl *tunnel;\n \tu8 ver;\n \n-\tif (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))\n-\t\treturn PACKET_REJECT;\n+\treason = pskb_may_pull_reason(skb, sizeof(*ershdr));\n+\tif (unlikely(reason))\n+\t\treturn reason;\n \n \tipv6h = ipv6_hdr(skb);\n \tershdr = (struct erspan_base_hdr *)skb-\u003edata;\n@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \tif (tunnel) {\n \t\tint len = erspan_hdr_len(ver);\n \n-\t\tif (unlikely(!pskb_may_pull(skb, len)))\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = pskb_may_pull_reason(skb, len);\n+\t\tif (unlikely(reason))\n+\t\t\treturn reason;\n \n-\t\tif (__iptunnel_pull_header(skb, len,\n-\t\t\t\t\t   htons(ETH_P_TEB),\n-\t\t\t\t\t   false, false))\n-\t\t\treturn PACKET_REJECT;\n+\t\treason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),\n+\t\t\t\t\t\tfalse, false);\n+\t\tif (reason)\n+\t\t\treturn reason;\n \n \t\tif (tunnel-\u003eparms.collect_md) {\n \t\t\tstruct erspan_metadata *pkt_md, *md;\n@@ -530,7 +534,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,\n \t\t\t\t\t\t  sizeof(*md));\n \t\t\tif (!tun_dst)\n-\t\t\t\treturn PACKET_REJECT;\n+\t\t\t\treturn SKB_DROP_REASON_NOMEM;\n \n \t\t\t/* MUST set options_len before referencing options */\n \t\t\tinfo = \u0026tun_dst-\u003eu.tun_info;\n@@ -558,40 +562,42 @@ static int ip6erspan_rcv(struct sk_buff *skb,\n \t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\n \t\t}\n \n-\t\treturn PACKET_RCVD;\n+\t\treturn SKB_NOT_DROPPED_YET;\n \t}\n \n-\treturn PACKET_REJECT;\n+\treturn SKB_DROP_REASON_TUNNEL_NOT_FOUND;\n }\n \n static int gre_rcv(struct sk_buff *skb)\n {\n+\tenum skb_drop_reason reason;\n \tstruct tnl_ptk_info tpi;\n-\tbool csum_err = false;\n-\tint hdr_len;\n \n-\thdr_len = gre_parse_header(skb, \u0026tpi, \u0026csum_err, htons(ETH_P_IPV6), 0);\n-\tif (hdr_len \u003c 0)\n+\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\n+\tif (reason)\n \t\tgoto drop;\n \n-\tif (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))\n+\treason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);\n+\tif (reason)\n \t\tgoto drop;\n \n \tif (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||\n \t\t     tpi.proto == htons(ETH_P_ERSPAN2))) {\n-\t\tif (ip6erspan_rcv(skb, \u0026tpi, hdr_len) == PACKET_RCVD)\n+\t\treason = ip6erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\n+\t\tif (!reason)\n \t\t\treturn 0;\n \t\tgoto out;\n \t}\n \n-\tif (ip6gre_rcv(skb, \u0026tpi) == PACKET_RCVD)\n+\treason = ip6gre_rcv(skb, \u0026tpi);\n+\tif (!reason)\n \t\treturn 0;\n \n out:\n \ticmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);\n drop:\n \tdev_core_stats_rx_dropped_inc(skb-\u003edev);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \ndiff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c\nindex 64a184bca46772..4912b08228a15a 100644\n--- a/net/ipv6/ip6_tunnel.c\n+++ b/net/ipv6/ip6_tunnel.c\n@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t\t\t\t\t\tstruct sk_buff *skb),\n \t\t\t bool log_ecn_err)\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tconst struct ipv6hdr *ipv6h;\n \tint nh, err;\n \n@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t    test_bit(IP_TUNNEL_CSUM_BIT, tpi-\u003eflags)) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_crc_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n \t\tgoto drop;\n \t}\n \n \tif (test_bit(IP_TUNNEL_SEQ_BIT, tunnel-\u003eparms.i_flags)) {\n-\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags) ||\n-\t\t    (tunnel-\u003ei_seqno \u0026\u0026\n-\t\t     (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0)) {\n+\t\tif (!test_bit(IP_TUNNEL_SEQ_BIT, tpi-\u003eflags)) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;\n+\t\t\tgoto drop;\n+\t\t}\n+\t\tif (tunnel-\u003ei_seqno \u0026\u0026\n+\t\t    (s32)(ntohl(tpi-\u003eseq) - tunnel-\u003ei_seqno) \u003c 0) {\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_fifo_errors);\n+\t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;\n \t\t\tgoto drop;\n \t\t}\n \t\ttunnel-\u003ei_seqno = ntohl(tpi-\u003eseq) + 1;\n@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \n \t/* Warning: All skb pointers will be invalidated! */\n \tif (tunnel-\u003edev-\u003etype == ARPHRD_ETHER) {\n-\t\tif (!pskb_may_pull(skb, ETH_HLEN)) {\n+\t\treason = pskb_may_pull_reason(skb, ETH_HLEN);\n+\t\tif (reason) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\t\tgoto drop;\n@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \n \tskb_reset_network_header(skb);\n \n-\tif (skb_vlan_inet_prepare(skb, true)) {\n+\treason = skb_vlan_inet_prepare(skb, true);\n+\tif (reason) {\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_length_errors);\n \t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n \t\tgoto drop;\n@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n \t\tif (err \u003e 1) {\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_frame_errors);\n \t\t\tDEV_STATS_INC(tunnel-\u003edev, rx_errors);\n+\t\t\treason = SKB_DROP_REASON_IP_TUNNEL_ECN;\n \t\t\tgoto drop;\n \t\t}\n \t}\n@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\n drop:\n \tif (tun_dst)\n \t\tdst_release((struct dst_entry *)tun_dst);\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \n@@ -941,6 +952,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \t\t\t\t\t\t  const struct ipv6hdr *ipv6h,\n \t\t\t\t\t\t  struct sk_buff *skb))\n {\n+\tenum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;\n \tstruct ip6_tnl *t;\n \tconst struct ipv6hdr *ipv6h = ipv6_hdr(skb);\n \tstruct metadata_dst *tun_dst = NULL;\n@@ -952,21 +964,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \tif (t) {\n \t\tu8 tproto = READ_ONCE(t-\u003eparms.proto);\n \n-\t\tif (tproto != ipproto \u0026\u0026 tproto != 0)\n+\t\tif (tproto != ipproto \u0026\u0026 tproto != 0) {\n+\t\t\treason = SKB_DROP_REASON_UNHANDLED_PROTO;\n \t\t\tgoto drop;\n-\t\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))\n+\t\t}\n+\t\tif (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {\n+\t\t\treason = SKB_DROP_REASON_XFRM_POLICY;\n \t\t\tgoto drop;\n+\t\t}\n \t\tipv6h = ipv6_hdr(skb);\n-\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr))\n+\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr)) {\n+\t\t\treason = SKB_DROP_REASON_NOT_SPECIFIED;\n \t\t\tgoto drop;\n-\t\tif (iptunnel_pull_header(skb, 0, tpi-\u003eproto, false))\n+\t\t}\n+\t\treason = iptunnel_pull_header(skb, 0, tpi-\u003eproto, false);\n+\t\tif (reason)\n \t\t\tgoto drop;\n \t\tif (t-\u003eparms.collect_md) {\n \t\t\tIP_TUNNEL_DECLARE_FLAGS(flags) = { };\n \n \t\t\ttun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);\n-\t\t\tif (!tun_dst)\n+\t\t\tif (!tun_dst) {\n+\t\t\t\treason = SKB_DROP_REASON_NOMEM;\n \t\t\t\tgoto drop;\n+\t\t\t}\n \t\t}\n \t\tret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\n \t\t\t\t    log_ecn_error);\n@@ -978,7 +999,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n \n drop:\n \trcu_read_unlock();\n-\tkfree_skb(skb);\n+\tkfree_skb_reason(skb, reason);\n \treturn 0;\n }\n \ndiff --git a/net/ipv6/sit.c b/net/ipv6/sit.c\nindex a7ec800216ade1..9576d146c96143 100644\n--- a/net/ipv6/sit.c\n+++ b/net/ipv6/sit.c\n@@ -1096,7 +1096,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,\n \t\tttl = iph6-\u003ehop_limit;\n \ttos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));\n \n-\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4) \u003c 0) {\n+\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4)) {\n \t\tip_rt_put(rt);\n \t\tgoto tx_error;\n \t}\n"
}

2/1 2026/11/14 05:13 agent patch-evaluator
2m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "NET_IPGRE",
    "NET_IPGRE_DEMUX",
    "NET_IP_TUNNEL",
    "NET_IPGRE_BROADCAST",
    "IPV6_GRE",
    "IPV6_TUNNEL",
    "IPV6_SIT"
  ],
  "FocusSymbols": [
    "gre_parse_header",
    "ip_tunnel_rcv",
    "ip_tunnel_xmit",
    "ip_md_tunnel_xmit",
    "ipgre_rcv",
    "ipgre_xmit",
    "erspan_rcv",
    "erspan_xmit",
    "gre_tap_xmit",
    "ip6gre_rcv",
    "ip6erspan_rcv",
    "ip6_tnl_rcv",
    "ipxip6_rcv",
    "ipip6_tunnel_xmit"
  ],
  "Reasoning": "The patch modifies core networking tunnel code (GRE, ERSPAN, SIT, and generic IP/IPv6 tunnels) to return detailed skb drop reasons rather than generic error codes. It changes the signature and return semantics of gre_parse_header() and ip_tunnel_encap(), and updates packet receive and transmit routines across net/ipv4 and net/ipv6. This reachable code handles untrusted packet input and tunnel configurations, making it relevant for fuzzing to discover regressions or crashes with malformed tunnel headers, sequence numbers, checksums, and encapsulation options.",
  "WorthFuzzing": true
}

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 1539401cda3b1821003d9f832e0ad9248abccfbf
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Nov 14 05:13:51 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index fa2fe89905573a..fb6f3d8da960c7 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -128,6 +128,10 @@
 	FN(PSP_INPUT)			\
 	FN(PSP_OUTPUT)			\
 	FN(RECURSION_LIMIT)		\
+	FN(TUNNEL_OPT_MISMATCH)		\
+	FN(TUNNEL_OLD_SEQ)		\
+	FN(GRE_CSUM)			\
+	FN(TUNNEL_ENCAP)		\
 	FNe(MAX)
 
 /**
@@ -535,11 +539,13 @@ enum skb_drop_reason {
 	 * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:
 	 * 1) VXLAN reserved fields are not zero
 	 * 2) VXLAN "I" flag is not set
+	 * 3) GRE version is not supported or the routing bit is set
 	 */
 	SKB_DROP_REASON_TUNNEL_INVALID_HDR,
 	/**
 	 * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the
-	 * packet, e.g. no VXLAN device for its VNI
+	 * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its
+	 * endpoints and key
 	 */
 	SKB_DROP_REASON_TUNNEL_NOT_FOUND,
 	/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
@@ -612,6 +618,29 @@ enum skb_drop_reason {
 	 * itself.
 	 */
 	SKB_DROP_REASON_RECURSION_LIMIT,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_OPT_MISMATCH: the tunnel options carried by
+	 * the packet do not match the tunnel configuration, e.g. a GRE tunnel
+	 * configured with 'icsum' or 'iseq' received a packet with no checksum
+	 * or no sequence number, or a GRE tunnel without 'icsum' received a
+	 * packet with a checksum.
+	 */
+	SKB_DROP_REASON_TUNNEL_OPT_MISMATCH,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_OLD_SEQ: the sequence number carried by the
+	 * packet is older than the one expected by the tunnel, e.g. the packet
+	 * was reordered in the network or by the receive processing, or the
+	 * remote endpoint restarted and reset its sequence numbering.
+	 */
+	SKB_DROP_REASON_TUNNEL_OLD_SEQ,
+	/** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+	SKB_DROP_REASON_GRE_CSUM,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation
+	 * header of a tunnel, e.g. an unknown or unregistered encapsulation
+	 * type.
+	 */
+	SKB_DROP_REASON_TUNNEL_ENCAP,
 	/**
 	 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
 	 * shouldn't be used as a real 'reason' - only for tracing code gen
diff --git a/include/net/gre.h b/include/net/gre.h
index b55f67ecd2fc4b..b5dbe00ab15ef7 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -32,8 +32,9 @@ struct gre_protocol {
 int gre_add_protocol(const struct gre_protocol *proto, u8 version);
 int gre_del_protocol(const struct gre_protocol *proto, u8 version);
 
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err, __be16 proto, int nhs);
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+		 bool ignore_csum_err, __be16 proto, int nhs);
 
 static inline bool netif_is_gretap(const struct net_device *dev)
 {
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5cccf4c0e6913a..87046ba50d45bb 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -207,10 +207,6 @@ struct tnl_ptk_info {
 	int hdr_len;
 };
 
-#define PACKET_RCVD	0
-#define PACKET_REJECT	1
-#define PACKET_NEXT	2
-
 #define IP_TNL_HASH_BITS   7
 #define IP_TNL_HASH_SIZE   (1 << IP_TNL_HASH_BITS)
 
@@ -545,18 +541,18 @@ static inline int ip_encap_hlen(struct ip_tunnel_encap *e)
 	return hlen;
 }
 
-static inline int ip_tunnel_encap(struct sk_buff *skb,
-				  struct ip_tunnel_encap *e,
-				  u8 *protocol, struct flowi4 *fl4)
+static inline enum skb_drop_reason
+ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel_encap *e,
+		u8 *protocol, struct flowi4 *fl4)
 {
 	const struct ip_tunnel_encap_ops *ops;
 	int ret = -EINVAL;
 
 	if (e->type == TUNNEL_ENCAP_NONE)
-		return 0;
+		return SKB_NOT_DROPPED_YET;
 
 	if (e->type >= MAX_IPTUN_ENCAP_OPS)
-		return -EINVAL;
+		return SKB_DROP_REASON_TUNNEL_ENCAP;
 
 	rcu_read_lock();
 	ops = rcu_dereference(iptun_encaps[e->type]);
@@ -564,7 +560,11 @@ static inline int ip_tunnel_encap(struct sk_buff *skb,
 		ret = ops->build_header(skb, e, protocol, fl4);
 	rcu_read_unlock();
 
-	return ret;
+	if (!ret)
+		return SKB_NOT_DROPPED_YET;
+	if (ret == -ENOMEM)
+		return SKB_DROP_REASON_NOMEM;
+	return SKB_DROP_REASON_TUNNEL_ENCAP;
 }
 
 /* Extract dsfield from inner protocol */
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd0..6c1d1fe914b895 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,47 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
 }
 EXPORT_SYMBOL_GPL(gre_del_protocol);
 
-/* Fills in tpi and returns header length to be pulled.
- * Note that caller must use pskb_may_pull() before pulling GRE header.
+/**
+ * gre_parse_header() - parse the GRE header of a packet
+ * @skb: the packet; the GRE header starts @nhs bytes past skb->data
+ * @tpi: filled in with the fields of the header, and with the length of
+ *	the header to be pulled in tpi->hdr_len
+ * @ignore_csum_err: do not reject the header when its checksum does not
+ *	match. The ICMP error handlers set it, as they only get a part of the
+ *	original packet; the checksum is still computed and the rest of the
+ *	header is parsed.
+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or
+ *	ETH_P_IPV6
+ * @nhs: the offset of the GRE header from skb->data
+ *
+ * The caller must use pskb_may_pull() before pulling the GRE header.
+ *
+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
  */
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err, __be16 proto, int nhs)
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+		 bool ignore_csum_err, __be16 proto, int nhs)
 {
 	const struct gre_base_hdr *greh;
+	enum skb_drop_reason reason;
 	__be32 *options;
 	int hdr_len;
 
-	if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
-		return -EINVAL;
+	reason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));
+	if (unlikely(reason))
+		return reason;
 
 	greh = (struct gre_base_hdr *)(skb->data + nhs);
 	if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
-		return -EINVAL;
+		return SKB_DROP_REASON_TUNNEL_INVALID_HDR;
 
 	gre_flags_to_tnl_flags(tpi->flags, greh->flags);
 	hdr_len = gre_calc_hlen(tpi->flags);
 
-	if (!pskb_may_pull(skb, nhs + hdr_len))
-		return -EINVAL;
+	reason = pskb_may_pull_reason(skb, nhs + hdr_len);
+	if (reason)
+		return reason;
 
 	greh = (struct gre_base_hdr *)(skb->data + nhs);
 	tpi->proto = greh->protocol;
@@ -87,9 +106,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		if (!skb_checksum_simple_validate(skb)) {
 			skb_checksum_try_convert(skb, IPPROTO_GRE,
 						 null_compute_pseudo);
-		} else if (csum_err) {
-			*csum_err = true;
-			return -EINVAL;
+		} else if (!ignore_csum_err) {
+			return SKB_DROP_REASON_GRE_CSUM;
 		}
 
 		options++;
@@ -117,7 +135,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		val = skb_header_pointer(skb, nhs + hdr_len,
 					 sizeof(_val), &_val);
 		if (!val)
-			return -EINVAL;
+			return SKB_DROP_REASON_PKT_TOO_SMALL;
 		tpi->proto = proto;
 		if ((*val & 0xF0) != 0x40)
 			hdr_len += 4;
@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	    greh->protocol == htons(ETH_P_ERSPAN2)) {
 		struct erspan_base_hdr *ershdr;
 
-		if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
-			return -EINVAL;
+		reason = pskb_may_pull_reason(skb,
+					      nhs + hdr_len + sizeof(*ershdr));
+		if (reason)
+			return reason;
 
 		ershdr = (struct erspan_base_hdr *)(skb->data + nhs + hdr_len);
 		tpi->key = cpu_to_be32(get_session_id(ershdr));
 	}
 
-	return hdr_len;
+	return SKB_NOT_DROPPED_YET;
 }
 EXPORT_SYMBOL(gre_parse_header);
 
 static int gre_rcv(struct sk_buff *skb)
 {
 	const struct gre_protocol *proto;
+	enum skb_drop_reason reason;
 	u8 ver;
 	int ret;
 
-	if (!pskb_may_pull(skb, 12))
+	reason = pskb_may_pull_reason(skb, 12);
+	if (reason)
 		goto drop;
 
 	ver = skb->data[1]&0x7f;
-	if (ver >= GREPROTO_MAX)
+	if (ver >= GREPROTO_MAX) {
+		reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
 		goto drop;
+	}
 
 	rcu_read_lock();
 	proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +191,11 @@ static int gre_rcv(struct sk_buff *skb)
 drop_nohandler:
 	rcu_read_unlock();
 	dev_core_stats_rx_nohandler_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
 	return NET_RX_DROP;
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return NET_RX_DROP;
 }
 
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 5485586fa0e625..71e087a7afcf00 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)
 	const int code = icmp_hdr(skb)->code;
 	struct tnl_ptk_info tpi;
 
-	if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IP),
-			     iph->ihl * 4) < 0)
+	if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IP),
+			     iph->ihl * 4))
 		return;
 
 	if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
@@ -264,9 +264,11 @@ static bool is_erspan_type1(int gre_hdr_len)
 	return gre_hdr_len == 4;
 }
 
-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		      int gre_hdr_len)
+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,
+				       struct tnl_ptk_info *tpi,
+				       int gre_hdr_len)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct net *net = dev_net(skb->dev);
 	struct metadata_dst *tun_dst = NULL;
 	struct erspan_base_hdr *ershdr;
@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, flags,
 					  iph->saddr, iph->daddr, 0);
 	} else {
-		if (unlikely(!pskb_may_pull(skb,
-					    gre_hdr_len + sizeof(*ershdr))))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb,
+					      gre_hdr_len + sizeof(*ershdr));
+		if (unlikely(reason))
+			return reason;
 
 		ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
 		ver = ershdr->ver;
@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		else
 			len = gre_hdr_len + erspan_hdr_len(ver);
 
-		if (unlikely(!pskb_may_pull(skb, len)))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb, len);
+		if (unlikely(reason))
+			return reason;
 
-		if (__iptunnel_pull_header(skb,
-					   len,
-					   htons(ETH_P_TEB),
-					   false, false))
+		reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+						false, false);
+		if (reason)
 			goto drop;
 
 		if (tunnel->collect_md) {
@@ -328,7 +331,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 			tun_dst = ip_tun_rx_dst(skb, flags,
 						tun_id, sizeof(*md));
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			/* MUST set options_len before referencing options */
 			info = &tun_dst->u.tun_info;
@@ -354,18 +357,21 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 
 		skb_reset_mac_header(skb);
 		ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 
 drop:
-	kfree_skb(skb);
-	return PACKET_RCVD;
+	kfree_skb_reason(skb, reason);
+	return SKB_NOT_DROPPED_YET;
 }
 
-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
-		       struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,
+					const struct tnl_ptk_info *tpi,
+					struct ip_tunnel_net *itn,
+					int hdr_len, bool raw_proto)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct metadata_dst *tun_dst = NULL;
 	const struct iphdr *iph;
 	struct ip_tunnel *tunnel;
@@ -377,8 +383,9 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
 	if (tunnel) {
 		const struct iphdr *tnl_params;
 
-		if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
-					   raw_proto, false))
+		reason = __iptunnel_pull_header(skb, hdr_len, tpi->proto,
+						raw_proto, false);
+		if (reason)
 			goto drop;
 
 		/* Special case for ipgre_header_parse(), which expects the
@@ -401,75 +408,80 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
 			tun_id = key32_to_tunnel_id(tpi->key);
 			tun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 		}
 
 		ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
-	return PACKET_NEXT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 
 drop:
-	kfree_skb(skb);
-	return PACKET_RCVD;
+	kfree_skb_reason(skb, reason);
+	return SKB_NOT_DROPPED_YET;
 }
 
-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
-		     int hdr_len)
+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,
+				      const struct tnl_ptk_info *tpi,
+				      int hdr_len)
 {
 	struct net *net = dev_net(skb->dev);
+	enum skb_drop_reason reason;
 	struct ip_tunnel_net *itn;
-	int res;
 
 	if (tpi->proto == htons(ETH_P_TEB))
 		itn = net_generic(net, gre_tap_net_id);
 	else
 		itn = net_generic(net, ipgre_net_id);
 
-	res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
-	if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
+	reason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
+	if (reason == SKB_DROP_REASON_TUNNEL_NOT_FOUND &&
+	    tpi->proto == htons(ETH_P_TEB)) {
 		/* ipgre tunnels in collect metadata mode should receive
 		 * also ETH_P_TEB traffic.
 		 */
 		itn = net_generic(net, ipgre_net_id);
-		res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
+		reason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
 	}
-	return res;
+	return reason;
 }
 
 static int gre_rcv(struct sk_buff *skb)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct tnl_ptk_info tpi;
-	bool csum_err = false;
-	int hdr_len;
 
 #ifdef CONFIG_NET_IPGRE_BROADCAST
 	if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
 		/* Looped back packet, drop it! */
-		if (rt_is_output_route(skb_rtable(skb)))
+		if (rt_is_output_route(skb_rtable(skb))) {
+			reason = SKB_DROP_REASON_NOT_SPECIFIED;
 			goto drop;
+		}
 	}
 #endif
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
-	if (hdr_len < 0)
+	reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IP), 0);
+	if (reason)
 		goto drop;
 
 	if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
 		     tpi.proto == htons(ETH_P_ERSPAN2))) {
-		if (erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+		reason = erspan_rcv(skb, &tpi, tpi.hdr_len);
+		if (!reason)
 			return 0;
 		goto out;
 	}
 
-	if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+	reason = ipgre_rcv(skb, &tpi, tpi.hdr_len);
+	if (!reason)
 		return 0;
 
 out:
 	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
@@ -496,6 +508,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)
 static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 			__be16 proto)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 	struct ip_tunnel_info *tun_info;
@@ -504,19 +517,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 
 	key = &tun_info->key;
 	tunnel_hlen = gre_calc_hlen(key->tun_flags);
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	/* Push Tunnel header. */
 	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
-					      tunnel->parms.o_flags)))
+					      tunnel->parms.o_flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	__set_bit(IP_TUNNEL_CSUM_BIT, flags);
 	__set_bit(IP_TUNNEL_KEY_BIT, flags);
@@ -533,12 +552,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 	return;
 
 err_free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 }
 
 static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 	struct ip_tunnel_info *tun_info;
@@ -552,29 +572,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 
 	key = &tun_info->key;
-	if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags))
+	if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
-	if (tun_info->options_len < sizeof(*md))
+	}
+	if (tun_info->options_len < sizeof(*md)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 	md = ip_tunnel_info_opts(tun_info);
 
 	/* ERSPAN has fixed 8 byte GRE header */
 	version = md->version;
 	tunnel_hlen = 8 + erspan_hdr_len(version);
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
-	if (gre_handle_offloads(skb, false))
+	if (gre_handle_offloads(skb, false)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	if (skb->len > dev->mtu + dev->hard_header_len) {
-		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+		if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto err_free_skb;
+		}
 		truncate = true;
 	}
 
@@ -606,6 +638,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 				       truncate, true);
 		proto = htons(ETH_P_ERSPAN2);
 	} else {
+		reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 		goto err_free_skb;
 	}
 
@@ -618,7 +651,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 	return;
 
 err_free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 }
 
@@ -652,8 +685,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
 	const struct iphdr *tnl_params;
+	enum skb_drop_reason reason;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -664,10 +699,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	if (dev->header_ops) {
 		int pull_len = tunnel->hlen + sizeof(struct iphdr);
 
-		if (skb_cow_head(skb, 0))
+		if (skb_cow_head(skb, 0)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 
-		if (!pskb_may_pull(skb, pull_len))
+		reason = pskb_may_pull_reason(skb, pull_len);
+		if (reason)
 			goto free_skb;
 
 		tnl_params = (const struct iphdr *)skb->data;
@@ -677,25 +715,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 		skb_reset_mac_header(skb);
 
 		if (skb->ip_summed == CHECKSUM_PARTIAL &&
-		    skb_checksum_start(skb) < skb->data)
+		    skb_checksum_start(skb) < skb->data) {
+			reason = SKB_DROP_REASON_SKB_CSUM;
 			goto free_skb;
+		}
 	} else {
-		if (skb_cow_head(skb, dev->needed_headroom))
+		if (skb_cow_head(skb, dev->needed_headroom)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 
 		tnl_params = &tunnel->parms.iph;
 	}
 
 	ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
 
-	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	__gre_xmit(skb, dev, tnl_params, skb->protocol, flags);
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
@@ -705,10 +749,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
+	enum skb_drop_reason reason;
 	bool truncate = false;
 	__be16 proto;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -716,15 +762,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 		return NETDEV_TX_OK;
 	}
 
-	if (gre_handle_offloads(skb, false))
+	if (gre_handle_offloads(skb, false)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	if (skb->len > dev->mtu + dev->hard_header_len) {
-		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+		if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 		truncate = true;
 	}
 
@@ -745,6 +797,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 				       truncate, true);
 		proto = htons(ETH_P_ERSPAN2);
 	} else {
+		reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 		goto free_skb;
 	}
 
@@ -753,7 +806,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
@@ -763,8 +816,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
+	enum skb_drop_reason reason;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -774,17 +829,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
 
 	ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
 
-	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_TEB), flags);
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a4a..924d02d0cc7bf3 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 		  const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
 		  bool log_ecn_error)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct iphdr *iph = ip_hdr(skb);
 	int nh, err;
 
@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 	    test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
 		DEV_STATS_INC(tunnel->dev, rx_crc_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
+		reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
 		goto drop;
 	}
 
 	if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
-		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
-		    (tunnel->i_seqno && (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
 			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
+			goto drop;
+		}
+		if (tunnel->i_seqno &&
+		    (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;
 			goto drop;
 		}
 		tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 
 	skb_set_network_header(skb, (tunnel->dev->type == ARPHRD_ETHER) ? ETH_HLEN : 0);
 
-	if (!pskb_inet_may_pull(skb)) {
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason) {
 		DEV_STATS_INC(tunnel->dev, rx_length_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
 		goto drop;
@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 		if (err > 1) {
 			DEV_STATS_INC(tunnel->dev, rx_frame_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
 			goto drop;
 		}
 	}
@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 drop:
 	if (tun_dst)
 		dst_release((struct dst_entry *)tun_dst);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
 void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		       u8 proto, int tunnel_hlen)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	u32 headroom = sizeof(struct iphdr);
 	struct ip_tunnel_info *tun_info;
@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto tx_error;
+	}
 	key = &tun_info->key;
 	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
 	inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
@@ -608,7 +622,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (!tunnel_hlen)
 		tunnel_hlen = ip_encap_hlen(&tun_info->encap);
 
-	if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0)
+	reason = ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4);
+	if (reason)
 		goto tx_error;
 
 	use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -618,6 +633,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		rt = ip_route_output_key(tunnel->net, &fl4);
 		if (IS_ERR(rt)) {
 			DEV_STATS_INC(dev, tx_carrier_errors);
+			reason = SKB_DROP_REASON_IP_OUTNOROUTES;
 			goto tx_error;
 		}
 		if (use_cache)
@@ -627,6 +643,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (rt->dst.dev == dev) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, collisions);
+		reason = SKB_DROP_REASON_RECURSION_LIMIT;
 		goto tx_error;
 	}
 
@@ -635,6 +652,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,
 			    key->u.ipv4.dst, true)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_PKT_TOO_BIG;
 		goto tx_error;
 	}
 
@@ -652,6 +670,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	headroom += LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len;
 	if (skb_cow_head(skb, headroom)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_NOMEM;
 		goto tx_dropped;
 	}
 
@@ -666,13 +685,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 tx_dropped:
 	DEV_STATS_INC(dev, tx_dropped);
 kfree:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 }
 EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);
 
 void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		    const struct iphdr *tnl_params, u8 protocol)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	struct ip_tunnel_info *tun_info = NULL;
 	const struct iphdr *inner_iph;
@@ -700,6 +720,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 		if (!skb_dst(skb)) {
 			DEV_STATS_INC(dev, tx_fifo_errors);
+			reason = SKB_DROP_REASON_NO_TX_TARGET;
 			goto tx_error;
 		}
 
@@ -713,9 +734,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		} else if (payload_protocol == htons(ETH_P_IP)) {
 			rt = skb_rtable(skb);
 			dst = rt_nexthop(rt, inner_iph->daddr);
-		}
 #if IS_ENABLED(CONFIG_IPV6)
-		else if (payload_protocol == htons(ETH_P_IPV6)) {
+		} else if (payload_protocol == htons(ETH_P_IPV6)) {
 			const struct in6_addr *addr6;
 			struct neighbour *neigh;
 			bool do_tx_error_icmp;
@@ -723,8 +743,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 			neigh = dst_neigh_lookup(skb_dst(skb),
 						 &ipv6_hdr(skb)->daddr);
-			if (!neigh)
+			if (!neigh) {
+				reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
 				goto tx_error;
+			}
 
 			addr6 = (const struct in6_addr *)&neigh->primary_key;
 			addr_type = ipv6_addr_type(addr6);
@@ -741,12 +763,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 				dst = addr6->s6_addr32[3];
 			}
 			neigh_release(neigh);
-			if (do_tx_error_icmp)
+			if (do_tx_error_icmp) {
+				reason = SKB_DROP_REASON_NO_TX_TARGET;
 				goto tx_error_icmp;
-		}
+			}
 #endif
-		else
+		} else {
+			reason = SKB_DROP_REASON_NO_TX_TARGET;
 			goto tx_error;
+		}
 
 		if (!md)
 			connected = false;
@@ -769,7 +794,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 			    tunnel->net, READ_ONCE(tunnel->parms.link),
 			    tunnel->fwmark, skb_get_hash(skb), 0);
 
-	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0)
+	reason = ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4);
+	if (reason)
 		goto tx_error;
 
 	if (connected && md) {
@@ -787,6 +813,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 		if (IS_ERR(rt)) {
 			DEV_STATS_INC(dev, tx_carrier_errors);
+			reason = SKB_DROP_REASON_IP_OUTNOROUTES;
 			goto tx_error;
 		}
 		if (use_cache)
@@ -800,6 +827,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (rt->dst.dev == dev) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, collisions);
+		reason = SKB_DROP_REASON_RECURSION_LIMIT;
 		goto tx_error;
 	}
 
@@ -809,6 +837,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_PKT_TOO_BIG;
 		goto tx_error;
 	}
 
@@ -843,7 +872,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (skb_cow_head(skb, max_headroom)) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, tx_dropped);
-		kfree_skb(skb);
+		kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
 		return;
 	}
 
@@ -859,7 +888,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 #endif
 tx_error:
 	DEV_STATS_INC(dev, tx_errors);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_xmit);
 
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b5d6ed8f0c3697..eae170ea0ba66d 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	struct tnl_ptk_info tpi;
 	struct ip6_tnl *t;
 
-	if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6),
-			     offset) < 0)
+	if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IPV6),
+			     offset))
 		return -EINVAL;
 
 	ipv6h = (const struct ipv6hdr *)skb->data;
@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	return 0;
 }
 
-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,
+				       const struct tnl_ptk_info *tpi)
 {
 	const struct ipv6hdr *ipv6h;
 	struct ip6_tnl *tunnel;
@@ -471,31 +472,33 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
 
 			tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			ip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
 		} else {
 			ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
 		}
 
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
 
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 }
 
-static int ip6erspan_rcv(struct sk_buff *skb,
-			 struct tnl_ptk_info *tpi,
-			 int gre_hdr_len)
+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,
+					  struct tnl_ptk_info *tpi,
+					  int gre_hdr_len)
 {
 	struct erspan_base_hdr *ershdr;
 	const struct ipv6hdr *ipv6h;
+	enum skb_drop_reason reason;
 	struct erspan_md2 *md2;
 	struct ip6_tnl *tunnel;
 	u8 ver;
 
-	if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
-		return PACKET_REJECT;
+	reason = pskb_may_pull_reason(skb, sizeof(*ershdr));
+	if (unlikely(reason))
+		return reason;
 
 	ipv6h = ipv6_hdr(skb);
 	ershdr = (struct erspan_base_hdr *)skb->data;
@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 	if (tunnel) {
 		int len = erspan_hdr_len(ver);
 
-		if (unlikely(!pskb_may_pull(skb, len)))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb, len);
+		if (unlikely(reason))
+			return reason;
 
-		if (__iptunnel_pull_header(skb, len,
-					   htons(ETH_P_TEB),
-					   false, false))
-			return PACKET_REJECT;
+		reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+						false, false);
+		if (reason)
+			return reason;
 
 		if (tunnel->parms.collect_md) {
 			struct erspan_metadata *pkt_md, *md;
@@ -530,7 +534,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 			tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,
 						  sizeof(*md));
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			/* MUST set options_len before referencing options */
 			info = &tun_dst->u.tun_info;
@@ -558,40 +562,42 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 			ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
 		}
 
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
 
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 }
 
 static int gre_rcv(struct sk_buff *skb)
 {
+	enum skb_drop_reason reason;
 	struct tnl_ptk_info tpi;
-	bool csum_err = false;
-	int hdr_len;
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6), 0);
-	if (hdr_len < 0)
+	reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IPV6), 0);
+	if (reason)
 		goto drop;
 
-	if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
+	reason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);
+	if (reason)
 		goto drop;
 
 	if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
 		     tpi.proto == htons(ETH_P_ERSPAN2))) {
-		if (ip6erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+		reason = ip6erspan_rcv(skb, &tpi, tpi.hdr_len);
+		if (!reason)
 			return 0;
 		goto out;
 	}
 
-	if (ip6gre_rcv(skb, &tpi) == PACKET_RCVD)
+	reason = ip6gre_rcv(skb, &tpi);
+	if (!reason)
 		return 0;
 
 out:
 	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 64a184bca46772..4912b08228a15a 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 						struct sk_buff *skb),
 			 bool log_ecn_err)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct ipv6hdr *ipv6h;
 	int nh, err;
 
@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 	    test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
 		DEV_STATS_INC(tunnel->dev, rx_crc_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
+		reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
 		goto drop;
 	}
 
 	if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
-		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
-		    (tunnel->i_seqno &&
-		     (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
 			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
+			goto drop;
+		}
+		if (tunnel->i_seqno &&
+		    (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;
 			goto drop;
 		}
 		tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 
 	/* Warning: All skb pointers will be invalidated! */
 	if (tunnel->dev->type == ARPHRD_ETHER) {
-		if (!pskb_may_pull(skb, ETH_HLEN)) {
+		reason = pskb_may_pull_reason(skb, ETH_HLEN);
+		if (reason) {
 			DEV_STATS_INC(tunnel->dev, rx_length_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
 			goto drop;
@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 
 	skb_reset_network_header(skb);
 
-	if (skb_vlan_inet_prepare(skb, true)) {
+	reason = skb_vlan_inet_prepare(skb, true);
+	if (reason) {
 		DEV_STATS_INC(tunnel->dev, rx_length_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
 		goto drop;
@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 		if (err > 1) {
 			DEV_STATS_INC(tunnel->dev, rx_frame_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
 			goto drop;
 		}
 	}
@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 drop:
 	if (tun_dst)
 		dst_release((struct dst_entry *)tun_dst);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
@@ -941,6 +952,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 						  const struct ipv6hdr *ipv6h,
 						  struct sk_buff *skb))
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip6_tnl *t;
 	const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
 	struct metadata_dst *tun_dst = NULL;
@@ -952,21 +964,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 	if (t) {
 		u8 tproto = READ_ONCE(t->parms.proto);
 
-		if (tproto != ipproto && tproto != 0)
+		if (tproto != ipproto && tproto != 0) {
+			reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 			goto drop;
-		if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+		}
+		if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+			reason = SKB_DROP_REASON_XFRM_POLICY;
 			goto drop;
+		}
 		ipv6h = ipv6_hdr(skb);
-		if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr))
+		if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr)) {
+			reason = SKB_DROP_REASON_NOT_SPECIFIED;
 			goto drop;
-		if (iptunnel_pull_header(skb, 0, tpi->proto, false))
+		}
+		reason = iptunnel_pull_header(skb, 0, tpi->proto, false);
+		if (reason)
 			goto drop;
 		if (t->parms.collect_md) {
 			IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 
 			tun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);
-			if (!tun_dst)
+			if (!tun_dst) {
+				reason = SKB_DROP_REASON_NOMEM;
 				goto drop;
+			}
 		}
 		ret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
 				    log_ecn_error);
@@ -978,7 +999,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 
 drop:
 	rcu_read_unlock();
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index a7ec800216ade1..9576d146c96143 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1096,7 +1096,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
 		ttl = iph6->hop_limit;
 	tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
 
-	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
+	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4)) {
 		ip_rt_put(rt);
 		goto tx_error;
 	}

3/2 2026/11/14 05:13 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 21184
							output: 35
							thoughts: 1175
						

Thoughts:
**Analyzing the Patch for Fuzzing Potential**

Okay, let's break this down. The first thing I see is the addition of new `skb_drop_reason` codes, which is interesting in itself: `SKB_DROP_REASON_TUNNEL_OPT_MISMATCH`, `SKB_DROP_REASON_TUNNEL_OLD_SEQ`, `SKB_DROP_REASON_GRE_CSUM`, `SKB_DROP_REASON_TUNNEL_ENCAP`. This immediately suggests a focus on tunnel-related code. So, the question is, is this a good candidate for syzkaller? Absolutely! Any change that introduces new error paths, especially within the networking stack, is a prime target.

Next, I need to understand the code changes. It looks like the patch is replacing the use of generic `kfree_skb()` calls or integer return codes with explicit `enum skb_drop_reason` values. A quick scan shows changes across several files, including `dropreason-core.h`, `gre.h`, `ip_tunnels.h`, `gre_demux.c`, `ip_gre.c`, `ip_tunnel.c`, `ip6_gre.c`, `ip6_tunnel.c`, and `sit.c`. That's a pretty broad scope, which is typical for anything touching the core data structures used by networking protocols.

I see a critical change in return value semantics for functions like `gre_parse_header` and `ip_tunnel_encap`. This is where it gets exciting. Previously, these functions returned an integer that might indicate the header length or an error code. Now, they return an `enum skb_drop_reason`. But wait, how is the header length used? It seems like now, the header length is set within `gre_parse_header` and stored in `tpi->hdr_len`. That's the key. This could easily lead to incorrect values being used elsewhere. I need to investigate how `hdr_len` is being used now, how error conditions are handled, and most importantly, whether this introduces any new exploitable conditions.

To be sure, I need to check where `gre_parse_header` actually sets `tpi->hdr_len`. I'll use `grepper` or `read-file` to check `net/ipv4/gre_demux.c`. This could be a critical point for fuzzing.



4/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "hdr_len",
  "PathPrefixes": [
    "net/ipv4/gre_demux.c"
  ]
}

Results:
{
  "Output": "net/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-62- * @tpi: filled in with the fields of the header, and with the length of\nnet/ipv4/gre_demux.c:63: *\tthe header to be pulled in tpi-\u003ehdr_len\nnet/ipv4/gre_demux.c-64- * @ignore_csum_err: do not reject the header when its checksum does not\n--\nnet/ipv4/gre_demux.c=78=gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n--\nnet/ipv4/gre_demux.c-83-\t__be32 *options;\nnet/ipv4/gre_demux.c:84:\tint hdr_len;\nnet/ipv4/gre_demux.c-85-\n--\nnet/ipv4/gre_demux.c-94-\tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\nnet/ipv4/gre_demux.c:95:\thdr_len = gre_calc_hlen(tpi-\u003eflags);\nnet/ipv4/gre_demux.c-96-\nnet/ipv4/gre_demux.c:97:\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\nnet/ipv4/gre_demux.c-98-\tif (reason)\n--\nnet/ipv4/gre_demux.c-134-\nnet/ipv4/gre_demux.c:135:\t\tval = skb_header_pointer(skb, nhs + hdr_len,\nnet/ipv4/gre_demux.c-136-\t\t\t\t\t sizeof(_val), \u0026_val);\n--\nnet/ipv4/gre_demux.c-140-\t\tif ((*val \u0026 0xF0) != 0x40)\nnet/ipv4/gre_demux.c:141:\t\t\thdr_len += 4;\nnet/ipv4/gre_demux.c-142-\t}\nnet/ipv4/gre_demux.c:143:\ttpi-\u003ehdr_len = hdr_len;\nnet/ipv4/gre_demux.c-144-\n--\nnet/ipv4/gre_demux.c-148-\t */\nnet/ipv4/gre_demux.c:149:\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\nnet/ipv4/gre_demux.c-150-\t    greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n--\nnet/ipv4/gre_demux.c-153-\t\treason = pskb_may_pull_reason(skb,\nnet/ipv4/gre_demux.c:154:\t\t\t\t\t      nhs + hdr_len + sizeof(*ershdr));\nnet/ipv4/gre_demux.c-155-\t\tif (reason)\n--\nnet/ipv4/gre_demux.c-157-\nnet/ipv4/gre_demux.c:158:\t\tershdr = (struct erspan_base_hdr *)(skb-\u003edata + nhs + hdr_len);\nnet/ipv4/gre_demux.c-159-\t\ttpi-\u003ekey = cpu_to_be32(get_session_id(ershdr));\n"
}

5/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23813
							output: 19
							thoughts: 44
						

Thoughts:
Here's my thought process, as requested:

**Digging Deeper into GRE Header Handling**

Okay, so I just set `tpi->hdr_len = hdr_len;` in this specific function. But immediately, my expert intuition is pinging me. This assignment feels… fundamental. It’s the kind of thing that could have implications beyond this single call. Before I move on, I need to understand the *scope* of this `gre_parse_header` function and how `hdr_len` is used. This feels too important to assume.

I need to quickly ascertain how widely this function is used. A quick scan of the kernel source would be useful. Where else is `gre_parse_header` being called? Are there other instances where this `hdr_len` is being set and used? Are these other callers using it the same way? Might there be some subtle differences that I need to be aware of? This needs a broader look to ensure there aren't any side effects or assumptions elsewhere that could bite us down the line. I need to be methodical in understanding this, I don't want to make assumptions.



6/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "gre_parse_header"
}

Results:
{
  "Output": "include/net/gre.h=35=enum skb_drop_reason\ninclude/net/gre.h:36:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\ninclude/net/gre.h-37-\t\t bool ignore_csum_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-59-/**\nnet/ipv4/gre_demux.c:60: * gre_parse_header() - parse the GRE header of a packet\nnet/ipv4/gre_demux.c-61- * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n--\nnet/ipv4/gre_demux.c=77=enum skb_drop_reason\nnet/ipv4/gre_demux.c:78:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-79-\t\t bool ignore_csum_err, __be16 proto, int nhs)\n--\nnet/ipv4/gre_demux.c-163-}\nnet/ipv4/gre_demux.c:164:EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-165-\n--\nnet/ipv4/ip_gre.c=219=static void gre_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv4/ip_gre.c-239-\nnet/ipv4/ip_gre.c:240:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\nnet/ipv4/ip_gre.c-241-\t\t\t     iph-\u003eihl * 4))\n--\nnet/ipv4/ip_gre.c=449=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-463-\nnet/ipv4/ip_gre.c:464:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-465-\tif (reason)\n--\nnet/ipv6/ip6_gre.c=384=static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n--\nnet/ipv6/ip6_gre.c-391-\nnet/ipv6/ip6_gre.c:392:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\nnet/ipv6/ip6_gre.c-393-\t\t\t     offset))\n--\nnet/ipv6/ip6_gre.c=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-575-\nnet/ipv6/ip6_gre.c:576:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-577-\tif (reason)\n"
}

7/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 24991
							output: 39
							thoughts: 507
						

Thoughts:
**Reachability Analysis and Fuzzing Prioritization**

Okay, let's break this down. First, reachability: Yes, without a doubt, this is reachable code. GRE tunnels, IP-GRE, IPv6-GRE, ERSPAN, SIT tunnels – the whole family of IP tunnels – are foundational to Linux networking. These are standard virtual network devices and protocols, built with `rtnl`/`ip link` (or netlink), with packets flowing through `tun/tap`, raw sockets, packet sockets, loopback, the works. I know Syzkaller is actively creating GRE tunnels and hammering them with packets. The modified code is smack-dab in the core networking: `net/ipv4/`, `net/ipv6/`, `include/net/`.

We're looking at changes that impact control flow, error reporting, return types, parsing, drop reasons, and the way `skb` is freed (`kfree_skb_reason` vs. `kfree_skb`). That's significant.

Thinking back to the core triage methodology, that "WorthFuzzing=true" flag? It's triggered when the patch hits reachable executable code, especially those core subsystems. We're talking memory management, synchronization, BPF, scheduler, core networking, VFS, syscalls, refactoring of data structures, any reachable drivers or protocols. This hits the sweet spot. Given the location of the modifications and the types of changes described, `WorthFuzzing` is definitively `true`.

Now, we need to get into the details:

1.  What configurations are going to be required to reach this code?
2.  What focus symbols should we select to make sure that we're targeting these specific code changes?

I have to carefully analyze the files that were modified:
*   `include/net/dropreason-core.h` (core networking, always compiled),
*   `include/net/gre.h`,
*   `include/net/ip_tunnels.h`,
*   `net/ipv4/gre_demux.c`,
*   `net/ipv4/ip_gre.c`,
*   `net/ipv4/ip_tunnel.c`,
*   `net/ipv6/ip6_gre.c`,
*   `net/ipv6/ip6_tunnel.c`, and
*   `net/ipv6/sit.c`.

I'll need to dig into the `Makefile` and `Kconfig` files within `net/ipv4/` and `net/ipv6/` to nail down the configuration dependencies. That's the next step.



8/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "gre_demux|ip_gre|ip_tunnel",
  "PathPrefixes": [
    "net/ipv4/Makefile"
  ]
}

Results:
{
  "Output": "net/ipv4/Makefile=6=obj-y     := route.o inetpeer.o protocol.o \\\n--\nnet/ipv4/Makefile-15-\t     fib_frontend.o fib_semantics.o fib_trie.o fib_notifier.o \\\nnet/ipv4/Makefile:16:\t     inet_fragment.o ping.o ip_tunnel_core.o gre_offload.o \\\nnet/ipv4/Makefile-17-\t     metrics.o netlink.o nexthop.o udp_tunnel_stub.o\nnet/ipv4/Makefile-18-\nnet/ipv4/Makefile:19:obj-$(CONFIG_NET_IP_TUNNEL) += ip_tunnel.o\nnet/ipv4/Makefile-20-obj-$(CONFIG_SYSCTL) += sysctl_net_ipv4.o\n--\nnet/ipv4/Makefile=25=obj-$(CONFIG_NET_IPIP) += ipip.o\nnet/ipv4/Makefile:26:gre-y := gre_demux.o\nnet/ipv4/Makefile-27-fou-y := fou_core.o fou_nl.o fou_bpf.o\n--\nnet/ipv4/Makefile=29=obj-$(CONFIG_NET_IPGRE_DEMUX) += gre.o\nnet/ipv4/Makefile:30:obj-$(CONFIG_NET_IPGRE) += ip_gre.o\nnet/ipv4/Makefile-31-udp_tunnel-y := udp_tunnel_core.o udp_tunnel_nic.o\n"
}

9/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26487
							output: 38
							thoughts: 12
						

Thoughts:
Here's my take on those thoughts, tailored for an expert audience:

**Diving into the IPv6 Makefile**

Okay, so the initial thought is, "Let's crack open `net/ipv6/Makefile`." That's a natural starting point when I'm troubleshooting, debugging, or extending anything IPv6-related in the kernel. The Makefile is the central configuration point for the module compilation and linking. It's the key to understanding how these components are put together. I'm probably looking for something specific, a dependency, a build flag, or possibly even just trying to get a lay of the land, understand the build process flow for a particular IPv6 subsystem. This might be triggered by a specific bug report, a performance issue, or even just curiosity about how a new feature is integrated. Regardless, that's where the journey starts.



10/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "ip6_gre|ip6_tunnel|sit",
  "PathPrefixes": [
    "net/ipv6/Makefile"
  ]
}

Results:
{
  "Output": "net/ipv6/Makefile=40=obj-$(CONFIG_IPV6_VTI) += ip6_vti.o\nnet/ipv6/Makefile:41:obj-$(CONFIG_IPV6_SIT) += sit.o\nnet/ipv6/Makefile:42:obj-$(CONFIG_IPV6_TUNNEL) += ip6_tunnel.o\nnet/ipv6/Makefile:43:obj-$(CONFIG_IPV6_GRE) += ip6_gre.o\nnet/ipv6/Makefile-44-obj-$(CONFIG_IPV6_FOU) += fou6.o\n"
}

11/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26870
							output: 41
							thoughts: 92
						

Thoughts:
Here's my thought process, as if I were reviewing those Kconfig options:

**Kconfig Configuration Review: Tunneling and GRE Options**

Okay, time to get my hands dirty with these Kconfig options. I need to make sure I understand the dependencies and relationships between `NET_IP_TUNNEL`, `NET_IPGRE_DEMUX`, `NET_IPGRE`, `IPV6_SIT`, `IPV6_TUNNEL`, and `IPV6_GRE`. It's pretty clear what the *types* are, and from previous experience I know what they are *for*; but I need to quickly and definitively check the specific configurations.

Let's start by digging into the relevant `Kconfig` files. I'll need to check both `net/ipv4/Kconfig` and `net/ipv6/Kconfig` to see how these options are defined, their default settings, any dependencies they might have, and if there are any conditional inclusions or exclusions that need further attention. A quick `grep` for each of those symbols within those two files should be sufficient to get a comprehensive picture. That should tell me everything I need to know about the current configuration and how they are handled.



12/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "config NET_IP_TUNNEL|config NET_IPGRE",
  "PathPrefixes": [
    "net/ipv4/Kconfig"
  ]
}

Results:
{
  "Output": "net/ipv4/Kconfig=162=config NET_IPIP\n--\nnet/ipv4/Kconfig-179-\nnet/ipv4/Kconfig:180:config NET_IPGRE_DEMUX\nnet/ipv4/Kconfig-181-\ttristate \"IP: GRE demultiplexer\"\n--\nnet/ipv4/Kconfig-185-\nnet/ipv4/Kconfig:186:config NET_IP_TUNNEL\nnet/ipv4/Kconfig-187-\ttristate\n--\nnet/ipv4/Kconfig-191-\nnet/ipv4/Kconfig:192:config NET_IPGRE\nnet/ipv4/Kconfig-193-\ttristate \"IP: GRE tunnels over IP\"\n--\nnet/ipv4/Kconfig-206-\nnet/ipv4/Kconfig:207:config NET_IPGRE_BROADCAST\nnet/ipv4/Kconfig-208-\tbool \"IP: broadcast GRE over IP\"\n"
}

13/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27519
							output: 35
							thoughts: 24
						

Thoughts:
Okay, let's dive into this. Here's my take on those lines in `net/ipv4/Kconfig`:

**Analyzing IPv4 Configuration Options**

Alright, I'm going to focus on lines 180-215 within `net/ipv4/Kconfig`. This area likely deals with a cluster of IPv4-related configuration options. Given my expertise, I'm expecting to find details around features or modules that are conditionally compiled or enabled. I’ll look for `config` directives, of course, and I'll pay close attention to the `depends on` clauses. These are crucial, because they reveal the dependencies – the underlying requirements – for enabling various aspects of IPv4 functionality.

I'll be specifically watching for how they relate to the underlying hardware platforms, other networking subsystems (like routing, firewall, or connection tracking), and perhaps even kernel features like threading or memory management. I'll anticipate seeing options related to routing protocols (RIP, OSPF, etc.), IPv4-specific features like fragmentation and reassembly, and maybe even some more obscure or specialized features. My immediate goal is to understand the logical structure of this section: how the configuration options are grouped, how they relate to one another, and what prerequisites must be met to enable specific functionalities. I'm looking for the overall architecture and how different parts are assembled.



14/2 2026/11/14 05:14 tool read-file
0m Args:
{
  "File": "net/ipv4/Kconfig",
  "FirstLine": 178,
  "LineCount": 40
}

Results:
{
  "Contents": " 178:\t\t  want). Most people won't need this and can say N.\n 179:\t\n 180:\tconfig NET_IPGRE_DEMUX\n 181:\t\ttristate \"IP: GRE demultiplexer\"\n 182:\t\thelp\n 183:\t\t  This is helper module to demultiplex GRE packets on GRE version field criteria.\n 184:\t\t  Required by ip_gre and pptp modules.\n 185:\t\n 186:\tconfig NET_IP_TUNNEL\n 187:\t\ttristate\n 188:\t\tselect DST_CACHE\n 189:\t\tselect GRO_CELLS\n 190:\t\tdefault n\n 191:\t\n 192:\tconfig NET_IPGRE\n 193:\t\ttristate \"IP: GRE tunnels over IP\"\n 194:\t\tdepends on NET_IPGRE_DEMUX\n 195:\t\tselect NET_IP_TUNNEL\n 196:\t\thelp\n 197:\t\t  Tunneling means encapsulating data of one protocol type within\n 198:\t\t  another protocol and sending it over a channel that understands the\n 199:\t\t  encapsulating protocol. This particular tunneling driver implements\n 200:\t\t  GRE (Generic Routing Encapsulation) and at this time allows\n 201:\t\t  encapsulating of IPv4 or IPv6 over existing IPv4 infrastructure.\n 202:\t\t  This driver is useful if the other endpoint is a Cisco router: Cisco\n 203:\t\t  likes GRE much better than the other Linux tunneling driver (\"IP\n 204:\t\t  tunneling\" above). In addition, GRE allows multicast redistribution\n 205:\t\t  through the tunnel.\n 206:\t\n 207:\tconfig NET_IPGRE_BROADCAST\n 208:\t\tbool \"IP: broadcast GRE over IP\"\n 209:\t\tdepends on IP_MULTICAST \u0026\u0026 NET_IPGRE\n 210:\t\thelp\n 211:\t\t  One application of GRE/IP is to construct a broadcast WAN (Wide Area\n 212:\t\t  Network), which looks like a normal Ethernet LAN (Local Area\n 213:\t\t  Network), but can be distributed all over the Internet. If you want\n 214:\t\t  to do that, say Y here and to \"IP multicast routing\" below.\n 215:\t\n 216:\tconfig IP_MROUTE_COMMON\n 217:\t\tbool\n"
}

15/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 28487
							output: 50
							thoughts: 64
						

Thoughts:
Okay, here's my interpretation of this logic, playing the role of the expert:

**Navigating the GRE Tunnel Dependencies**

Alright, let's break this down. My initial observation is that `NET_IPGRE` is intrinsically linked to `NET_IPGRE_DEMUX`. That's not surprising; I'd expect that kind of relationship. A GRE tunnel, at its core, is going to need some kind of demultiplexing mechanism, so it makes perfect sense for `NET_IPGRE` to depend on that, just in terms of how the kernel config is laid out. I also see that `NET_IPGRE` implies selection of `NET_IP_TUNNEL`. That's expected, considering that GRE is a tunneling protocol itself.

Now, my next step is to drill into the IPv6 side of things. I'm going to shift my focus over to `net/ipv6/Kconfig` to confirm which options are in play. I'll need to check the configuration options for IPv6 GRE (`IPV6_GRE`), IPv6 tunnel support in general (`IPV6_TUNNEL`), and IPv6 SIT tunneling (`IPV6_SIT`). I suspect there'll be parallel dependencies and configurations, probably mirroring what we just saw for IPv4, but let's confirm the details. It's important to understand the full picture, including IPv6, to grasp the entirety of GRE functionality within the kernel.



16/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "config IPV6_GRE|config IPV6_TUNNEL|config IPV6_SIT",
  "PathPrefixes": [
    "net/ipv6/Kconfig"
  ]
}

Results:
{
  "Output": "net/ipv6/Kconfig=150=config IPV6_VTI\n--\nnet/ipv6/Kconfig-161-\nnet/ipv6/Kconfig:162:config IPV6_SIT\nnet/ipv6/Kconfig-163-\ttristate \"IPv6: IPv6-in-IPv4 tunnel (SIT driver)\"\n--\nnet/ipv6/Kconfig-176-\nnet/ipv6/Kconfig:177:config IPV6_SIT_6RD\nnet/ipv6/Kconfig-178-\tbool \"IPv6: IPv6 Rapid Deployment (6RD)\"\n--\nnet/ipv6/Kconfig=196=config IPV6_NDISC_NODETYPE\n--\nnet/ipv6/Kconfig-198-\nnet/ipv6/Kconfig:199:config IPV6_TUNNEL\nnet/ipv6/Kconfig-200-\ttristate \"IPv6: IP-in-IPv6 tunnel (RFC2473)\"\n--\nnet/ipv6/Kconfig-209-\nnet/ipv6/Kconfig:210:config IPV6_GRE\nnet/ipv6/Kconfig-211-\ttristate \"IPv6: GRE tunnel\"\n"
}

17/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 29226
							output: 35
							thoughts: 29
						

Thoughts:
Here's my analysis of the provided text, from the perspective of an expert:

**Diving into the IPv6 Configuration**

Okay, so I need to get a handle on the IPv6 configuration options. The goal is to understand how these features interact and what their dependencies are. My immediate thought is to zero in on the `net/ipv6/Kconfig` file, specifically lines 160 through 220. That's usually where the meat of the configuration for a module like this resides. I'm going to scan that section carefully for the dependencies and select statements. Understanding these dependencies is crucial; they reveal which features enable others, and which might be automatically included or excluded based on my existing kernel configuration. I'm looking for the relationships, the "if A then B", "if C selects D", kind of logic that dictates how IPv6 features are built and enabled. This detailed examination of the Kconfig entries will give me a solid base to understand the configuration.



18/2 2026/11/14 05:14 tool read-file
0m Args:
{
  "File": "net/ipv6/Kconfig",
  "FirstLine": 160,
  "LineCount": 60
}

Results:
{
  "Contents": " 160:\t\ton top.\n 161:\t\n 162:\tconfig IPV6_SIT\n 163:\t\ttristate \"IPv6: IPv6-in-IPv4 tunnel (SIT driver)\"\n 164:\t\tselect INET_TUNNEL\n 165:\t\tselect NET_IP_TUNNEL\n 166:\t\tselect IPV6_NDISC_NODETYPE\n 167:\t\tdefault m\n 168:\t\thelp\n 169:\t\t  Tunneling means encapsulating data of one protocol type within\n 170:\t\t  another protocol and sending it over a channel that understands the\n 171:\t\t  encapsulating protocol. This driver implements encapsulation of IPv6\n 172:\t\t  into IPv4 packets. This is useful if you want to connect two IPv6\n 173:\t\t  networks over an IPv4-only path.\n 174:\t\n 175:\t\t  Saying M here will produce a module called sit. If unsure, say M.\n 176:\t\n 177:\tconfig IPV6_SIT_6RD\n 178:\t\tbool \"IPv6: IPv6 Rapid Deployment (6RD)\"\n 179:\t\tdepends on IPV6_SIT\n 180:\t\tdefault n\n 181:\t\thelp\n 182:\t\t  IPv6 Rapid Deployment (6rd; draft-ietf-softwire-ipv6-6rd) builds upon\n 183:\t\t  mechanisms of 6to4 (RFC3056) to enable a service provider to rapidly\n 184:\t\t  deploy IPv6 unicast service to IPv4 sites to which it provides\n 185:\t\t  customer premise equipment.  Like 6to4, it utilizes stateless IPv6 in\n 186:\t\t  IPv4 encapsulation in order to transit IPv4-only network\n 187:\t\t  infrastructure.  Unlike 6to4, a 6rd service provider uses an IPv6\n 188:\t\t  prefix of its own in place of the fixed 6to4 prefix.\n 189:\t\n 190:\t\t  With this option enabled, the SIT driver offers 6rd functionality by\n 191:\t\t  providing additional ioctl API to configure the IPv6 Prefix for in\n 192:\t\t  stead of static 2002::/16 for 6to4.\n 193:\t\n 194:\t\t  If unsure, say N.\n 195:\t\n 196:\tconfig IPV6_NDISC_NODETYPE\n 197:\t\tbool\n 198:\t\n 199:\tconfig IPV6_TUNNEL\n 200:\t\ttristate \"IPv6: IP-in-IPv6 tunnel (RFC2473)\"\n 201:\t\tselect INET6_TUNNEL\n 202:\t\tselect DST_CACHE\n 203:\t\tselect GRO_CELLS\n 204:\t\thelp\n 205:\t\t  Support for IPv6-in-IPv6 and IPv4-in-IPv6 tunnels described in\n 206:\t\t  RFC 2473.\n 207:\t\n 208:\t\t  If unsure, say N.\n 209:\t\n 210:\tconfig IPV6_GRE\n 211:\t\ttristate \"IPv6: GRE tunnel\"\n 212:\t\tselect IPV6_TUNNEL\n 213:\t\tselect NET_IP_TUNNEL\n 214:\t\tdepends on NET_IPGRE_DEMUX\n 215:\t\thelp\n 216:\t\t  Tunneling means encapsulating data of one protocol type within\n 217:\t\t  another protocol and sending it over a channel that understands the\n 218:\t\t  encapsulating protocol. This particular tunneling driver implements\n 219:\t\t  GRE (Generic Routing Encapsulation) and at this time allows\n"
}

19/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30469
							output: 52
							thoughts: 1318
						

Thoughts:
**Analyzing the GRE/Tunneling Configuration and Symbol Exposure**

Okay, let's break this down. First, I need to understand which kernel configurations are relevant to this patch. From what I see, `NET_IPGRE`, `NET_IPGRE_DEMUX`, `NET_IP_TUNNEL`, `IPV6_GRE`, `IPV6_TUNNEL`, and `IPV6_SIT` are the key players. I can already see the dependencies: `NET_IPGRE` pulls in `NET_IP_TUNNEL` and depends on `NET_IPGRE_DEMUX`, `IPV6_GRE` also selects `IPV6_TUNNEL` and `NET_IP_TUNNEL` while depending on `NET_IPGRE_DEMUX`, and `IPV6_SIT` selects `NET_IP_TUNNEL`.  So, if I have `NET_IPGRE`, `NET_IPGRE_DEMUX`, `IPV6_GRE`, `IPV6_SIT`, and `IPV6_TUNNEL` enabled, I should cover all the necessary parts for this patch to work. I'll need to double-check that there aren't any other configs sneakily involved, but this seems like a solid base.

Now, let's examine the code modifications. I see `CONFIG_NET_IPGRE_BROADCAST` in `net/ipv4/ip_gre.c`.  It was already there, guarded by an `#ifdef` in `gre_rcv`, and was only touched slightly.  I can either list `NET_IPGRE_BROADCAST` explicitly or I can just use `NET_IPGRE`, which seems like the more general approach.

Next, I need to identify the crucial functions affected to narrow down the focus. I'm looking for non-ubiquitous, specific functions that are modified. So, let's list them:

1.  `gre_parse_header` (in `net/ipv4/gre_demux.c`) - exported, non-static.
2.  `gre_rcv` (static)
3.  `gre_err` (static)
4.  `erspan_rcv` (static)
5.  `__ipgre_rcv` (static)
6.  `ipgre_rcv` (static)
7.  `gre_rcv` (static)
8.  `gre_fb_xmit` (static)
9.  `erspan_fb_xmit` (static)
10. `ipgre_xmit` (static, `netdev_ops` `ndo_start_xmit`)
11. `erspan_xmit` (static, `netdev_ops` `ndo_start_xmit`)
12. `gre_tap_xmit` (static, `netdev_ops` `ndo_start_xmit`)
13. `ip_tunnel_rcv` (EXPORT_SYMBOL_GPL)
14. `ip_md_tunnel_xmit` (EXPORT_SYMBOL_GPL)
15. `ip_tunnel_xmit` (EXPORT_SYMBOL_GPL)
16. `ip6gre_err` (static)
17. `ip6gre_rcv` (static)
18. `ip6erspan_rcv` (static)
19. `gre_rcv` (static)
20. `__ip6_tnl_rcv` (static)
21. `ipxip6_rcv` (static)
22. `ipip6_tunnel_xmit` (static)

Now, I have to figure out which of these functions are actually *visible* symbols, either through export, or by virtue of not being inlinable. I need to know if static functions are inlined or if they are exported/symbolic.

In standard amd64 kernels:

*   `gre_parse_header`, `ip_tunnel_rcv`, `ip_tunnel_xmit`, and `ip_md_tunnel_xmit` are all explicitly exported.
*   `ipgre_xmit`, `erspan_xmit`, and `gre_tap_xmit` are declared as `ndo_start_xmit` handlers, so they are function pointers stored in `net_device_ops`. The compiler *cannot* inline these; they will be distinct, non-inlined symbols in `vmlinux`.
*   `ipgre_rcv` *might* be reachable via `gre_rcv` so it is not inlined
*   `ipip6_tunnel_xmit


20/2 2026/11/14 05:14 tool grepper
0m Args:
{
  "Expression": "ip6gre_rcv|ip6erspan_rcv|ip6gre_err",
  "PathPrefixes": [
    "net/ipv6/ip6_gre.c"
  ]
}

Results:
{
  "Output": "net/ipv6/ip6_gre.c=375=static void ip6gre_tunnel_uninit(struct net_device *dev)\n--\nnet/ipv6/ip6_gre.c-383-\nnet/ipv6/ip6_gre.c:384:static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\nnet/ipv6/ip6_gre.c-385-\t\t       u8 type, u8 code, int offset, __be32 info)\n--\nnet/ipv6/ip6_gre.c-453-\nnet/ipv6/ip6_gre.c:454:static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,\nnet/ipv6/ip6_gre.c-455-\t\t\t\t       const struct tnl_ptk_info *tpi)\n--\nnet/ipv6/ip6_gre.c-487-\nnet/ipv6/ip6_gre.c:488:static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\nnet/ipv6/ip6_gre.c-489-\t\t\t\t\t  struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_gre.c=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-585-\t\t     tpi.proto == htons(ETH_P_ERSPAN2))) {\nnet/ipv6/ip6_gre.c:586:\t\treason = ip6erspan_rcv(skb, \u0026tpi, tpi.hdr_len);\nnet/ipv6/ip6_gre.c-587-\t\tif (!reason)\n--\nnet/ipv6/ip6_gre.c-591-\nnet/ipv6/ip6_gre.c:592:\treason = ip6gre_rcv(skb, \u0026tpi);\nnet/ipv6/ip6_gre.c-593-\tif (!reason)\n--\nnet/ipv6/ip6_gre.c=1568=static struct inet6_protocol ip6gre_protocol __read_mostly = {\nnet/ipv6/ip6_gre.c-1569-\t.handler     = gre_rcv,\nnet/ipv6/ip6_gre.c:1570:\t.err_handler = ip6gre_err,\nnet/ipv6/ip6_gre.c-1571-\t.flags       = INET6_PROTO_FINAL,\n"
}

21/2 2026/11/14 05:14 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 33529
							output: 39
							thoughts: 75
						

Thoughts:
Here's my analysis of the provided code snippets:

**Digging into GRE Tunneling Implementations**

Okay, so I'm looking at how Generic Routing Encapsulation (GRE) is implemented in the Linux kernel, specifically the IPv6 and IPv4 versions. My initial focus is on the registration of the GRE protocol handlers. I see that within `net/ipv6/ip6_gre.c`, the `ip6gre_protocol` structure is being set up. This structure is crucial because it defines the core callbacks for handling GRE packets. Specifically, I'm noting that `ip6gre_protocol.err_handler` points to `ip6gre_err` and `ip6gre_protocol.handler` points to `gre_rcv`. This is my starting point, as it shows me where the kernel routes incoming GRE traffic based on the encapsulated protocol. `ip6gre_err` is the function that deals with the error cases when processing the GRE traffic and `gre_rcv` is the standard receiver, responsible for handling the the encapsulated packets.

Now, I need to check out the IPv4 side to see if there are any major differences in how GRE is managed. So, I need to check the `net/ipv4/ip_gre.c` file and specifically functions `gre_rcv` and `gre_err`. I assume there will be similarities in the packet processing logic, but I will investigate if they are handled the same. I'll need to compare the error handling (`gre_err` in IPv4 against `ip6gre_err` in IPv6) and the reception logic in each of the versions.



22/2 2026/11/14 05:15 tool grepper
0m Args:
{
  "Expression": "gre_rcv|gre_err",
  "PathPrefixes": [
    "net/ipv4/ip_gre.c"
  ]
}

Results:
{
  "Output": "net/ipv4/ip_gre.c=120=static unsigned int erspan_net_id __read_mostly;\nnet/ipv4/ip_gre.c-121-\nnet/ipv4/ip_gre.c:122:static int ipgre_err(struct sk_buff *skb, u32 info,\nnet/ipv4/ip_gre.c-123-\t\t     const struct tnl_ptk_info *tpi)\n--\nnet/ipv4/ip_gre.c-218-\nnet/ipv4/ip_gre.c:219:static void gre_err(struct sk_buff *skb, u32 info)\nnet/ipv4/ip_gre.c-220-{\n--\nnet/ipv4/ip_gre.c-254-\nnet/ipv4/ip_gre.c:255:\tipgre_err(skb, info, \u0026tpi);\nnet/ipv4/ip_gre.c-256-}\n--\nnet/ipv4/ip_gre.c=267=static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv4/ip_gre.c-368-\nnet/ipv4/ip_gre.c:369:static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,\nnet/ipv4/ip_gre.c-370-\t\t\t\t\tconst struct tnl_ptk_info *tpi,\n--\nnet/ipv4/ip_gre.c-423-\nnet/ipv4/ip_gre.c:424:static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,\nnet/ipv4/ip_gre.c-425-\t\t\t\t      const struct tnl_ptk_info *tpi,\n--\nnet/ipv4/ip_gre.c-436-\nnet/ipv4/ip_gre.c:437:\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);\nnet/ipv4/ip_gre.c-438-\tif (reason == SKB_DROP_REASON_TUNNEL_NOT_FOUND \u0026\u0026\n--\nnet/ipv4/ip_gre.c-443-\t\titn = net_generic(net, ipgre_net_id);\nnet/ipv4/ip_gre.c:444:\t\treason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);\nnet/ipv4/ip_gre.c-445-\t}\n--\nnet/ipv4/ip_gre.c-448-\nnet/ipv4/ip_gre.c:449:static int gre_rcv(struct sk_buff *skb)\nnet/ipv4/ip_gre.c-450-{\n--\nnet/ipv4/ip_gre.c-475-\nnet/ipv4/ip_gre.c:476:\treason = ipgre_rcv(skb, \u0026tpi, tpi.hdr_len);\nnet/ipv4/ip_gre.c-477-\tif (!reason)\n--\nnet/ipv4/ip_gre.c=1133=static const struct gre_protocol ipgre_protocol = {\nnet/ipv4/ip_gre.c:1134:\t.handler     = gre_rcv,\nnet/ipv4/ip_gre.c:1135:\t.err_handler = gre_err,\nnet/ipv4/ip_gre.c-1136-};\n"
}

23/2 2026/11/14 05:15 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 34899
							output: 36
							thoughts: 86
						

Thoughts:
Here's my take on the situation:

**Investigating the GRE Receive Path**

Alright, let's break this down. I've spotted something interesting—two functions named `gre_rcv`. One of them, the `static int gre_rcv(struct sk_buff *skb)` function, seems to be registered as an `inet_protocol` handler for `IPPROTO_GRE`. That immediately piques my interest. I need to understand the relationship between these.

My next move is clear: I'm diving into `net/ipv4/gre_demux.c`. I need to figure out exactly how and where this `gre_rcv` function is getting registered as an IP protocol handler. Knowing the registration process is key to understanding how GRE traffic is initially received and routed within the kernel's network stack. Understanding this registration will help me form a mental model of how the system processes GRE packets.



24/2 2026/11/14 05:15 tool grepper
0m Args:
{
  "Expression": "gre_rcv",
  "PathPrefixes": [
    "net/ipv4/gre_demux.c"
  ]
}

Results:
{
  "Output": "net/ipv4/gre_demux.c=164=EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-165-\nnet/ipv4/gre_demux.c:166:static int gre_rcv(struct sk_buff *skb)\nnet/ipv4/gre_demux.c-167-{\n--\nnet/ipv4/gre_demux.c=223=static const struct net_protocol net_gre_protocol = {\nnet/ipv4/gre_demux.c:224:\t.handler     = gre_rcv,\nnet/ipv4/gre_demux.c-225-\t.err_handler = gre_err,\n"
}

25/2 2026/11/14 05:15 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 35408
							output: 39
							thoughts: 53
						

Thoughts:
Okay, here's my take on those thoughts, framed as an expert's internal monologue:

**Investigating IPv6 Tunnel Reception**

Right, so I'm digging into IPv6 tunnel reception, specifically in the kernel. I need to understand how these packets are handled, and where the core logic resides. My initial focus is on `net/ipv6/ip6_tunnel.c`. Okay, so far so good.

Now, I'm noting the functions that seem most relevant to receive processing. `__ip6_tnl_rcv` and `ipxip6_rcv` are the obvious candidates. I'll need to understand what each does, but first, I need to know how `ipxip6_rcv` is invoked. It's crucial to trace the call chain to pinpoint the entry point and the circumstances in which this function is triggered. Knowing that's essential for understanding the data flow and potential points of interest for analysis or modification, be that performance or security. Let's see if I can find that information quickly.



26/2 2026/11/14 05:15 tool grepper
0m Args:
{
  "Expression": "ipxip6_rcv",
  "PathPrefixes": [
    "net/ipv6/ip6_tunnel.c"
  ]
}

Results:
{
  "Output": "net/ipv6/ip6_tunnel.c=944=static const struct tnl_ptk_info tpi_mpls = {\n--\nnet/ipv6/ip6_tunnel.c-948-\nnet/ipv6/ip6_tunnel.c:949:static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\nnet/ipv6/ip6_tunnel.c-950-\t\t      const struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_tunnel.c=1006=static int ip4ip6_rcv(struct sk_buff *skb)\nnet/ipv6/ip6_tunnel.c-1007-{\nnet/ipv6/ip6_tunnel.c:1008:\treturn ipxip6_rcv(skb, IPPROTO_IPIP, \u0026tpi_v4,\nnet/ipv6/ip6_tunnel.c-1009-\t\t\t  ip4ip6_dscp_ecn_decapsulate);\n--\nnet/ipv6/ip6_tunnel.c=1012=static int ip6ip6_rcv(struct sk_buff *skb)\nnet/ipv6/ip6_tunnel.c-1013-{\nnet/ipv6/ip6_tunnel.c:1014:\treturn ipxip6_rcv(skb, IPPROTO_IPV6, \u0026tpi_v6,\nnet/ipv6/ip6_tunnel.c-1015-\t\t\t  ip6ip6_dscp_ecn_decapsulate);\n--\nnet/ipv6/ip6_tunnel.c=1018=static int mplsip6_rcv(struct sk_buff *skb)\nnet/ipv6/ip6_tunnel.c-1019-{\nnet/ipv6/ip6_tunnel.c:1020:\treturn ipxip6_rcv(skb, IPPROTO_MPLS, \u0026tpi_mpls,\nnet/ipv6/ip6_tunnel.c-1021-\t\t\t  mplsip6_dscp_ecn_decapsulate);\n"
}

27/2 2026/11/14 05:15 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36268
							output: 47
							thoughts: 85
						

Thoughts:
Okay, here's my interpretation of this flow, as if I were thinking it through:

**Deconstructing the IPv6 Tunneling Receive Path**

Right, so I'm tracing the receive path for IPv6-over-IPv6 tunnels, and it seems like we have a pattern here. I see that routines like `ip4ip6_rcv`, `ip6ip6_rcv`, and others all funnel into `ipxip6_rcv`. That's the common entry point, which then, as I suspected, calls `__ip6_tnl_rcv`. Now, I need to understand what happens *within* `__ip6_tnl_rcv`, so I'll go directly to the source. The natural place to look is either in `include/net/ip6_tunnel.h` or, perhaps more likely the implementation, `net/ipv6/ip6_tunnel.c`. Let's see what `ip6_tnl_rcv` - the function that gets called inside `__ip6_tnl_rcv` - actually does with these tunneled IPv6 packets. I'm guessing that's where the core logic of the decapsulation and packet processing resides. Time to dig in!



28/2 2026/11/14 05:15 tool grepper
0m Args:
{
  "Expression": "ip6_tnl_rcv",
  "PathPrefixes": [
    "net/ipv6/",
    "include/net/ip6_tunnel.h"
  ]
}

Results:
{
  "Output": "include/net/ip6_tunnel.h=133=struct ipv6_tlv_tnl_enc_lim {\n--\ninclude/net/ip6_tunnel.h-138-\ninclude/net/ip6_tunnel.h:139:int ip6_tnl_rcv_ctl(struct ip6_tnl *t, const struct in6_addr *laddr,\ninclude/net/ip6_tunnel.h-140-\t\tconst struct in6_addr *raddr);\ninclude/net/ip6_tunnel.h:141:int ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\ninclude/net/ip6_tunnel.h-142-\t\tconst struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,\n--\nnet/ipv6/ip6_gre.c=454=static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-476-\nnet/ipv6/ip6_gre.c:477:\t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\nnet/ipv6/ip6_gre.c-478-\t\t} else {\nnet/ipv6/ip6_gre.c:479:\t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\nnet/ipv6/ip6_gre.c-480-\t\t}\n--\nnet/ipv6/ip6_gre.c=488=static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,\n--\nnet/ipv6/ip6_gre.c-558-\nnet/ipv6/ip6_gre.c:559:\t\t\tip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);\nnet/ipv6/ip6_gre.c-560-\nnet/ipv6/ip6_gre.c-561-\t\t} else {\nnet/ipv6/ip6_gre.c:562:\t\t\tip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);\nnet/ipv6/ip6_gre.c-563-\t\t}\n--\nnet/ipv6/ip6_tunnel.c=777=EXPORT_SYMBOL(ip6_tnl_get_cap);\n--\nnet/ipv6/ip6_tunnel.c-779-/* called with rcu_read_lock() */\nnet/ipv6/ip6_tunnel.c:780:int ip6_tnl_rcv_ctl(struct ip6_tnl *t,\nnet/ipv6/ip6_tunnel.c-781-\t\t\t\t  const struct in6_addr *laddr,\n--\nnet/ipv6/ip6_tunnel.c-805-}\nnet/ipv6/ip6_tunnel.c:806:EXPORT_SYMBOL_GPL(ip6_tnl_rcv_ctl);\nnet/ipv6/ip6_tunnel.c-807-\nnet/ipv6/ip6_tunnel.c:808:static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,\nnet/ipv6/ip6_tunnel.c-809-\t\t\t const struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_tunnel.c-915-\nnet/ipv6/ip6_tunnel.c:916:int ip6_tnl_rcv(struct ip6_tnl *t, struct sk_buff *skb,\nnet/ipv6/ip6_tunnel.c-917-\t\tconst struct tnl_ptk_info *tpi,\n--\nnet/ipv6/ip6_tunnel.c-928-\nnet/ipv6/ip6_tunnel.c:929:\treturn __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\nnet/ipv6/ip6_tunnel.c-930-\t\t\t     log_ecn_err);\nnet/ipv6/ip6_tunnel.c-931-}\nnet/ipv6/ip6_tunnel.c:932:EXPORT_SYMBOL(ip6_tnl_rcv);\nnet/ipv6/ip6_tunnel.c-933-\n--\nnet/ipv6/ip6_tunnel.c=949=static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,\n--\nnet/ipv6/ip6_tunnel.c-975-\t\tipv6h = ipv6_hdr(skb);\nnet/ipv6/ip6_tunnel.c:976:\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr)) {\nnet/ipv6/ip6_tunnel.c-977-\t\t\treason = SKB_DROP_REASON_NOT_SPECIFIED;\n--\nnet/ipv6/ip6_tunnel.c-991-\t\t}\nnet/ipv6/ip6_tunnel.c:992:\t\tret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,\nnet/ipv6/ip6_tunnel.c-993-\t\t\t\t    log_ecn_error);\n--\nnet/ipv6/ip6_vti.c=296=static int vti6_input_proto(struct sk_buff *skb, int nexthdr, __be32 spi,\n--\nnet/ipv6/ip6_vti.c-315-\t\tipv6h = ipv6_hdr(skb);\nnet/ipv6/ip6_vti.c:316:\t\tif (!ip6_tnl_rcv_ctl(t, \u0026ipv6h-\u003edaddr, \u0026ipv6h-\u003esaddr)) {\nnet/ipv6/ip6_vti.c-317-\t\t\tDEV_STATS_INC(t-\u003edev, rx_dropped);\n"
}

29/2 2026/11/14 05:15 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38243
							output: 21
							thoughts: 1652
						

Thoughts:
**Focusing the Fuzzer: Identifying Key Kernel Functions**

Okay, let's break this down systematically. I see that `__ip6_tnl_rcv` is called by `ip6_tnl_rcv` and `ipxip6_rcv`. This looks like a good starting point for understanding where the changes are impacting the networking stack. My first instinct is to explore the tunnel-related functions, especially those exported in `net/ipv4/ip_tunnel.c`. I'll want to review `ip_tunnel_rcv`, `ip_tunnel_xmit`, and `ip_md_tunnel_xmit`. Then, I'll need to check `gre_parse_header` in `net/ipv4/gre_demux.c`, which likely plays a role in header parsing.

Moving on to `net/ipv4/ip_gre.c`, the focus will be on the receive and transmit pathways: `ipgre_xmit`, `erspan_xmit`, `gre_tap_xmit`, and the corresponding receivers: `erspan_rcv`, `ipgre_rcv`, and `gre_rcv`.  In `net/ipv6/ip6_gre.c`, I'll check `ip6gre_rcv` and `ip6erspan_rcv`, and in `net/ipv6/ip6_tunnel.c`, I'll make sure to get `ip6_tnl_rcv` and `ipxip6_rcv`. Finally, I also want to look at `ipip6_tunnel_xmit` from `net/ipv6/sit.c`.

Now, before I commit to those symbols, let's take a look at the guidelines for `FocusSymbols`. It's crucial to avoid ubiquitous functions, so I must target the specific feature logic or entrypoints.

The patch seems to modify these .c file functions:
- `gre_parse_header`
- `ipgre_rcv`
- `ipgre_xmit`
- `erspan_rcv`
- `erspan_xmit`
- `gre_tap_xmit`
- `ip_tunnel_rcv`
- `ip_tunnel_xmit`
- `ip_md_tunnel_xmit`
- `ip6gre_rcv`
- `ip6erspan_rcv`
- `ip6_tnl_rcv` (or `__ip6_tnl_rcv`)
- `ipxip6_rcv`
- `ipip6_tunnel_xmit`

Okay, those function names are a bit redundant, but it's important to make sure they're all there. Let's make sure I didn't miss something in the other files. Specifically, I'll quickly check if `net/ipv6/ip6_gre.c` or `net/ipv4/ip_gre.c` have additional functions related to `ndo_start_xmit` or entry points that might have been impacted. I'll need to check the diffs!
Hmm, the patch modified `ip6gre_rcv` and `ip6erspan_rcv` in `net/ipv6/ip6_gre.c`. But no xmit functions were modified. `ipip6_tunnel_xmit` in `net/ipv6/sit.c` looks good. `gre_err`, `erspan_rcv`, `__ipgre_rcv`, `ipgre_rcv`, `gre_rcv`, `gre_fb_xmit`, `erspan_fb_xmit`, `ipgre_xmit`, `erspan_xmit`, `gre_tap_xmit` in `net/ipv4/ip_gre.c` were modified. Also, `ip_tunnel_rcv`, `ip_md_tunnel_xmit`, `ip_tunnel_xmit` in `net/ipv4/ip_tunnel.c`. And `__ip6_tnl_rcv`, `ipxip6_rcv` in `net/ipv6/ip6_tunnel.c` and finally `gre_parse_header`, `gre_rcv` in `net/ipv4/gre_demux.c`.

Let me verify the visibility of `gre_rcv` among the files. There are multiple definitions, so it might be better to include the distinct functions from the specific source files.

I also should not forget that `ip_tunnel_encap` in `include/net/ip_tunnels.h` is declared as static inline. Since this is an inline function, I


30/2 2026/11/14 05:15 tool grepper
0m Args:
{
  "Expression": "ip_tunnel_encap\\("
}

Results:
{
  "Output": "include/net/ip_tunnels.h=544=static inline enum skb_drop_reason\ninclude/net/ip_tunnels.h:545:ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel_encap *e,\ninclude/net/ip_tunnels.h-546-\t\tu8 *protocol, struct flowi4 *fl4)\n--\nnet/ipv4/ip_tunnel.c=586=void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv4/ip_tunnel.c-624-\nnet/ipv4/ip_tunnel.c:625:\treason = ip_tunnel_encap(skb, \u0026tun_info-\u003eencap, \u0026proto, \u0026fl4);\nnet/ipv4/ip_tunnel.c-626-\tif (reason)\n--\nnet/ipv4/ip_tunnel.c=692=void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,\n--\nnet/ipv4/ip_tunnel.c-796-\nnet/ipv4/ip_tunnel.c:797:\treason = ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4);\nnet/ipv4/ip_tunnel.c-798-\tif (reason)\n--\nnet/ipv6/sit.c=966=static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,\n--\nnet/ipv6/sit.c-1098-\nnet/ipv6/sit.c:1099:\tif (ip_tunnel_encap(skb, \u0026tunnel-\u003eencap, \u0026protocol, \u0026fl4)) {\nnet/ipv6/sit.c-1100-\t\tip_rt_put(rt);\n"
}

31/2 2026/11/14 05:15 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41420
							output: 333
							thoughts: 1291
						

Thoughts:
**Analyzing the Impact of Enhanced SKB Drop Reasons in Tunneling**

Okay, so I've been digging into this patch. The key here is that `ip_tunnel_encap` is only called from a limited number of places. Now, let's nail down the configuration requirements. We need to make sure we have: `NET_IP_TUNNEL`, `NET_IPGRE_DEMUX`, `NET_IPGRE`, `IPV6_GRE`, `IPV6_TUNNEL`, `IPV6_SIT`, `INET`, and `IPV6`.

I should check if `NET_IPGRE` and `IPV6_GRE` have any specific configuration dependencies. Looking at `net/ipv4/Kconfig` and `net/ipv6/Kconfig`, I see: `NET_IPGRE_DEMUX` is tristate (no dependencies). `NET_IP_TUNNEL` is also tristate, selected by several other options. `NET_IPGRE` depends on `NET_IPGRE_DEMUX` and selects `NET_IP_TUNNEL`. `NET_IPGRE_BROADCAST` depends on `IP_MULTICAST` and `NET_IPGRE`. `IPV6_SIT` depends on `IPV6` and selects `INET_TUNNEL`, `NET_IP_TUNNEL`, and `IPV6_NDISC_NODETYPE`. `IPV6_TUNNEL` just depends on `IPV6`.  `IPV6_GRE` depends on `IPV6` and `NET_IPGRE_DEMUX` and selects `IPV6_TUNNEL` and `NET_IP_TUNNEL`.

So, the essential configs are: `NET_IPGRE`, `NET_IPGRE_DEMUX`, `IPV6_GRE`, `IPV6_TUNNEL`, `IPV6_SIT`, and `NET_IP_TUNNEL`.  `NET_IPGRE_BROADCAST` is also worth enabling.

Alright, let's look for any other configurations. The code in `net/ipv4/ip_gre.c` shows that `CONFIG_NET_IPGRE_BROADCAST` specifically handles multicast packets within the GRE context, which is important for understanding the impact of this patch.

Now, let's re-examine those core symbols to ensure a holistic understanding: `gre_parse_header`, `ip_tunnel_rcv`, `ip_tunnel_xmit`, `ip_md_tunnel_xmit`, `ipgre_rcv`, `ipgre_xmit`, `erspan_rcv`, `erspan_xmit`, `gre_tap_xmit`, `ip6gre_rcv`, `ip6erspan_rcv`, `ip6_tnl_rcv`, `ipxip6_rcv`, and `ipip6_tunnel_xmit`.

Each one of these functions is very specific to the altered networking code, which is good. They are directly implementing and exercising the code that's been changed, especially around detailed drop reason logic.

My final analysis indicates a very solid patch.  It refactors the GRE and IP/IPv6 tunnel paths to provide precise SKB drop reasons (things like `SKB_DROP_REASON_TUNNEL_OPT_MISMATCH` and so on) instead of vague errors. The changes affect header parsing, encapsulation, and packet handling in various tunnel modules (`ip_gre`, `ip_tunnel`, `ip6_gre`, `ip6_tunnel`, and `sit`).  These are all core networking components accessible through the standard networking APIs and netlink. This is a good thing to fuzz, particularly the edge cases with malformed packets, sequence numbers, encapsulation failures, and checksums. I am ready to call `set-results`.



32/2 2026/11/14 05:16 tool set-results
0m Args:
{
  "EnableConfigs": [
    "NET_IPGRE",
    "NET_IPGRE_DEMUX",
    "NET_IP_TUNNEL",
    "NET_IPGRE_BROADCAST",
    "IPV6_GRE",
    "IPV6_TUNNEL",
    "IPV6_SIT"
  ],
  "FocusSymbols": [
    "gre_parse_header",
    "ip_tunnel_rcv",
    "ip_tunnel_xmit",
    "ip_md_tunnel_xmit",
    "ipgre_rcv",
    "ipgre_xmit",
    "erspan_rcv",
    "erspan_xmit",
    "gre_tap_xmit",
    "ip6gre_rcv",
    "ip6erspan_rcv",
    "ip6_tnl_rcv",
    "ipxip6_rcv",
    "ipip6_tunnel_xmit"
  ],
  "Reasoning": "The patch modifies core networking tunnel code (GRE, ERSPAN, SIT, and generic IP/IPv6 tunnels) to return detailed skb drop reasons rather than generic error codes. It changes the signature and return semantics of gre_parse_header() and ip_tunnel_encap(), and updates packet receive and transmit routines across net/ipv4 and net/ipv6. This reachable code handles untrusted packet input and tunnel configurations, making it relevant for fuzzing to discover regressions or crashes with malformed tunnel headers, sequence numbers, checksums, and encapsulation options.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "NET_IPGRE",
    "NET_IPGRE_DEMUX",
    "NET_IP_TUNNEL",
    "NET_IPGRE_BROADCAST",
    "IPV6_GRE",
    "IPV6_TUNNEL",
    "IPV6_SIT"
  ],
  "FocusSymbols": [
    "gre_parse_header",
    "ip_tunnel_rcv",
    "ip_tunnel_xmit",
    "ip_md_tunnel_xmit",
    "ipgre_rcv",
    "ipgre_xmit",
    "erspan_rcv",
    "erspan_xmit",
    "gre_tap_xmit",
    "ip6gre_rcv",
    "ip6erspan_rcv",
    "ip6_tnl_rcv",
    "ipxip6_rcv",
    "ipip6_tunnel_xmit"
  ],
  "Reasoning": "The patch modifies core networking tunnel code (GRE, ERSPAN, SIT, and generic IP/IPv6 tunnels) to return detailed skb drop reasons rather than generic error codes. It changes the signature and return semantics of gre_parse_header() and ip_tunnel_encap(), and updates packet receive and transmit routines across net/ipv4 and net/ipv6. This reachable code handles untrusted packet input and tunnel configurations, making it relevant for fuzzing to discover regressions or crashes with malformed tunnel headers, sequence numbers, checksums, and encapsulation options.",
  "WorthFuzzing": true
}

33/1 2026/11/14 05:16 action If
1m Args:
{
  "WorthFuzzing": true
}

Results:
null

34/2 2026/11/14 05:16 agent kmsan-evaluator
1m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch series introduces detailed skb drop reasons (enum skb_drop_reason) and replaces kfree_skb() with kfree_skb_reason() across IPv4 and IPv6 GRE, ERSPAN, and generic IP tunnel receive and transmit paths.\n\nKMSAN vs KASAN Applicability:\n1. No uninitialized memory or info-leak risks: The patch does not expose any uninitialized data or kernel memory to user space (no copy_to_user, netlink attributes, ioctl output, or socket options are introduced or modified). Drop reasons are internal kernel tracepoint arguments passed to kfree_skb_reason().\n2. Variable initialization: All newly introduced local variables (e.g., `enum skb_drop_reason reason`) are either initialized at declaration or explicitly assigned along every code path prior to being read or passed to kfree_skb_reason().\n3. Data structures: The `struct tnl_ptk_info tpi` parsed by `gre_parse_header()` has all relevant fields populated on success and is not read on failure paths. No new heap/stack allocations or complex structures are created.\n4. Any potential bugs in header bounds calculation or parsing would manifest as buffer overruns or invalid pointer dereferences, which are covered by KASAN and standard sanitizers rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit 1539401cda3b1821003d9f832e0ad9248abccfbf
Author: syz-cluster <triage@syzkaller.com>
Date:   Sat Nov 14 05:13:51 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/net/dropreason-core.h b/include/net/dropreason-core.h
index fa2fe89905573a..fb6f3d8da960c7 100644
--- a/include/net/dropreason-core.h
+++ b/include/net/dropreason-core.h
@@ -128,6 +128,10 @@
 	FN(PSP_INPUT)			\
 	FN(PSP_OUTPUT)			\
 	FN(RECURSION_LIMIT)		\
+	FN(TUNNEL_OPT_MISMATCH)		\
+	FN(TUNNEL_OLD_SEQ)		\
+	FN(GRE_CSUM)			\
+	FN(TUNNEL_ENCAP)		\
 	FNe(MAX)
 
 /**
@@ -535,11 +539,13 @@ enum skb_drop_reason {
 	 * @SKB_DROP_REASON_TUNNEL_INVALID_HDR: tunnel header is invalid. E.g.:
 	 * 1) VXLAN reserved fields are not zero
 	 * 2) VXLAN "I" flag is not set
+	 * 3) GRE version is not supported or the routing bit is set
 	 */
 	SKB_DROP_REASON_TUNNEL_INVALID_HDR,
 	/**
 	 * @SKB_DROP_REASON_TUNNEL_NOT_FOUND: no tunnel device found for the
-	 * packet, e.g. no VXLAN device for its VNI
+	 * packet, e.g. no VXLAN device for its VNI or no GRE tunnel for its
+	 * endpoints and key
 	 */
 	SKB_DROP_REASON_TUNNEL_NOT_FOUND,
 	/** @SKB_DROP_REASON_MAC_INVALID_SOURCE: source mac is invalid */
@@ -612,6 +618,29 @@ enum skb_drop_reason {
 	 * itself.
 	 */
 	SKB_DROP_REASON_RECURSION_LIMIT,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_OPT_MISMATCH: the tunnel options carried by
+	 * the packet do not match the tunnel configuration, e.g. a GRE tunnel
+	 * configured with 'icsum' or 'iseq' received a packet with no checksum
+	 * or no sequence number, or a GRE tunnel without 'icsum' received a
+	 * packet with a checksum.
+	 */
+	SKB_DROP_REASON_TUNNEL_OPT_MISMATCH,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_OLD_SEQ: the sequence number carried by the
+	 * packet is older than the one expected by the tunnel, e.g. the packet
+	 * was reordered in the network or by the receive processing, or the
+	 * remote endpoint restarted and reset its sequence numbering.
+	 */
+	SKB_DROP_REASON_TUNNEL_OLD_SEQ,
+	/** @SKB_DROP_REASON_GRE_CSUM: GRE checksum error */
+	SKB_DROP_REASON_GRE_CSUM,
+	/**
+	 * @SKB_DROP_REASON_TUNNEL_ENCAP: failed to build the encapsulation
+	 * header of a tunnel, e.g. an unknown or unregistered encapsulation
+	 * type.
+	 */
+	SKB_DROP_REASON_TUNNEL_ENCAP,
 	/**
 	 * @SKB_DROP_REASON_MAX: the maximum of core drop reasons, which
 	 * shouldn't be used as a real 'reason' - only for tracing code gen
diff --git a/include/net/gre.h b/include/net/gre.h
index b55f67ecd2fc4b..b5dbe00ab15ef7 100644
--- a/include/net/gre.h
+++ b/include/net/gre.h
@@ -32,8 +32,9 @@ struct gre_protocol {
 int gre_add_protocol(const struct gre_protocol *proto, u8 version);
 int gre_del_protocol(const struct gre_protocol *proto, u8 version);
 
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err, __be16 proto, int nhs);
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+		 bool ignore_csum_err, __be16 proto, int nhs);
 
 static inline bool netif_is_gretap(const struct net_device *dev)
 {
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5cccf4c0e6913a..87046ba50d45bb 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -207,10 +207,6 @@ struct tnl_ptk_info {
 	int hdr_len;
 };
 
-#define PACKET_RCVD	0
-#define PACKET_REJECT	1
-#define PACKET_NEXT	2
-
 #define IP_TNL_HASH_BITS   7
 #define IP_TNL_HASH_SIZE   (1 << IP_TNL_HASH_BITS)
 
@@ -545,18 +541,18 @@ static inline int ip_encap_hlen(struct ip_tunnel_encap *e)
 	return hlen;
 }
 
-static inline int ip_tunnel_encap(struct sk_buff *skb,
-				  struct ip_tunnel_encap *e,
-				  u8 *protocol, struct flowi4 *fl4)
+static inline enum skb_drop_reason
+ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel_encap *e,
+		u8 *protocol, struct flowi4 *fl4)
 {
 	const struct ip_tunnel_encap_ops *ops;
 	int ret = -EINVAL;
 
 	if (e->type == TUNNEL_ENCAP_NONE)
-		return 0;
+		return SKB_NOT_DROPPED_YET;
 
 	if (e->type >= MAX_IPTUN_ENCAP_OPS)
-		return -EINVAL;
+		return SKB_DROP_REASON_TUNNEL_ENCAP;
 
 	rcu_read_lock();
 	ops = rcu_dereference(iptun_encaps[e->type]);
@@ -564,7 +560,11 @@ static inline int ip_tunnel_encap(struct sk_buff *skb,
 		ret = ops->build_header(skb, e, protocol, fl4);
 	rcu_read_unlock();
 
-	return ret;
+	if (!ret)
+		return SKB_NOT_DROPPED_YET;
+	if (ret == -ENOMEM)
+		return SKB_DROP_REASON_NOMEM;
+	return SKB_DROP_REASON_TUNNEL_ENCAP;
 }
 
 /* Extract dsfield from inner protocol */
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c
index 96fd7dc6d82dd0..6c1d1fe914b895 100644
--- a/net/ipv4/gre_demux.c
+++ b/net/ipv4/gre_demux.c
@@ -56,28 +56,47 @@ int gre_del_protocol(const struct gre_protocol *proto, u8 version)
 }
 EXPORT_SYMBOL_GPL(gre_del_protocol);
 
-/* Fills in tpi and returns header length to be pulled.
- * Note that caller must use pskb_may_pull() before pulling GRE header.
+/**
+ * gre_parse_header() - parse the GRE header of a packet
+ * @skb: the packet; the GRE header starts @nhs bytes past skb->data
+ * @tpi: filled in with the fields of the header, and with the length of
+ *	the header to be pulled in tpi->hdr_len
+ * @ignore_csum_err: do not reject the header when its checksum does not
+ *	match. The ICMP error handlers set it, as they only get a part of the
+ *	original packet; the checksum is still computed and the rest of the
+ *	header is parsed.
+ * @proto: the protocol to report for a WCCP payload, ETH_P_IP or
+ *	ETH_P_IPV6
+ * @nhs: the offset of the GRE header from skb->data
+ *
+ * The caller must use pskb_may_pull() before pulling the GRE header.
+ *
+ * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the
+ * header is rejected.
  */
-int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		     bool *csum_err, __be16 proto, int nhs)
+enum skb_drop_reason
+gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
+		 bool ignore_csum_err, __be16 proto, int nhs)
 {
 	const struct gre_base_hdr *greh;
+	enum skb_drop_reason reason;
 	__be32 *options;
 	int hdr_len;
 
-	if (unlikely(!pskb_may_pull(skb, nhs + sizeof(struct gre_base_hdr))))
-		return -EINVAL;
+	reason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));
+	if (unlikely(reason))
+		return reason;
 
 	greh = (struct gre_base_hdr *)(skb->data + nhs);
 	if (unlikely(greh->flags & (GRE_VERSION | GRE_ROUTING)))
-		return -EINVAL;
+		return SKB_DROP_REASON_TUNNEL_INVALID_HDR;
 
 	gre_flags_to_tnl_flags(tpi->flags, greh->flags);
 	hdr_len = gre_calc_hlen(tpi->flags);
 
-	if (!pskb_may_pull(skb, nhs + hdr_len))
-		return -EINVAL;
+	reason = pskb_may_pull_reason(skb, nhs + hdr_len);
+	if (reason)
+		return reason;
 
 	greh = (struct gre_base_hdr *)(skb->data + nhs);
 	tpi->proto = greh->protocol;
@@ -87,9 +106,8 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		if (!skb_checksum_simple_validate(skb)) {
 			skb_checksum_try_convert(skb, IPPROTO_GRE,
 						 null_compute_pseudo);
-		} else if (csum_err) {
-			*csum_err = true;
-			return -EINVAL;
+		} else if (!ignore_csum_err) {
+			return SKB_DROP_REASON_GRE_CSUM;
 		}
 
 		options++;
@@ -117,7 +135,7 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		val = skb_header_pointer(skb, nhs + hdr_len,
 					 sizeof(_val), &_val);
 		if (!val)
-			return -EINVAL;
+			return SKB_DROP_REASON_PKT_TOO_SMALL;
 		tpi->proto = proto;
 		if ((*val & 0xF0) != 0x40)
 			hdr_len += 4;
@@ -132,29 +150,35 @@ int gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 	    greh->protocol == htons(ETH_P_ERSPAN2)) {
 		struct erspan_base_hdr *ershdr;
 
-		if (!pskb_may_pull(skb, nhs + hdr_len + sizeof(*ershdr)))
-			return -EINVAL;
+		reason = pskb_may_pull_reason(skb,
+					      nhs + hdr_len + sizeof(*ershdr));
+		if (reason)
+			return reason;
 
 		ershdr = (struct erspan_base_hdr *)(skb->data + nhs + hdr_len);
 		tpi->key = cpu_to_be32(get_session_id(ershdr));
 	}
 
-	return hdr_len;
+	return SKB_NOT_DROPPED_YET;
 }
 EXPORT_SYMBOL(gre_parse_header);
 
 static int gre_rcv(struct sk_buff *skb)
 {
 	const struct gre_protocol *proto;
+	enum skb_drop_reason reason;
 	u8 ver;
 	int ret;
 
-	if (!pskb_may_pull(skb, 12))
+	reason = pskb_may_pull_reason(skb, 12);
+	if (reason)
 		goto drop;
 
 	ver = skb->data[1]&0x7f;
-	if (ver >= GREPROTO_MAX)
+	if (ver >= GREPROTO_MAX) {
+		reason = SKB_DROP_REASON_TUNNEL_INVALID_HDR;
 		goto drop;
+	}
 
 	rcu_read_lock();
 	proto = rcu_dereference(gre_proto[ver]);
@@ -167,11 +191,11 @@ static int gre_rcv(struct sk_buff *skb)
 drop_nohandler:
 	rcu_read_unlock();
 	dev_core_stats_rx_nohandler_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, SKB_DROP_REASON_UNHANDLED_PROTO);
 	return NET_RX_DROP;
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return NET_RX_DROP;
 }
 
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 5485586fa0e625..71e087a7afcf00 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -237,8 +237,8 @@ static void gre_err(struct sk_buff *skb, u32 info)
 	const int code = icmp_hdr(skb)->code;
 	struct tnl_ptk_info tpi;
 
-	if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IP),
-			     iph->ihl * 4) < 0)
+	if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IP),
+			     iph->ihl * 4))
 		return;
 
 	if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED) {
@@ -264,9 +264,11 @@ static bool is_erspan_type1(int gre_hdr_len)
 	return gre_hdr_len == 4;
 }
 
-static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
-		      int gre_hdr_len)
+static enum skb_drop_reason erspan_rcv(struct sk_buff *skb,
+				       struct tnl_ptk_info *tpi,
+				       int gre_hdr_len)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct net *net = dev_net(skb->dev);
 	struct metadata_dst *tun_dst = NULL;
 	struct erspan_base_hdr *ershdr;
@@ -288,9 +290,10 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		tunnel = ip_tunnel_lookup(itn, skb->dev->ifindex, flags,
 					  iph->saddr, iph->daddr, 0);
 	} else {
-		if (unlikely(!pskb_may_pull(skb,
-					    gre_hdr_len + sizeof(*ershdr))))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb,
+					      gre_hdr_len + sizeof(*ershdr));
+		if (unlikely(reason))
+			return reason;
 
 		ershdr = (struct erspan_base_hdr *)(skb->data + gre_hdr_len);
 		ver = ershdr->ver;
@@ -306,13 +309,13 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 		else
 			len = gre_hdr_len + erspan_hdr_len(ver);
 
-		if (unlikely(!pskb_may_pull(skb, len)))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb, len);
+		if (unlikely(reason))
+			return reason;
 
-		if (__iptunnel_pull_header(skb,
-					   len,
-					   htons(ETH_P_TEB),
-					   false, false))
+		reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+						false, false);
+		if (reason)
 			goto drop;
 
 		if (tunnel->collect_md) {
@@ -328,7 +331,7 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 			tun_dst = ip_tun_rx_dst(skb, flags,
 						tun_id, sizeof(*md));
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			/* MUST set options_len before referencing options */
 			info = &tun_dst->u.tun_info;
@@ -354,18 +357,21 @@ static int erspan_rcv(struct sk_buff *skb, struct tnl_ptk_info *tpi,
 
 		skb_reset_mac_header(skb);
 		ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 
 drop:
-	kfree_skb(skb);
-	return PACKET_RCVD;
+	kfree_skb_reason(skb, reason);
+	return SKB_NOT_DROPPED_YET;
 }
 
-static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
-		       struct ip_tunnel_net *itn, int hdr_len, bool raw_proto)
+static enum skb_drop_reason __ipgre_rcv(struct sk_buff *skb,
+					const struct tnl_ptk_info *tpi,
+					struct ip_tunnel_net *itn,
+					int hdr_len, bool raw_proto)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct metadata_dst *tun_dst = NULL;
 	const struct iphdr *iph;
 	struct ip_tunnel *tunnel;
@@ -377,8 +383,9 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
 	if (tunnel) {
 		const struct iphdr *tnl_params;
 
-		if (__iptunnel_pull_header(skb, hdr_len, tpi->proto,
-					   raw_proto, false))
+		reason = __iptunnel_pull_header(skb, hdr_len, tpi->proto,
+						raw_proto, false);
+		if (reason)
 			goto drop;
 
 		/* Special case for ipgre_header_parse(), which expects the
@@ -401,75 +408,80 @@ static int __ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
 			tun_id = key32_to_tunnel_id(tpi->key);
 			tun_dst = ip_tun_rx_dst(skb, flags, tun_id, 0);
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 		}
 
 		ip_tunnel_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
-	return PACKET_NEXT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 
 drop:
-	kfree_skb(skb);
-	return PACKET_RCVD;
+	kfree_skb_reason(skb, reason);
+	return SKB_NOT_DROPPED_YET;
 }
 
-static int ipgre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi,
-		     int hdr_len)
+static enum skb_drop_reason ipgre_rcv(struct sk_buff *skb,
+				      const struct tnl_ptk_info *tpi,
+				      int hdr_len)
 {
 	struct net *net = dev_net(skb->dev);
+	enum skb_drop_reason reason;
 	struct ip_tunnel_net *itn;
-	int res;
 
 	if (tpi->proto == htons(ETH_P_TEB))
 		itn = net_generic(net, gre_tap_net_id);
 	else
 		itn = net_generic(net, ipgre_net_id);
 
-	res = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
-	if (res == PACKET_NEXT && tpi->proto == htons(ETH_P_TEB)) {
+	reason = __ipgre_rcv(skb, tpi, itn, hdr_len, false);
+	if (reason == SKB_DROP_REASON_TUNNEL_NOT_FOUND &&
+	    tpi->proto == htons(ETH_P_TEB)) {
 		/* ipgre tunnels in collect metadata mode should receive
 		 * also ETH_P_TEB traffic.
 		 */
 		itn = net_generic(net, ipgre_net_id);
-		res = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
+		reason = __ipgre_rcv(skb, tpi, itn, hdr_len, true);
 	}
-	return res;
+	return reason;
 }
 
 static int gre_rcv(struct sk_buff *skb)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct tnl_ptk_info tpi;
-	bool csum_err = false;
-	int hdr_len;
 
 #ifdef CONFIG_NET_IPGRE_BROADCAST
 	if (ipv4_is_multicast(ip_hdr(skb)->daddr)) {
 		/* Looped back packet, drop it! */
-		if (rt_is_output_route(skb_rtable(skb)))
+		if (rt_is_output_route(skb_rtable(skb))) {
+			reason = SKB_DROP_REASON_NOT_SPECIFIED;
 			goto drop;
+		}
 	}
 #endif
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IP), 0);
-	if (hdr_len < 0)
+	reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IP), 0);
+	if (reason)
 		goto drop;
 
 	if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
 		     tpi.proto == htons(ETH_P_ERSPAN2))) {
-		if (erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+		reason = erspan_rcv(skb, &tpi, tpi.hdr_len);
+		if (!reason)
 			return 0;
 		goto out;
 	}
 
-	if (ipgre_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+	reason = ipgre_rcv(skb, &tpi, tpi.hdr_len);
+	if (!reason)
 		return 0;
 
 out:
 	icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
@@ -496,6 +508,7 @@ static int gre_handle_offloads(struct sk_buff *skb, bool csum)
 static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 			__be16 proto)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 	struct ip_tunnel_info *tun_info;
@@ -504,19 +517,25 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 
 	key = &tun_info->key;
 	tunnel_hlen = gre_calc_hlen(key->tun_flags);
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	/* Push Tunnel header. */
 	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT,
-					      tunnel->parms.o_flags)))
+					      tunnel->parms.o_flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	__set_bit(IP_TUNNEL_CSUM_BIT, flags);
 	__set_bit(IP_TUNNEL_KEY_BIT, flags);
@@ -533,12 +552,13 @@ static void gre_fb_xmit(struct sk_buff *skb, struct net_device *dev,
 	return;
 
 err_free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 }
 
 static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 	struct ip_tunnel_info *tun_info;
@@ -552,29 +572,41 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 
 	key = &tun_info->key;
-	if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags))
+	if (!test_bit(IP_TUNNEL_ERSPAN_OPT_BIT, tun_info->key.tun_flags)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
-	if (tun_info->options_len < sizeof(*md))
+	}
+	if (tun_info->options_len < sizeof(*md)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto err_free_skb;
+	}
 	md = ip_tunnel_info_opts(tun_info);
 
 	/* ERSPAN has fixed 8 byte GRE header */
 	version = md->version;
 	tunnel_hlen = 8 + erspan_hdr_len(version);
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
-	if (gre_handle_offloads(skb, false))
+	if (gre_handle_offloads(skb, false)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto err_free_skb;
+	}
 
 	if (skb->len > dev->mtu + dev->hard_header_len) {
-		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+		if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto err_free_skb;
+		}
 		truncate = true;
 	}
 
@@ -606,6 +638,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 				       truncate, true);
 		proto = htons(ETH_P_ERSPAN2);
 	} else {
+		reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 		goto err_free_skb;
 	}
 
@@ -618,7 +651,7 @@ static void erspan_fb_xmit(struct sk_buff *skb, struct net_device *dev)
 	return;
 
 err_free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 }
 
@@ -652,8 +685,10 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
 	const struct iphdr *tnl_params;
+	enum skb_drop_reason reason;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -664,10 +699,13 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 	if (dev->header_ops) {
 		int pull_len = tunnel->hlen + sizeof(struct iphdr);
 
-		if (skb_cow_head(skb, 0))
+		if (skb_cow_head(skb, 0)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 
-		if (!pskb_may_pull(skb, pull_len))
+		reason = pskb_may_pull_reason(skb, pull_len);
+		if (reason)
 			goto free_skb;
 
 		tnl_params = (const struct iphdr *)skb->data;
@@ -677,25 +715,31 @@ static netdev_tx_t ipgre_xmit(struct sk_buff *skb,
 		skb_reset_mac_header(skb);
 
 		if (skb->ip_summed == CHECKSUM_PARTIAL &&
-		    skb_checksum_start(skb) < skb->data)
+		    skb_checksum_start(skb) < skb->data) {
+			reason = SKB_DROP_REASON_SKB_CSUM;
 			goto free_skb;
+		}
 	} else {
-		if (skb_cow_head(skb, dev->needed_headroom))
+		if (skb_cow_head(skb, dev->needed_headroom)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 
 		tnl_params = &tunnel->parms.iph;
 	}
 
 	ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
 
-	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	__gre_xmit(skb, dev, tnl_params, skb->protocol, flags);
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
@@ -705,10 +749,12 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
+	enum skb_drop_reason reason;
 	bool truncate = false;
 	__be16 proto;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -716,15 +762,21 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 		return NETDEV_TX_OK;
 	}
 
-	if (gre_handle_offloads(skb, false))
+	if (gre_handle_offloads(skb, false)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	if (skb->len > dev->mtu + dev->hard_header_len) {
-		if (pskb_trim(skb, dev->mtu + dev->hard_header_len))
+		if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) {
+			reason = SKB_DROP_REASON_NOMEM;
 			goto free_skb;
+		}
 		truncate = true;
 	}
 
@@ -745,6 +797,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 				       truncate, true);
 		proto = htons(ETH_P_ERSPAN2);
 	} else {
+		reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 		goto free_skb;
 	}
 
@@ -753,7 +806,7 @@ static netdev_tx_t erspan_xmit(struct sk_buff *skb,
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
@@ -763,8 +816,10 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
 {
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	IP_TUNNEL_DECLARE_FLAGS(flags);
+	enum skb_drop_reason reason;
 
-	if (!pskb_inet_may_pull(skb))
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason)
 		goto free_skb;
 
 	if (tunnel->collect_md) {
@@ -774,17 +829,21 @@ static netdev_tx_t gre_tap_xmit(struct sk_buff *skb,
 
 	ip_tunnel_flags_copy(flags, tunnel->parms.o_flags);
 
-	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags)))
+	if (gre_handle_offloads(skb, test_bit(IP_TUNNEL_CSUM_BIT, flags))) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
-	if (skb_cow_head(skb, dev->needed_headroom))
+	if (skb_cow_head(skb, dev->needed_headroom)) {
+		reason = SKB_DROP_REASON_NOMEM;
 		goto free_skb;
+	}
 
 	__gre_xmit(skb, dev, &tunnel->parms.iph, htons(ETH_P_TEB), flags);
 	return NETDEV_TX_OK;
 
 free_skb:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	DEV_STATS_INC(dev, tx_dropped);
 	return NETDEV_TX_OK;
 }
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index 0875474a578a4a..924d02d0cc7bf3 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -384,6 +384,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 		  const struct tnl_ptk_info *tpi, struct metadata_dst *tun_dst,
 		  bool log_ecn_error)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct iphdr *iph = ip_hdr(skb);
 	int nh, err;
 
@@ -398,14 +399,22 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 	    test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
 		DEV_STATS_INC(tunnel->dev, rx_crc_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
+		reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
 		goto drop;
 	}
 
 	if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
-		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
-		    (tunnel->i_seqno && (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
 			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
+			goto drop;
+		}
+		if (tunnel->i_seqno &&
+		    (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;
 			goto drop;
 		}
 		tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -419,7 +428,8 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 
 	skb_set_network_header(skb, (tunnel->dev->type == ARPHRD_ETHER) ? ETH_HLEN : 0);
 
-	if (!pskb_inet_may_pull(skb)) {
+	reason = pskb_inet_may_pull_reason(skb);
+	if (reason) {
 		DEV_STATS_INC(tunnel->dev, rx_length_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
 		goto drop;
@@ -434,6 +444,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 		if (err > 1) {
 			DEV_STATS_INC(tunnel->dev, rx_frame_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
 			goto drop;
 		}
 	}
@@ -457,7 +468,7 @@ int ip_tunnel_rcv(struct ip_tunnel *tunnel, struct sk_buff *skb,
 drop:
 	if (tun_dst)
 		dst_release((struct dst_entry *)tun_dst);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
@@ -575,6 +586,7 @@ static int tnl_update_pmtu(struct net_device *dev, struct sk_buff *skb,
 void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		       u8 proto, int tunnel_hlen)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	u32 headroom = sizeof(struct iphdr);
 	struct ip_tunnel_info *tun_info;
@@ -588,8 +600,10 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	tun_info = skb_tunnel_info(skb);
 	if (unlikely(!tun_info || !(tun_info->mode & IP_TUNNEL_INFO_TX) ||
-		     ip_tunnel_info_af(tun_info) != AF_INET))
+		     ip_tunnel_info_af(tun_info) != AF_INET)) {
+		reason = SKB_DROP_REASON_TUNNEL_TXINFO;
 		goto tx_error;
+	}
 	key = &tun_info->key;
 	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
 	inner_iph = (const struct iphdr *)skb_inner_network_header(skb);
@@ -608,7 +622,8 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (!tunnel_hlen)
 		tunnel_hlen = ip_encap_hlen(&tun_info->encap);
 
-	if (ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4) < 0)
+	reason = ip_tunnel_encap(skb, &tun_info->encap, &proto, &fl4);
+	if (reason)
 		goto tx_error;
 
 	use_cache = ip_tunnel_dst_cache_usable(skb, tun_info);
@@ -618,6 +633,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		rt = ip_route_output_key(tunnel->net, &fl4);
 		if (IS_ERR(rt)) {
 			DEV_STATS_INC(dev, tx_carrier_errors);
+			reason = SKB_DROP_REASON_IP_OUTNOROUTES;
 			goto tx_error;
 		}
 		if (use_cache)
@@ -627,6 +643,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (rt->dst.dev == dev) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, collisions);
+		reason = SKB_DROP_REASON_RECURSION_LIMIT;
 		goto tx_error;
 	}
 
@@ -635,6 +652,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, tunnel_hlen,
 			    key->u.ipv4.dst, true)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_PKT_TOO_BIG;
 		goto tx_error;
 	}
 
@@ -652,6 +670,7 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	headroom += LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len;
 	if (skb_cow_head(skb, headroom)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_NOMEM;
 		goto tx_dropped;
 	}
 
@@ -666,13 +685,14 @@ void ip_md_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 tx_dropped:
 	DEV_STATS_INC(dev, tx_dropped);
 kfree:
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 }
 EXPORT_SYMBOL_GPL(ip_md_tunnel_xmit);
 
 void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		    const struct iphdr *tnl_params, u8 protocol)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip_tunnel *tunnel = netdev_priv(dev);
 	struct ip_tunnel_info *tun_info = NULL;
 	const struct iphdr *inner_iph;
@@ -700,6 +720,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 		if (!skb_dst(skb)) {
 			DEV_STATS_INC(dev, tx_fifo_errors);
+			reason = SKB_DROP_REASON_NO_TX_TARGET;
 			goto tx_error;
 		}
 
@@ -713,9 +734,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 		} else if (payload_protocol == htons(ETH_P_IP)) {
 			rt = skb_rtable(skb);
 			dst = rt_nexthop(rt, inner_iph->daddr);
-		}
 #if IS_ENABLED(CONFIG_IPV6)
-		else if (payload_protocol == htons(ETH_P_IPV6)) {
+		} else if (payload_protocol == htons(ETH_P_IPV6)) {
 			const struct in6_addr *addr6;
 			struct neighbour *neigh;
 			bool do_tx_error_icmp;
@@ -723,8 +743,10 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 			neigh = dst_neigh_lookup(skb_dst(skb),
 						 &ipv6_hdr(skb)->daddr);
-			if (!neigh)
+			if (!neigh) {
+				reason = SKB_DROP_REASON_NEIGH_CREATEFAIL;
 				goto tx_error;
+			}
 
 			addr6 = (const struct in6_addr *)&neigh->primary_key;
 			addr_type = ipv6_addr_type(addr6);
@@ -741,12 +763,15 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 				dst = addr6->s6_addr32[3];
 			}
 			neigh_release(neigh);
-			if (do_tx_error_icmp)
+			if (do_tx_error_icmp) {
+				reason = SKB_DROP_REASON_NO_TX_TARGET;
 				goto tx_error_icmp;
-		}
+			}
 #endif
-		else
+		} else {
+			reason = SKB_DROP_REASON_NO_TX_TARGET;
 			goto tx_error;
+		}
 
 		if (!md)
 			connected = false;
@@ -769,7 +794,8 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 			    tunnel->net, READ_ONCE(tunnel->parms.link),
 			    tunnel->fwmark, skb_get_hash(skb), 0);
 
-	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0)
+	reason = ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4);
+	if (reason)
 		goto tx_error;
 
 	if (connected && md) {
@@ -787,6 +813,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 		if (IS_ERR(rt)) {
 			DEV_STATS_INC(dev, tx_carrier_errors);
+			reason = SKB_DROP_REASON_IP_OUTNOROUTES;
 			goto tx_error;
 		}
 		if (use_cache)
@@ -800,6 +827,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (rt->dst.dev == dev) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, collisions);
+		reason = SKB_DROP_REASON_RECURSION_LIMIT;
 		goto tx_error;
 	}
 
@@ -809,6 +837,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 
 	if (tnl_update_pmtu(dev, skb, rt, df, inner_iph, 0, 0, false)) {
 		ip_rt_put(rt);
+		reason = SKB_DROP_REASON_PKT_TOO_BIG;
 		goto tx_error;
 	}
 
@@ -843,7 +872,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 	if (skb_cow_head(skb, max_headroom)) {
 		ip_rt_put(rt);
 		DEV_STATS_INC(dev, tx_dropped);
-		kfree_skb(skb);
+		kfree_skb_reason(skb, SKB_DROP_REASON_NOMEM);
 		return;
 	}
 
@@ -859,7 +888,7 @@ void ip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev,
 #endif
 tx_error:
 	DEV_STATS_INC(dev, tx_errors);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 }
 EXPORT_SYMBOL_GPL(ip_tunnel_xmit);
 
diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index b5d6ed8f0c3697..eae170ea0ba66d 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -389,8 +389,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	struct tnl_ptk_info tpi;
 	struct ip6_tnl *t;
 
-	if (gre_parse_header(skb, &tpi, NULL, htons(ETH_P_IPV6),
-			     offset) < 0)
+	if (gre_parse_header(skb, &tpi, true, htons(ETH_P_IPV6),
+			     offset))
 		return -EINVAL;
 
 	ipv6h = (const struct ipv6hdr *)skb->data;
@@ -451,7 +451,8 @@ static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
 	return 0;
 }
 
-static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
+static enum skb_drop_reason ip6gre_rcv(struct sk_buff *skb,
+				       const struct tnl_ptk_info *tpi)
 {
 	const struct ipv6hdr *ipv6h;
 	struct ip6_tnl *tunnel;
@@ -471,31 +472,33 @@ static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi)
 
 			tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id, 0);
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			ip6_tnl_rcv(tunnel, skb, tpi, tun_dst, log_ecn_error);
 		} else {
 			ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
 		}
 
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
 
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 }
 
-static int ip6erspan_rcv(struct sk_buff *skb,
-			 struct tnl_ptk_info *tpi,
-			 int gre_hdr_len)
+static enum skb_drop_reason ip6erspan_rcv(struct sk_buff *skb,
+					  struct tnl_ptk_info *tpi,
+					  int gre_hdr_len)
 {
 	struct erspan_base_hdr *ershdr;
 	const struct ipv6hdr *ipv6h;
+	enum skb_drop_reason reason;
 	struct erspan_md2 *md2;
 	struct ip6_tnl *tunnel;
 	u8 ver;
 
-	if (unlikely(!pskb_may_pull(skb, sizeof(*ershdr))))
-		return PACKET_REJECT;
+	reason = pskb_may_pull_reason(skb, sizeof(*ershdr));
+	if (unlikely(reason))
+		return reason;
 
 	ipv6h = ipv6_hdr(skb);
 	ershdr = (struct erspan_base_hdr *)skb->data;
@@ -507,13 +510,14 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 	if (tunnel) {
 		int len = erspan_hdr_len(ver);
 
-		if (unlikely(!pskb_may_pull(skb, len)))
-			return PACKET_REJECT;
+		reason = pskb_may_pull_reason(skb, len);
+		if (unlikely(reason))
+			return reason;
 
-		if (__iptunnel_pull_header(skb, len,
-					   htons(ETH_P_TEB),
-					   false, false))
-			return PACKET_REJECT;
+		reason = __iptunnel_pull_header(skb, len, htons(ETH_P_TEB),
+						false, false);
+		if (reason)
+			return reason;
 
 		if (tunnel->parms.collect_md) {
 			struct erspan_metadata *pkt_md, *md;
@@ -530,7 +534,7 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 			tun_dst = ipv6_tun_rx_dst(skb, flags, tun_id,
 						  sizeof(*md));
 			if (!tun_dst)
-				return PACKET_REJECT;
+				return SKB_DROP_REASON_NOMEM;
 
 			/* MUST set options_len before referencing options */
 			info = &tun_dst->u.tun_info;
@@ -558,40 +562,42 @@ static int ip6erspan_rcv(struct sk_buff *skb,
 			ip6_tnl_rcv(tunnel, skb, tpi, NULL, log_ecn_error);
 		}
 
-		return PACKET_RCVD;
+		return SKB_NOT_DROPPED_YET;
 	}
 
-	return PACKET_REJECT;
+	return SKB_DROP_REASON_TUNNEL_NOT_FOUND;
 }
 
 static int gre_rcv(struct sk_buff *skb)
 {
+	enum skb_drop_reason reason;
 	struct tnl_ptk_info tpi;
-	bool csum_err = false;
-	int hdr_len;
 
-	hdr_len = gre_parse_header(skb, &tpi, &csum_err, htons(ETH_P_IPV6), 0);
-	if (hdr_len < 0)
+	reason = gre_parse_header(skb, &tpi, false, htons(ETH_P_IPV6), 0);
+	if (reason)
 		goto drop;
 
-	if (iptunnel_pull_header(skb, hdr_len, tpi.proto, false))
+	reason = iptunnel_pull_header(skb, tpi.hdr_len, tpi.proto, false);
+	if (reason)
 		goto drop;
 
 	if (unlikely(tpi.proto == htons(ETH_P_ERSPAN) ||
 		     tpi.proto == htons(ETH_P_ERSPAN2))) {
-		if (ip6erspan_rcv(skb, &tpi, hdr_len) == PACKET_RCVD)
+		reason = ip6erspan_rcv(skb, &tpi, tpi.hdr_len);
+		if (!reason)
 			return 0;
 		goto out;
 	}
 
-	if (ip6gre_rcv(skb, &tpi) == PACKET_RCVD)
+	reason = ip6gre_rcv(skb, &tpi);
+	if (!reason)
 		return 0;
 
 out:
 	icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
 drop:
 	dev_core_stats_rx_dropped_inc(skb->dev);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 64a184bca46772..4912b08228a15a 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -813,6 +813,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 						struct sk_buff *skb),
 			 bool log_ecn_err)
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	const struct ipv6hdr *ipv6h;
 	int nh, err;
 
@@ -820,15 +821,22 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 	    test_bit(IP_TUNNEL_CSUM_BIT, tpi->flags)) {
 		DEV_STATS_INC(tunnel->dev, rx_crc_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
+		reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
 		goto drop;
 	}
 
 	if (test_bit(IP_TUNNEL_SEQ_BIT, tunnel->parms.i_flags)) {
-		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags) ||
-		    (tunnel->i_seqno &&
-		     (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0)) {
+		if (!test_bit(IP_TUNNEL_SEQ_BIT, tpi->flags)) {
 			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OPT_MISMATCH;
+			goto drop;
+		}
+		if (tunnel->i_seqno &&
+		    (s32)(ntohl(tpi->seq) - tunnel->i_seqno) < 0) {
+			DEV_STATS_INC(tunnel->dev, rx_fifo_errors);
+			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_TUNNEL_OLD_SEQ;
 			goto drop;
 		}
 		tunnel->i_seqno = ntohl(tpi->seq) + 1;
@@ -838,7 +846,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 
 	/* Warning: All skb pointers will be invalidated! */
 	if (tunnel->dev->type == ARPHRD_ETHER) {
-		if (!pskb_may_pull(skb, ETH_HLEN)) {
+		reason = pskb_may_pull_reason(skb, ETH_HLEN);
+		if (reason) {
 			DEV_STATS_INC(tunnel->dev, rx_length_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
 			goto drop;
@@ -859,7 +868,8 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 
 	skb_reset_network_header(skb);
 
-	if (skb_vlan_inet_prepare(skb, true)) {
+	reason = skb_vlan_inet_prepare(skb, true);
+	if (reason) {
 		DEV_STATS_INC(tunnel->dev, rx_length_errors);
 		DEV_STATS_INC(tunnel->dev, rx_errors);
 		goto drop;
@@ -881,6 +891,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 		if (err > 1) {
 			DEV_STATS_INC(tunnel->dev, rx_frame_errors);
 			DEV_STATS_INC(tunnel->dev, rx_errors);
+			reason = SKB_DROP_REASON_IP_TUNNEL_ECN;
 			goto drop;
 		}
 	}
@@ -898,7 +909,7 @@ static int __ip6_tnl_rcv(struct ip6_tnl *tunnel, struct sk_buff *skb,
 drop:
 	if (tun_dst)
 		dst_release((struct dst_entry *)tun_dst);
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
@@ -941,6 +952,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 						  const struct ipv6hdr *ipv6h,
 						  struct sk_buff *skb))
 {
+	enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
 	struct ip6_tnl *t;
 	const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
 	struct metadata_dst *tun_dst = NULL;
@@ -952,21 +964,30 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 	if (t) {
 		u8 tproto = READ_ONCE(t->parms.proto);
 
-		if (tproto != ipproto && tproto != 0)
+		if (tproto != ipproto && tproto != 0) {
+			reason = SKB_DROP_REASON_UNHANDLED_PROTO;
 			goto drop;
-		if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+		}
+		if (!xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+			reason = SKB_DROP_REASON_XFRM_POLICY;
 			goto drop;
+		}
 		ipv6h = ipv6_hdr(skb);
-		if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr))
+		if (!ip6_tnl_rcv_ctl(t, &ipv6h->daddr, &ipv6h->saddr)) {
+			reason = SKB_DROP_REASON_NOT_SPECIFIED;
 			goto drop;
-		if (iptunnel_pull_header(skb, 0, tpi->proto, false))
+		}
+		reason = iptunnel_pull_header(skb, 0, tpi->proto, false);
+		if (reason)
 			goto drop;
 		if (t->parms.collect_md) {
 			IP_TUNNEL_DECLARE_FLAGS(flags) = { };
 
 			tun_dst = ipv6_tun_rx_dst(skb, flags, 0, 0);
-			if (!tun_dst)
+			if (!tun_dst) {
+				reason = SKB_DROP_REASON_NOMEM;
 				goto drop;
+			}
 		}
 		ret = __ip6_tnl_rcv(t, skb, tpi, tun_dst, dscp_ecn_decapsulate,
 				    log_ecn_error);
@@ -978,7 +999,7 @@ static int ipxip6_rcv(struct sk_buff *skb, u8 ipproto,
 
 drop:
 	rcu_read_unlock();
-	kfree_skb(skb);
+	kfree_skb_reason(skb, reason);
 	return 0;
 }
 
diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index a7ec800216ade1..9576d146c96143 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -1096,7 +1096,7 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
 		ttl = iph6->hop_limit;
 	tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
 
-	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4) < 0) {
+	if (ip_tunnel_encap(skb, &tunnel->encap, &protocol, &fl4)) {
 		ip_rt_put(rt);
 		goto tx_error;
 	}

35/3 2026/11/14 05:16 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 20396
							output: 39
							thoughts: 1154
						

Thoughts:
**Analyzing the Patch for KMSAN Fuzzing Justification**

Okay, so the task is to assess this patch series and determine if it warrants a dedicated KMSAN fuzzing session. My first step is to thoroughly understand what the patch actually *does*.

Right, so, looking at the code changes, it appears this patch series is focused on instrumenting the network tunnel receive and transmit paths, specifically dealing with GRE, IP tunnels, ERSPAN, and SIT. It's moving away from the more generic `kfree_skb` and instead leveraging `skb_drop_reason` throughout. The aim is to provide more granular information on *why* a packet is being dropped, instead of just the fact that it *was* dropped, and to use `kfree_skb_reason` to inform the freeing of the skb. The existing return codes (e.g., success/fail integers) are being replaced with the `enum skb_drop_reason` and propagated to the freeing function.

Now, from a KMSAN perspective, my immediate concern is potential uninitialized memory risks introduced by this change. The replacement of return codes needs careful scrutiny. Let's look at the critical function:

This function is particularly interesting. Previously, it returned an integer (`int`), likely related to the header length. On success, it returned the length; on error, a negative error code (e.g., `-EINVAL`). The code contained a `pskb_may_pull` to ensure sufficient data was present in the skb. The original code included checks and returned an error code such as `-EINVAL`. This error code likely was used to signal that the data being pulled wasn't available in the skb, causing the caller to exit.

The patch has converted this function to return an `enum skb_drop_reason`. But wait - where does that calculated header length, `hdr_len`, now go? The original code did an early return on the data check:

Now, it returns `SKB_NOT_DROPPED_YET`. Is `tpi->hdr_len` being updated anywhere? This is a key question! If not, any code that relies on `hdr_len` (and used to be passed to it) will now have garbage, uninitialized data, and be subject to uninitialized memory use. I'll need to meticulously read `gre_demux.c` lines 50-160, specifically to see how the caller of `gre_parse_header` uses the `tpi` struct and whether the caller assumes `tpi->hdr_len` is initialized somewhere. A full understanding is needed to determine if this new patch does anything with the hdr length, or if the code still relies on it. I need to be sure that the callers of `gre_parse_header` don't rely on it. A grep would be a good tool here to see what `hdr_len` is used for now.


36/3 2026/11/14 05:16 tool read-file
0m Args:
{
  "File": "net/ipv4/gre_demux.c",
  "FirstLine": 56,
  "LineCount": 100
}

Results:
{
  "Contents": "  56:\t}\n  57:\tEXPORT_SYMBOL_GPL(gre_del_protocol);\n  58:\t\n  59:\t/**\n  60:\t * gre_parse_header() - parse the GRE header of a packet\n  61:\t * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n  62:\t * @tpi: filled in with the fields of the header, and with the length of\n  63:\t *\tthe header to be pulled in tpi-\u003ehdr_len\n  64:\t * @ignore_csum_err: do not reject the header when its checksum does not\n  65:\t *\tmatch. The ICMP error handlers set it, as they only get a part of the\n  66:\t *\toriginal packet; the checksum is still computed and the rest of the\n  67:\t *\theader is parsed.\n  68:\t * @proto: the protocol to report for a WCCP payload, ETH_P_IP or\n  69:\t *\tETH_P_IPV6\n  70:\t * @nhs: the offset of the GRE header from skb-\u003edata\n  71:\t *\n  72:\t * The caller must use pskb_may_pull() before pulling the GRE header.\n  73:\t *\n  74:\t * Return: SKB_NOT_DROPPED_YET, or the reason to drop the packet if the\n  75:\t * header is rejected.\n  76:\t */\n  77:\tenum skb_drop_reason\n  78:\tgre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\n  79:\t\t\t bool ignore_csum_err, __be16 proto, int nhs)\n  80:\t{\n  81:\t\tconst struct gre_base_hdr *greh;\n  82:\t\tenum skb_drop_reason reason;\n  83:\t\t__be32 *options;\n  84:\t\tint hdr_len;\n  85:\t\n  86:\t\treason = pskb_may_pull_reason(skb, nhs + sizeof(struct gre_base_hdr));\n  87:\t\tif (unlikely(reason))\n  88:\t\t\treturn reason;\n  89:\t\n  90:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n  91:\t\tif (unlikely(greh-\u003eflags \u0026 (GRE_VERSION | GRE_ROUTING)))\n  92:\t\t\treturn SKB_DROP_REASON_TUNNEL_INVALID_HDR;\n  93:\t\n  94:\t\tgre_flags_to_tnl_flags(tpi-\u003eflags, greh-\u003eflags);\n  95:\t\thdr_len = gre_calc_hlen(tpi-\u003eflags);\n  96:\t\n  97:\t\treason = pskb_may_pull_reason(skb, nhs + hdr_len);\n  98:\t\tif (reason)\n  99:\t\t\treturn reason;\n 100:\t\n 101:\t\tgreh = (struct gre_base_hdr *)(skb-\u003edata + nhs);\n 102:\t\ttpi-\u003eproto = greh-\u003eprotocol;\n 103:\t\n 104:\t\toptions = (__be32 *)(greh + 1);\n 105:\t\tif (greh-\u003eflags \u0026 GRE_CSUM) {\n 106:\t\t\tif (!skb_checksum_simple_validate(skb)) {\n 107:\t\t\t\tskb_checksum_try_convert(skb, IPPROTO_GRE,\n 108:\t\t\t\t\t\t\t null_compute_pseudo);\n 109:\t\t\t} else if (!ignore_csum_err) {\n 110:\t\t\t\treturn SKB_DROP_REASON_GRE_CSUM;\n 111:\t\t\t}\n 112:\t\n 113:\t\t\toptions++;\n 114:\t\t}\n 115:\t\n 116:\t\tif (greh-\u003eflags \u0026 GRE_KEY) {\n 117:\t\t\ttpi-\u003ekey = *options;\n 118:\t\t\toptions++;\n 119:\t\t} else {\n 120:\t\t\ttpi-\u003ekey = 0;\n 121:\t\t}\n 122:\t\tif (unlikely(greh-\u003eflags \u0026 GRE_SEQ)) {\n 123:\t\t\ttpi-\u003eseq = *options;\n 124:\t\t\toptions++;\n 125:\t\t} else {\n 126:\t\t\ttpi-\u003eseq = 0;\n 127:\t\t}\n 128:\t\t/* WCCP version 1 and 2 protocol decoding.\n 129:\t\t * - Change protocol to IPv4/IPv6\n 130:\t\t * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header\n 131:\t\t */\n 132:\t\tif (greh-\u003eflags == 0 \u0026\u0026 tpi-\u003eproto == htons(ETH_P_WCCP)) {\n 133:\t\t\tu8 _val, *val;\n 134:\t\n 135:\t\t\tval = skb_header_pointer(skb, nhs + hdr_len,\n 136:\t\t\t\t\t\t sizeof(_val), \u0026_val);\n 137:\t\t\tif (!val)\n 138:\t\t\t\treturn SKB_DROP_REASON_PKT_TOO_SMALL;\n 139:\t\t\ttpi-\u003eproto = proto;\n 140:\t\t\tif ((*val \u0026 0xF0) != 0x40)\n 141:\t\t\t\thdr_len += 4;\n 142:\t\t}\n 143:\t\ttpi-\u003ehdr_len = hdr_len;\n 144:\t\n 145:\t\t/* ERSPAN ver 1 and 2 protocol sets GRE key field\n 146:\t\t * to 0 and sets the configured key in the\n 147:\t\t * inner erspan header field\n 148:\t\t */\n 149:\t\tif ((greh-\u003eprotocol == htons(ETH_P_ERSPAN) \u0026\u0026 hdr_len != 4) ||\n 150:\t\t    greh-\u003eprotocol == htons(ETH_P_ERSPAN2)) {\n 151:\t\t\tstruct erspan_base_hdr *ershdr;\n 152:\t\n 153:\t\t\treason = pskb_may_pull_reason(skb,\n 154:\t\t\t\t\t\t      nhs + hdr_len + sizeof(*ershdr));\n 155:\t\t\tif (reason)\n"
}

37/3 2026/11/14 05:16 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23834
							output: 19
							thoughts: 54
						

Thoughts:
**Checking for Function Call Updates**

Okay, so I just set `tpi->hdr_len = hdr_len;` on line 143. Now, the critical question is, did I catch everything? Specifically, are all the calls to `gre_parse_header` in this code base updated to reflect the change I just made? It’s a classic gotcha—I need to make absolutely sure no stale calls are floating around. Best practice dictates a quick double-check. Time to fire up the grep command and verify all instances of `gre_parse_header` and make sure the change is reflected everywhere it is called. Don't want any missed cases causing silent bugs down the road!



38/3 2026/11/14 05:16 tool grepper
0m Args:
{
  "Expression": "gre_parse_header"
}

Results:
{
  "Output": "include/net/gre.h=35=enum skb_drop_reason\ninclude/net/gre.h:36:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\ninclude/net/gre.h-37-\t\t bool ignore_csum_err, __be16 proto, int nhs);\n--\nnet/ipv4/gre_demux.c=57=EXPORT_SYMBOL_GPL(gre_del_protocol);\n--\nnet/ipv4/gre_demux.c-59-/**\nnet/ipv4/gre_demux.c:60: * gre_parse_header() - parse the GRE header of a packet\nnet/ipv4/gre_demux.c-61- * @skb: the packet; the GRE header starts @nhs bytes past skb-\u003edata\n--\nnet/ipv4/gre_demux.c=77=enum skb_drop_reason\nnet/ipv4/gre_demux.c:78:gre_parse_header(struct sk_buff *skb, struct tnl_ptk_info *tpi,\nnet/ipv4/gre_demux.c-79-\t\t bool ignore_csum_err, __be16 proto, int nhs)\n--\nnet/ipv4/gre_demux.c-163-}\nnet/ipv4/gre_demux.c:164:EXPORT_SYMBOL(gre_parse_header);\nnet/ipv4/gre_demux.c-165-\n--\nnet/ipv4/ip_gre.c=219=static void gre_err(struct sk_buff *skb, u32 info)\n--\nnet/ipv4/ip_gre.c-239-\nnet/ipv4/ip_gre.c:240:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IP),\nnet/ipv4/ip_gre.c-241-\t\t\t     iph-\u003eihl * 4))\n--\nnet/ipv4/ip_gre.c=449=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv4/ip_gre.c-463-\nnet/ipv4/ip_gre.c:464:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IP), 0);\nnet/ipv4/ip_gre.c-465-\tif (reason)\n--\nnet/ipv6/ip6_gre.c=384=static int ip6gre_err(struct sk_buff *skb, struct inet6_skb_parm *opt,\n--\nnet/ipv6/ip6_gre.c-391-\nnet/ipv6/ip6_gre.c:392:\tif (gre_parse_header(skb, \u0026tpi, true, htons(ETH_P_IPV6),\nnet/ipv6/ip6_gre.c-393-\t\t\t     offset))\n--\nnet/ipv6/ip6_gre.c=571=static int gre_rcv(struct sk_buff *skb)\n--\nnet/ipv6/ip6_gre.c-575-\nnet/ipv6/ip6_gre.c:576:\treason = gre_parse_header(skb, \u0026tpi, false, htons(ETH_P_IPV6), 0);\nnet/ipv6/ip6_gre.c-577-\tif (reason)\n"
}

39/3 2026/11/14 05:16 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 24930
							output: 23
							thoughts: 655
						

Thoughts:
**Analyzing Calls to `gre_parse_header`**

Okay, let's break down how `gre_parse_header` is being used within this code base. My initial observation is that it's called from several key points within the GRE and IPv6 GRE handling logic. Specifically, I'm seeing it used in:

1.  `ip_gre.c: gre_err`: This looks to be handling some error path, where the function is called with a boolean flag set to `true` and specifically expecting an IPv4 encapsulated payload (`ETH_P_IP`). The `iph->ihl * 4` suggests this function is being called with an offset from the IP header length. The return here is a simple `return;` if `gre_parse_header` succeeds, which suggests a possible early exit or no further handling is required if parsing is successful.
2.  `ip_gre.c: gre_rcv`: This is the main receive path for IPv4 GRE traffic. Here, `gre_parse_header` is called to parse the header. The boolean flag is set to `false`. Crucially, it then checks the parsed `tpi` for `ETH_P_ERSPAN` or `ETH_P_ERSPAN2` and offloads the handling to dedicated ERSPAN functions if it's the case. Otherwise, it proceeds to the `ipgre_rcv` function.
3.  `ip6_gre.c: ip6gre_err`: Similar to the IPv4 error path, this handles IPv6 error cases. The boolean flag is `true`, the protocol expected is `ETH_P_IPV6`, and an offset is provided, suggesting a possible context where we know about IPv6 headers. A non-zero return value results in an error being indicated.
4.  `ip6_gre.c: gre_rcv`: Again, the primary receive path, but for IPv6 encapsulated GRE traffic. The flag is set to `false`. After the initial `gre_parse_header` call, it calls `iptunnel_pull_header` and then, similar to the IPv4 path, checks for ERSPAN traffic and branches to dedicated ERSPAN handling if necessary, otherwise the main `ip6gre_rcv` function handles it.

My immediate thought is, let's ensure that the `tpi` struct, passed by pointer, is consistently and correctly initialized by `gre_parse_header` *when it succeeds*. This is paramount for the downstream logic to function correctly. I need to be sure all the fields of this `tpi` struct are properly set after a successful parse. I need to inspect the `tnl_ptk_info` struct definition itself to be certain what it contains and how those fields are being used.



40/3 2026/11/14 05:16 tool grepper
0m Args:
{
  "Expression": "struct tnl_ptk_info \\{"
}

Results:
{
  "Output": "include/net/ip_tunnels.h=155=struct ip_tunnel {\n--\ninclude/net/ip_tunnels.h-201-\ninclude/net/ip_tunnels.h:202:struct tnl_ptk_info {\ninclude/net/ip_tunnels.h-203-\tIP_TUNNEL_DECLARE_FLAGS(flags);\n"
}

41/3 2026/11/14 05:16 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26302
							output: 38
							thoughts: 23
						

Thoughts:
Okay, let's dive into this. Here's my thought process on the matter:

**Analyzing `include/net/ip_tunnels.h` Around Line 202**

Alright, I need to get my bearings. The text directs me to `include/net/ip_tunnels.h`, and specifically around line 202. Immediately, my mind starts to churn through what I *expect* to find in that region. Given the filename, I'm anticipating tunnel-related definitions – likely structures, constants, and maybe some inline function prototypes concerning IP tunnels. I'll be looking for clues about the data structures used to represent tunnel interfaces, the types of tunneling protocols supported, and potentially any internal flags or control parameters that are relevant at that level. I wonder if there are any specific structures or enums that pertain to VXLAN, GRE, or other common tunneling mechanisms. I'll need to pay close attention to the field sizes and their interpretations, because that will directly impact performance and overhead. It's also possible that there are relevant function declarations related to the encapsulation or decapsulation processes. Line 202 could be a declaration, a struct member, or a macro definition and it'll all depend on the context of the surrounding code. Time to dig in and see what treasures this file holds.



42/3 2026/11/14 05:16 tool read-file
0m Args:
{
  "File": "include/net/ip_tunnels.h",
  "FirstLine": 200,
  "LineCount": 20
}

Results:
{
  "Contents": " 200:\t};\n 201:\t\n 202:\tstruct tnl_ptk_info {\n 203:\t\tIP_TUNNEL_DECLARE_FLAGS(flags);\n 204:\t\t__be16 proto;\n 205:\t\t__be32 key;\n 206:\t\t__be32 seq;\n 207:\t\tint hdr_len;\n 208:\t};\n 209:\t\n 210:\t#define IP_TNL_HASH_BITS   7\n 211:\t#define IP_TNL_HASH_SIZE   (1 \u003c\u003c IP_TNL_HASH_BITS)\n 212:\t\n 213:\tstruct ip_tunnel_net {\n 214:\t\tstruct net_device *fb_tunnel_dev;\n 215:\t\tstruct rtnl_link_ops *rtnl_link_ops;\n 216:\t\tstruct hlist_head tunnels[IP_TNL_HASH_SIZE];\n 217:\t\tstruct mutex tunnels_lock;\n 218:\t\tstruct ip_tunnel __rcu *collect_md_tun;\n 219:\t\tint type;\n"
}

43/3 2026/11/14 05:16 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26947
							output: 324
							thoughts: 2991
						

Thoughts:
**Analysis of GRE Tunnel Error Handling and KMSAN Applicability**

Okay, let's break this down. My goal is to determine if this patch necessitates a KMSAN (Kernel Memory Sanitizer) check. The core of this patch seems to be refactoring how GRE (Generic Routing Encapsulation), IP tunnel, ERSPAN (Encapsulated Remote SPAN), and SIT (Simple Internet Tunnel) code handles errors. Specifically, it's about shifting from generic error codes and direct `kfree_skb()` calls to using granular `skb_drop_reason` enums and the `kfree_skb_reason()` function. This is a pretty straightforward conversion, but we need to ensure it's done safely.

My initial thought process immediately focuses on the `struct tnl_ptk_info`, and how its fields are populated and accessed. If `gre_parse_header` returns an error, the code *should* bail out *before* using the values it populates.  I meticulously traced the uses of `gre_parse_header` in functions like `gre_err`, `gre_rcv`, `ip6gre_err`, and `ip6_gre.c: gre_rcv`, making sure that the flow control correctly exits or drops the packets if `gre_parse_header` fails. I was looking for any case where `tpi` was accessed after a failing return code. I confirmed that the values are only used when the function returns 0 (success). This suggests there's no inherent risk of using uninitialized memory within this context.

My next step involved a deep dive into the definition and usage of the `reason` variable, which is now the crucial element in `kfree_skb_reason()`. I needed to absolutely confirm that `reason` is *always* initialized before being passed to `kfree_skb_reason()`. I exhaustively examined its definition and usage in various files (`net/ipv4/gre_demux.c`, `net/ipv4/ip_gre.c`, `net/ipv4/ip_tunnel.c`, `net/ipv6/ip6_gre.c`, and `net/ipv6/ip6_tunnel.c`), going through every single branch of the code. In each case, I confirmed that `reason` is either initialized to a specific value upfront (e.g., `SKB_DROP_REASON_NOT_SPECIFIED`) or assigned a value from a function call or a conditional branch *before* being used in `kfree_skb_reason()`. I made double and triple sure.

Now, the crucial question: Does this patch introduce a *risk* that *only* KMSAN could detect? KMSAN's purpose is to find uninitialized memory reads. This patch doesn't introduce any new structures that need allocation or reading. All variables, especially the new drop reason variable, are properly initialized. There are no direct copies of data from the kernel space to the user space; no new system calls, netlink, or ioctls are being introduced that could expose uninitialized kernel memory. The changes are focused on control flow and error reporting within the kernel, making sure packets are dropped safely and providing better information about the drops. The patch simply moves the error handling around. The fact that any bounds or offset errors in parsing headers, etc. are detectable with the usual KASAN checks is reassuring.

Given all this, according to the guideline "Set NeedsKMSAN=false IF: ... All stack/heap structures touched or introduced by the patch are fully zeroed or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied. ... The patch does not introduce any risk of uninitialized memory usage or info-leaks." and the "Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN, LOCKDEP, OR OTHER STANDARD BUG DETECTORS.", the answer is very clear. **NeedsKMSAN should be set to `false` here.** I have demonstrated that this patch does not introduce any scenario where KMSAN would be necessary.



44/3 2026/11/14 05:17 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch series introduces detailed skb drop reasons (enum skb_drop_reason) and replaces kfree_skb() with kfree_skb_reason() across IPv4 and IPv6 GRE, ERSPAN, and generic IP tunnel receive and transmit paths.\n\nKMSAN vs KASAN Applicability:\n1. No uninitialized memory or info-leak risks: The patch does not expose any uninitialized data or kernel memory to user space (no copy_to_user, netlink attributes, ioctl output, or socket options are introduced or modified). Drop reasons are internal kernel tracepoint arguments passed to kfree_skb_reason().\n2. Variable initialization: All newly introduced local variables (e.g., `enum skb_drop_reason reason`) are either initialized at declaration or explicitly assigned along every code path prior to being read or passed to kfree_skb_reason().\n3. Data structures: The `struct tnl_ptk_info tpi` parsed by `gre_parse_header()` has all relevant fields populated on success and is not read on failure paths. No new heap/stack allocations or complex structures are created.\n4. Any potential bugs in header bounds calculation or parsing would manifest as buffer overruns or invalid pointer dereferences, which are covered by KASAN and standard sanitizers rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch series introduces detailed skb drop reasons (enum skb_drop_reason) and replaces kfree_skb() with kfree_skb_reason() across IPv4 and IPv6 GRE, ERSPAN, and generic IP tunnel receive and transmit paths.\n\nKMSAN vs KASAN Applicability:\n1. No uninitialized memory or info-leak risks: The patch does not expose any uninitialized data or kernel memory to user space (no copy_to_user, netlink attributes, ioctl output, or socket options are introduced or modified). Drop reasons are internal kernel tracepoint arguments passed to kfree_skb_reason().\n2. Variable initialization: All newly introduced local variables (e.g., `enum skb_drop_reason reason`) are either initialized at declaration or explicitly assigned along every code path prior to being read or passed to kfree_skb_reason().\n3. Data structures: The `struct tnl_ptk_info tpi` parsed by `gre_parse_header()` has all relevant fields populated on success and is not read on failure paths. No new heap/stack allocations or complex structures are created.\n4. Any potential bugs in header bounds calculation or parsing would manifest as buffer overruns or invalid pointer dereferences, which are covered by KASAN and standard sanitizers rather than KMSAN.\n\nTherefore, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)