| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/07 14:34 | flow | patch-triage |
5mArgs:null Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"INET",
"IPV6",
"TLS",
"IP_SCTP"
],
"FocusSymbols": [
"skb_segment",
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_checksum_help",
"skb_crc32c_csum_help",
"skb_zerocopy",
"skb_try_coalesce",
"skb_copy_and_csum_dev",
"__skb_gro_checksum_complete"
],
"KMSANReasoning": "The patch series refactors skb checksumming and copying functions (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits) to return proper error codes rather than silently returning 0 upon failure or hitting BUG_ONs. It also improves bounds checking and error handling across skb segmentation (skb_segment), coalescing (skb_try_coalesce), and zerocopy logic to handle malformed or truncated skb frag lists gracefully.\n\nRegarding uninitialized memory:\n- All checksum output variables passed by reference across callers (e.g. in dev.c, gro.c, icmp.c, ip_output.c, skbuff.c) are either explicitly initialized (e.g., `__wsum csum = 0;`, `u32 crc = ~0;`) or guarded by `__must_check` return codes that trigger immediate error returns or packet drops prior to any use of the checksum value.\n- In partial failure scenarios within `skb_copy_and_csum_bits`, `skb_copy_and_csum_frag_list`, and `skb_copy_and_csum_dev`, destination buffers are defensively zeroed via `memset` to prevent leaving stale or uninitialized bytes in copied buffers.\n- No kernel-to-user copy paths (such as netlink, ioctl, or socket options) or uninitialized struct padding are exposed.\n\nThe failure modes touched by this patch series involve buffer boundaries, length calculations, list iteration, and NULL checks—risks such as out-of-bounds reads/writes, pointer invalidation, and assertions that are directly covered by KASAN and net debugging checks. A dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false,
"Reasoning": "The patch introduces extensive error-propagation and sanity checks across core networking skb operations (skb_segment, skb_checksum_full, skb_copy_and_csum_bits, skb_crc32c_full, skb_try_coalesce, skb_zerocopy). It modifies skb segmentation and checksumming logic, alters return signatures, and adds multiple DEBUG_NET_WARN_ON_ONCE invariant checks in reachable core networking execution paths. Fuzzing is warranted to verify that complex skb geometries (e.g. frag lists, non-linear buffers, GSO/GRO) do not trigger new assertions, regressions, or edge-case fault conditions.",
"WorthFuzzing": true
} |
| 1/1 | 2026/11/07 14:34 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 7eab7c1eee34f51ba1f3d4538574f0ac9fb72156\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Sat Nov 7 14:34:09 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethernet/sun/sunvnet_common.c\nindex 5cca958690521f..4f229fcecc32f1 100644\n--- a/drivers/net/ethernet/sun/sunvnet_common.c\n+++ b/drivers/net/ethernet/sun/sunvnet_common.c\n@@ -1167,9 +1167,13 @@ static inline struct sk_buff *vnet_skb_shape(struct sk_buff *skb, int ncookies)\n \n \t\t\t/* copy the rest, with csum calculation */\n \t\t\t*(__sum16 *)(skb-\u003edata + offset) = 0;\n-\t\t\tcsum = skb_copy_and_csum_bits(skb, start,\n-\t\t\t\t\t\t nskb-\u003edata + start,\n-\t\t\t\t\t\t skb-\u003elen - start);\n+\t\t\tif (skb_copy_and_csum_bits(skb, start,\n+\t\t\t\t\t\t nskb-\u003edata + start,\n+\t\t\t\t\t\t skb-\u003elen - start, \u0026csum)) {\n+\t\t\t\tdev_kfree_skb(nskb);\n+\t\t\t\tdev_kfree_skb(skb);\n+\t\t\t\treturn NULL;\n+\t\t\t}\n \n \t\t\t/* add in the header checksums */\n \t\t\tif (skb-\u003eprotocol == htons(ETH_P_IP)) {\ndiff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c\nindex fdcb91042f2906..17811d81937c6e 100644\n--- a/drivers/net/xen-netfront.c\n+++ b/drivers/net/xen-netfront.c\n@@ -695,7 +695,12 @@ static struct sk_buff *bounce_skb(const struct sk_buff *skb)\n \t/* Set the tail pointer and length */\n \tskb_put(n, skb-\u003elen);\n \n-\tBUG_ON(skb_copy_bits(skb, -headerlen, n-\u003ehead, headerlen + skb-\u003elen));\n+\tif (unlikely(skb_copy_bits(skb, -headerlen, n-\u003ehead,\n+\t\t\t\t headerlen + skb-\u003elen))) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\tkfree_skb(n);\n+\t\treturn NULL;\n+\t}\n \n \tskb_copy_header(n, skb);\n \treturn n;\ndiff --git a/include/linux/skbuff.h b/include/linux/skbuff.h\nindex 6787fcf6ac3e43..5581ed3cbf479d 100644\n--- a/include/linux/skbuff.h\n+++ b/include/linux/skbuff.h\n@@ -4280,8 +4280,10 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb);\n int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);\n int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);\n int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);\n-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,\n-\t\t\t int len);\n+int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n+\t\t\t\t\tu8 *to, int len, __wsum *csump);\n+int __must_check skb_checksum_full(const struct sk_buff *skb, int offset,\n+\t\t\t\t int len, __wsum *csump);\n int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,\n \t\t struct pipe_inode_info *pipe, unsigned int len,\n \t\t unsigned int flags);\n@@ -4330,6 +4332,8 @@ static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)\n \n __wsum skb_checksum(const struct sk_buff *skb, int offset, int len,\n \t\t __wsum csum);\n+int __must_check skb_crc32c_full(const struct sk_buff *skb, int offset,\n+\t\t\t\t int len, u32 *crcp);\n u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc);\n \n static inline void * __must_check\n@@ -4890,7 +4894,7 @@ static inline void skb_checksum_complete_unset(struct sk_buff *skb)\n * 0: checksum is validated or try to in skb_checksum_complete. In the latter\n *\tcase the ip_summed will not be CHECKSUM_UNNECESSARY and the pseudo\n *\tchecksum is stored in skb-\u003ecsum for use in __skb_checksum_complete\n- * non-zero: value of invalid checksum\n+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed\n *\n */\n static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,\n@@ -4930,7 +4934,7 @@ static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)\n *\n * Return values:\n * 0: checksum is validated or try to in skb_checksum_complete\n- * non-zero: value of invalid checksum\n+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed\n */\n #define __skb_checksum_validate(skb, proto, complete,\t\t\t\\\n \t\t\t\tzero_okay, check, compute_pseudo)\t\\\ndiff --git a/net/core/dev.c b/net/core/dev.c\nindex 3ac700d37e596f..f9878db781df7c 100644\n--- a/net/core/dev.c\n+++ b/net/core/dev.c\n@@ -3665,7 +3665,7 @@ void skb_warn_bad_offload(const struct sk_buff *skb)\n */\n int skb_checksum_help(struct sk_buff *skb)\n {\n-\t__wsum csum;\n+\t__wsum csum = 0;\n \tint ret = 0, offset;\n \n \tif (skb-\u003eip_summed == CHECKSUM_COMPLETE)\n@@ -3697,13 +3697,16 @@ int skb_checksum_help(struct sk_buff *skb)\n \t\t\t offset, skb_headlen(skb));\n \t\tgoto out;\n \t}\n-\tcsum = skb_checksum(skb, offset, skb-\u003elen - offset, 0);\n+\tret = skb_checksum_full(skb, offset, skb-\u003elen - offset, \u0026csum);\n+\tif (ret)\n+\t\tgoto out;\n \n \toffset += skb-\u003ecsum_offset;\n \tif (unlikely(offset + sizeof(__sum16) \u003e skb_headlen(skb))) {\n \t\tDO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);\n \t\tWARN_ONCE(true, \"offset+2 (%zu) \u003e skb_headlen() (%u)\\n\",\n \t\t\t offset + sizeof(__sum16), skb_headlen(skb));\n+\t\tret = -EINVAL;\n \t\tgoto out;\n \t}\n \tret = skb_ensure_writable(skb, offset + sizeof(__sum16));\n@@ -3749,8 +3752,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb)\n \tif (ret)\n \t\tgoto out;\n \n-\tcrc = ~skb_crc32c(skb, start, skb-\u003elen - start, ~0);\n-\t*(__le32 *)(skb-\u003edata + offset) = cpu_to_le32(crc);\n+\tcrc = ~0;\n+\tret = skb_crc32c_full(skb, start, skb-\u003elen - start, \u0026crc);\n+\tif (ret)\n+\t\tgoto out;\n+\t*(__le32 *)(skb-\u003edata + offset) = cpu_to_le32(~crc);\n \tskb_reset_csum_not_inet(skb);\n out:\n \treturn ret;\ndiff --git a/net/core/filter.c b/net/core/filter.c\nindex 09c60a58c82abe..9881ac89e94c12 100644\n--- a/net/core/filter.c\n+++ b/net/core/filter.c\n@@ -3723,9 +3723,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,\n \t\tshinfo-\u003egso_segs = 0;\n \n \t\t/* Due to header growth, MSS needs to be downgraded.\n-\t\t * There is a BUG_ON() when segmenting the frag_list with\n-\t\t * head_frag true, so linearize the skb after downgrading\n-\t\t * the MSS.\n+\t\t * Segmenting a frag_list with head_frag true at the new MSS\n+\t\t * fails and the packet gets dropped, so linearize the skb\n+\t\t * after downgrading the MSS.\n \t\t */\n \t\tif (!(flags \u0026 BPF_F_ADJ_ROOM_FIXED_GSO)) {\n \t\t\tskb_decrease_gso_size(shinfo, len_diff);\ndiff --git a/net/core/gro.c b/net/core/gro.c\nindex 1b033855a20db6..e2e847c95270c7 100644\n--- a/net/core/gro.c\n+++ b/net/core/gro.c\n@@ -798,10 +798,17 @@ EXPORT_SYMBOL(napi_gro_frags);\n */\n __sum16 __skb_gro_checksum_complete(struct sk_buff *skb)\n {\n-\t__wsum wsum;\n+\t__wsum wsum = 0;\n \t__sum16 sum;\n \n-\twsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb), 0);\n+\t/* If the data can't be checksummed it can't be valid either, and\n+\t * NAPI_GRO_CB(skb)-\u003ecsum only holds the pseudo checksum.\n+\t */\n+\tif (skb_checksum_full(skb, skb_gro_offset(skb), skb_gro_len(skb),\n+\t\t\t \u0026wsum)) {\n+\t\tNAPI_GRO_CB(skb)-\u003ecsum_valid = 0;\n+\t\treturn (__force __sum16)1;\n+\t}\n \n \t/* NAPI_GRO_CB(skb)-\u003ecsum holds pseudo checksum */\n \tsum = csum_fold(csum_add(NAPI_GRO_CB(skb)-\u003ecsum, wsum));\ndiff --git a/net/core/net_test.c b/net/core/net_test.c\nindex 2b5080c226636c..976d14896251df 100644\n--- a/net/core/net_test.c\n+++ b/net/core/net_test.c\n@@ -41,6 +41,17 @@ enum gso_test_nr {\n \tGSO_TEST_RESEGMENT_MULTI,\n \tGSO_TEST_RESEGMENT_TAIL,\n \tGSO_TEST_RESEGMENT_ONE_MSS,\n+\tGSO_TEST_FRAG_LIST_NON_UNIFORM_SG,\n+\tGSO_TEST_FRAG_LIST_NESTED,\n+\tGSO_TEST_SHORT_LINEAR,\n+\tGSO_TEST_SHORT_LINEAR_STRADDLE,\n+\tGSO_TEST_SHORT_FRAG_LIST,\n+\tGSO_TEST_SHORT_GSO_BY_FRAGS,\n+\tGSO_TEST_FRAG_LIST_NESTED_NO_SG,\n+\tGSO_TEST_SHORT_LINEAR_NO_SG,\n+\tGSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,\n+\tGSO_TEST_SHORT_FRAG_LIST_NO_SG,\n+\tGSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,\n };\n \n struct gso_test_case {\n@@ -58,11 +69,18 @@ struct gso_test_case {\n \tunsigned int gso_type;\n \t/* skbs from alloc_skb() instead of build_skb(), head_frag clear */\n \tbool no_head_frag;\n+\t/* bytes that skb-\u003elen counts but the skb doesn't hold */\n+\tunsigned int missing_len;\n+\t/* segment without NETIF_F_SG */\n+\tbool no_sg;\n \n \t/* output as expected */\n \tunsigned int nr_segs;\n \tconst unsigned int *segs;\n \tconst unsigned int *gso_segs;\n+\n+\t/* skb_segment() is expected to fail with this error */\n+\tint err;\n };\n \n static struct gso_test_case cases[] = {\n@@ -241,6 +259,110 @@ static struct gso_test_case cases[] = {\n \t\t},\n \t\t.gso_segs = (const unsigned int[]) { 0, 0, 0, 0 },\n \t},\n+\t{\n+\t\t/* frag_list members that don't end on gso_size boundaries\n+\t\t * can't be segmented with SG\n+\t\t */\n+\t\t.id = GSO_TEST_FRAG_LIST_NON_UNIFORM_SG,\n+\t\t.name = \"frag_list_non_uniform_sg\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.nr_frag_skbs = 4,\n+\t\t.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, 1, GSO_TEST_SIZE, 2 },\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t/* the second frag_list member hangs off the first one's\n+\t\t * frag_list instead of off the head's\n+\t\t */\n+\t\t.id = GSO_TEST_FRAG_LIST_NESTED,\n+\t\t.name = \"frag_list_nested\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.nr_frag_skbs = 2,\n+\t\t.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t/* the data runs out on a segment boundary */\n+\t\t.id = GSO_TEST_SHORT_LINEAR,\n+\t\t.name = \"short_linear\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.missing_len = 50,\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t/* the data runs out in the middle of a segment */\n+\t\t.id = GSO_TEST_SHORT_LINEAR_STRADDLE,\n+\t\t.name = \"short_linear_straddle\",\n+\t\t.linear_len = GSO_TEST_SIZE + 500,\n+\t\t.missing_len = 700,\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t.id = GSO_TEST_SHORT_FRAG_LIST,\n+\t\t.name = \"short_frag_list\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.nr_frag_skbs = 1,\n+\t\t.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },\n+\t\t.missing_len = 50,\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t.id = GSO_TEST_SHORT_GSO_BY_FRAGS,\n+\t\t.name = \"short_gso_by_frags\",\n+\t\t.nr_frag_skbs = 2,\n+\t\t.frag_skbs = (const unsigned int[]) { 100, 200 },\n+\t\t.missing_len = 50,\n+\t\t.err = -EINVAL,\n+\t},\n+\t{\n+\t\t/* without SG the nested data is copied by skb_copy_bits(),\n+\t\t * which does look inside a member's own frag_list\n+\t\t */\n+\t\t.id = GSO_TEST_FRAG_LIST_NESTED_NO_SG,\n+\t\t.name = \"frag_list_nested_no_sg\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.nr_frag_skbs = 2,\n+\t\t.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },\n+\t\t.no_sg = true,\n+\t\t.nr_segs = 3,\n+\t\t.segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, GSO_TEST_SIZE },\n+\t},\n+\t{\n+\t\t/* without SG it is skb_copy_bits() that runs out of data */\n+\t\t.id = GSO_TEST_SHORT_LINEAR_NO_SG,\n+\t\t.name = \"short_linear_no_sg\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.missing_len = 50,\n+\t\t.no_sg = true,\n+\t\t.err = -EFAULT,\n+\t},\n+\t{\n+\t\t.id = GSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,\n+\t\t.name = \"short_linear_straddle_no_sg\",\n+\t\t.linear_len = GSO_TEST_SIZE + 500,\n+\t\t.missing_len = 700,\n+\t\t.no_sg = true,\n+\t\t.err = -EFAULT,\n+\t},\n+\t{\n+\t\t.id = GSO_TEST_SHORT_FRAG_LIST_NO_SG,\n+\t\t.name = \"short_frag_list_no_sg\",\n+\t\t.linear_len = GSO_TEST_SIZE,\n+\t\t.nr_frag_skbs = 1,\n+\t\t.frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },\n+\t\t.missing_len = 50,\n+\t\t.no_sg = true,\n+\t\t.err = -EFAULT,\n+\t},\n+\t{\n+\t\t.id = GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,\n+\t\t.name = \"short_gso_by_frags_no_sg\",\n+\t\t.nr_frag_skbs = 2,\n+\t\t.frag_skbs = (const unsigned int[]) { 100, 200 },\n+\t\t.missing_len = 50,\n+\t\t.no_sg = true,\n+\t\t.err = -EINVAL,\n+\t},\n };\n \n static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)\n@@ -337,21 +459,49 @@ static void gso_test_func(struct kunit *test)\n \t\tskb-\u003edata_len += total_size;\n \t\tskb-\u003etruesize += total_true_size;\n \n-\t\tif (tcase-\u003eid == GSO_TEST_GSO_BY_FRAGS)\n+\t\tif (tcase-\u003eid == GSO_TEST_GSO_BY_FRAGS ||\n+\t\t tcase-\u003eid == GSO_TEST_SHORT_GSO_BY_FRAGS ||\n+\t\t tcase-\u003eid == GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG)\n \t\t\tskb_shinfo(skb)-\u003egso_size = GSO_BY_FRAGS;\n+\n+\t\tif (tcase-\u003eid == GSO_TEST_FRAG_LIST_NESTED ||\n+\t\t tcase-\u003eid == GSO_TEST_FRAG_LIST_NESTED_NO_SG) {\n+\t\t\tstruct sk_buff *first = skb_shinfo(skb)-\u003efrag_list;\n+\n+\t\t\tskb_shinfo(first)-\u003efrag_list = first-\u003enext;\n+\t\t\tfirst-\u003enext = NULL;\n+\t\t\tfirst-\u003elen += tcase-\u003efrag_skbs[1];\n+\t\t\tfirst-\u003edata_len += tcase-\u003efrag_skbs[1];\n+\t\t}\n \t}\n \n+\tskb-\u003elen += tcase-\u003emissing_len;\n+\tskb-\u003edata_len += tcase-\u003emissing_len;\n+\n \tfeatures = NETIF_F_SG | NETIF_F_HW_CSUM;\n \tif (tcase-\u003eid == GSO_TEST_GSO_PARTIAL)\n \t\tfeatures |= NETIF_F_GSO_PARTIAL;\n \n-\t/* TODO: this should also work with SG,\n-\t * rather than hit BUG_ON(i \u003e= nfrags)\n+\t/* TODO: this should also work with SG, rather than fail the\n+\t * i \u003e= nfrags check in skb_segment()\n \t */\n-\tif (tcase-\u003eid == GSO_TEST_FRAG_LIST_NON_UNIFORM)\n+\tif (tcase-\u003eid == GSO_TEST_FRAG_LIST_NON_UNIFORM || tcase-\u003eno_sg)\n \t\tfeatures \u0026= ~NETIF_F_SG;\n \n \tSKB_GSO_CB(skb)-\u003emax_segs = tcase-\u003emax_segs;\n+\n+\tif (tcase-\u003eerr) {\n+\t\t/* the suppression block doesn't run if it can't be set up */\n+\t\tsegs = NULL;\n+\t\tkunit_warning_suppress(test) {\n+\t\t\tsegs = skb_segment(skb, features);\n+\t\t}\n+\t\tKUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(segs), tcase-\u003eerr);\n+\t\tif (!IS_ERR_OR_NULL(segs))\n+\t\t\tkfree_skb_list(segs);\n+\t\tgoto free_gso_skb;\n+\t}\n+\n \tsegs = skb_segment(skb, features);\n \tif (IS_ERR(segs)) {\n \t\tKUNIT_FAIL(test, \"segs error %pe\", segs);\n@@ -1374,7 +1524,7 @@ static void netmem_ref_test_skb_segment(struct kunit *test)\n \t/* 5. Linear head_skb (nr_frags=0) + mixed pp_recycle frag_list where\n \t * member A has linear + frag (pp_recycle=1) and tail member B has\n \t * linear len == skb_headlen(A) (pp_recycle=0): keeps SG clone path\n-\t * synchronized without hitting BUG_ON(i \u003e= nfrags).\n+\t * synchronized without failing the i \u003e= nfrags check.\n \t */\n \thead = alloc_skb(64, GFP_KERNEL);\n \tlist = alloc_skb(64, GFP_KERNEL);\ndiff --git a/net/core/skbuff.c b/net/core/skbuff.c\nindex 48f67641172433..29951ce11850b9 100644\n--- a/net/core/skbuff.c\n+++ b/net/core/skbuff.c\n@@ -2821,9 +2821,23 @@ static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)\n \tint delta = skb-\u003elen - len;\n \n \tif (skb_frags_readable(skb)) {\n-\t\tskb-\u003ecsum = csum_block_sub(skb-\u003ecsum,\n-\t\t\t\t\t skb_checksum(skb, len, delta, 0),\n-\t\t\t\t\t len);\n+\t\t__wsum csum = 0;\n+\t\tint err;\n+\n+\t\tif (!skb_checksum_full(skb, len, delta, \u0026csum)) {\n+\t\t\tskb-\u003ecsum = csum_block_sub(skb-\u003ecsum, csum, len);\n+\t\t\treturn 0;\n+\t\t}\n+\n+\t\t/* The trimmed bytes can't be checksummed, so skb-\u003ecsum can't\n+\t\t * be adjusted. Software can checksum the remaining packet\n+\t\t * after trimming, as long as it can read it.\n+\t\t */\n+\t\tcsum = 0;\n+\t\terr = skb_checksum_full(skb, 0, len, \u0026csum);\n+\t\tif (err)\n+\t\t\treturn err;\n+\t\tskb-\u003eip_summed = CHECKSUM_NONE;\n \t\treturn 0;\n \t}\n \n@@ -3536,27 +3550,88 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)\n }\n EXPORT_SYMBOL(skb_store_bits);\n \n-/* Checksum skb data. */\n-__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)\n+/* The frag_list part of skb_checksum_full(). It's out of line so that taking\n+ * the address of csum2 doesn't cost every caller a stack protector.\n+ */\n+static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,\n+\t\t\t\t\t int offset, int len, int pos,\n+\t\t\t\t\t __wsum csum, __wsum *csump)\n+{\n+\tstruct sk_buff *frag_iter;\n+\tint copy, err;\n+\n+\tskb_walk_frags(skb, frag_iter) {\n+\t\tint end;\n+\n+\t\tWARN_ON(start \u003e offset + len);\n+\n+\t\tend = start + frag_iter-\u003elen;\n+\t\tcopy = end - offset;\n+\t\tif (copy \u003e 0) {\n+\t\t\t__wsum csum2 = 0;\n+\n+\t\t\tif (copy \u003e len)\n+\t\t\t\tcopy = len;\n+\t\t\terr = skb_checksum_full(frag_iter, offset - start, copy,\n+\t\t\t\t\t\t\u0026csum2);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t\tcsum = csum_block_add(csum, csum2, pos);\n+\t\t\tlen -= copy;\n+\t\t\tif (len == 0)\n+\t\t\t\tgoto out;\n+\t\t\toffset += copy;\n+\t\t\tpos += copy;\n+\t\t}\n+\t\tstart = end;\n+\t}\n+\tif (unlikely(len)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EFAULT;\n+\t}\n+out:\n+\t*csump = csum;\n+\treturn 0;\n+}\n+\n+/**\n+ *\tskb_checksum_full - checksum a range of an skb\n+ *\t@skb: buffer to checksum\n+ *\t@offset: offset in @skb to start at\n+ *\t@len: number of bytes to checksum\n+ *\t@csump: the sum to add to; on success the range's sum is added to it\n+ *\n+ *\tReturn: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb\n+ *\truns out before @len does, or if the range goes past the linear area\n+ *\tof an skb, @skb or one on its frag_list, that has unreadable frags.\n+ *\tOn failure *@csump is not changed.\n+ */\n+int skb_checksum_full(const struct sk_buff *skb, int offset, int len,\n+\t\t __wsum *csump)\n {\n \tint start = skb_headlen(skb);\n \tint i, copy = start - offset;\n-\tstruct sk_buff *frag_iter;\n+\t__wsum csum = *csump;\n \tint pos = 0;\n \n+\tif (unlikely(len \u003c 0)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Checksum header. */\n \tif (copy \u003e 0) {\n \t\tif (copy \u003e len)\n \t\t\tcopy = len;\n \t\tcsum = csum_partial(skb-\u003edata + offset, copy, csum);\n \t\tif ((len -= copy) == 0)\n-\t\t\treturn csum;\n+\t\t\tgoto out;\n \t\toffset += copy;\n \t\tpos\t= copy;\n \t}\n \n-\tif (WARN_ON_ONCE(!skb_frags_readable(skb)))\n-\t\treturn 0;\n+\tif (!skb_frags_readable(skb))\n+\t\treturn -EFAULT;\n \n \tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n \t\tint end;\n@@ -3585,52 +3660,114 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)\n \t\t\t}\n \n \t\t\tif (!(len -= copy))\n-\t\t\t\treturn csum;\n+\t\t\t\tgoto out;\n \t\t\toffset += copy;\n \t\t}\n \t\tstart = end;\n \t}\n \n+\treturn skb_checksum_frag_list(skb, start, offset, len, pos, csum,\n+\t\t\t\t csump);\n+out:\n+\t*csump = csum;\n+\treturn 0;\n+}\n+EXPORT_SYMBOL(skb_checksum_full);\n+\n+/* skb_checksum() has no way to report failure, so it returns 0, which is a\n+ * valid checksum. Use skb_checksum_full() in new code.\n+ */\n+__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)\n+{\n+\tint err = skb_checksum_full(skb, offset, len, \u0026csum);\n+\n+\tif (unlikely(err)) {\n+\t\tWARN_ON_ONCE(err == -EFAULT \u0026\u0026 !skb_frags_readable(skb));\n+\t\treturn 0;\n+\t}\n+\treturn csum;\n+}\n+EXPORT_SYMBOL(skb_checksum);\n+\n+/* The frag_list part of skb_copy_and_csum_bits(). It's out of line so that\n+ * taking the address of csum2 doesn't cost every caller a stack protector.\n+ */\n+static noinline int skb_copy_and_csum_frag_list(const struct sk_buff *skb,\n+\t\t\t\t\t\tint start, int offset, u8 *to,\n+\t\t\t\t\t\tint len, int pos, __wsum csum,\n+\t\t\t\t\t\t__wsum *csump)\n+{\n+\tstruct sk_buff *frag_iter;\n+\tint copy, err;\n+\n \tskb_walk_frags(skb, frag_iter) {\n+\t\t__wsum csum2;\n \t\tint end;\n \n \t\tWARN_ON(start \u003e offset + len);\n \n \t\tend = start + frag_iter-\u003elen;\n-\t\tif ((copy = end - offset) \u003e 0) {\n-\t\t\t__wsum csum2;\n+\t\tcopy = end - offset;\n+\t\tif (copy \u003e 0) {\n \t\t\tif (copy \u003e len)\n \t\t\t\tcopy = len;\n-\t\t\tcsum2 = skb_checksum(frag_iter, offset - start, copy,\n-\t\t\t\t\t 0);\n+\t\t\terr = skb_copy_and_csum_bits(frag_iter, offset - start,\n+\t\t\t\t\t\t to, copy, \u0026csum2);\n+\t\t\tif (err) {\n+\t\t\t\t/* The child zeroed its part; zero the rest. */\n+\t\t\t\tmemset(to + copy, 0, len - copy);\n+\t\t\t\treturn err;\n+\t\t\t}\n \t\t\tcsum = csum_block_add(csum, csum2, pos);\n-\t\t\tif ((len -= copy) == 0)\n-\t\t\t\treturn csum;\n+\t\t\tlen -= copy;\n+\t\t\tif (len == 0)\n+\t\t\t\tgoto out;\n \t\t\toffset += copy;\n+\t\t\tto += copy;\n \t\t\tpos += copy;\n \t\t}\n \t\tstart = end;\n \t}\n \tif (unlikely(len)) {\n \t\tDEBUG_NET_WARN_ON_ONCE(1);\n-\t\treturn 0;\n+\t\t/* Don't hand the caller a buffer with stale bytes in it. */\n+\t\tmemset(to, 0, len);\n+\t\treturn -EFAULT;\n \t}\n-\n-\treturn csum;\n+out:\n+\t*csump = csum;\n+\treturn 0;\n }\n-EXPORT_SYMBOL(skb_checksum);\n-\n-/* Both of above in one bottle. */\n \n-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n-\t\t\t\t u8 *to, int len)\n+/**\n+ *\tskb_copy_and_csum_bits - copy data out of an skb and checksum it\n+ *\t@skb: source buffer\n+ *\t@offset: offset in @skb to start copying from\n+ *\t@to: destination buffer\n+ *\t@len: number of bytes to copy\n+ *\t@csump: where to store the checksum of the copied bytes\n+ *\n+ *\tReturn: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb\n+ *\thas unreadable frags or runs out before @len does. On failure *@csump\n+ *\tis not set. On -EFAULT the part of @to that couldn't be filled is\n+ *\tzeroed, and on -EINVAL @to is not touched.\n+ */\n+int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n+\t\t\t u8 *to, int len, __wsum *csump)\n {\n \tint start = skb_headlen(skb);\n \tint i, copy = start - offset;\n-\tstruct sk_buff *frag_iter;\n \tint pos = 0;\n \t__wsum csum = 0;\n \n+\t/* Everything below clamps its copy to @len, so a negative one would\n+\t * turn into a huge copy.\n+\t */\n+\tif (unlikely(len \u003c 0)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EINVAL;\n+\t}\n+\n \t/* Copy header. */\n \tif (copy \u003e 0) {\n \t\tif (copy \u003e len)\n@@ -3638,7 +3775,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n \t\tcsum = csum_partial_copy_nocheck(skb-\u003edata + offset, to,\n \t\t\t\t\t\t copy);\n \t\tif ((len -= copy) == 0)\n-\t\t\treturn csum;\n+\t\t\tgoto out;\n \t\toffset += copy;\n \t\tto += copy;\n \t\tpos\t= copy;\n@@ -3646,9 +3783,8 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n \n \tif (!skb_frags_readable(skb)) {\n \t\t/* Don't hand the caller a buffer with stale bytes in it. */\n-\t\tif (len \u003e 0)\n-\t\t\tmemset(to, 0, len);\n-\t\treturn 0;\n+\t\tmemset(to, 0, len);\n+\t\treturn -EFAULT;\n \t}\n \n \tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n@@ -3680,64 +3816,95 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n \t\t\t}\n \n \t\t\tif (!(len -= copy))\n-\t\t\t\treturn csum;\n+\t\t\t\tgoto out;\n \t\t\toffset += copy;\n \t\t\tto += copy;\n \t\t}\n \t\tstart = end;\n \t}\n \n+\treturn skb_copy_and_csum_frag_list(skb, start, offset, to, len, pos,\n+\t\t\t\t\t csum, csump);\n+out:\n+\t*csump = csum;\n+\treturn 0;\n+}\n+EXPORT_SYMBOL(skb_copy_and_csum_bits);\n+\n+#ifdef CONFIG_NET_CRC32C\n+/* The frag_list part of skb_crc32c_full(). It's out of line so that taking\n+ * the address of crc doesn't cost every caller a stack protector.\n+ */\n+static noinline int skb_crc32c_frag_list(const struct sk_buff *skb, int start,\n+\t\t\t\t\t int offset, int len, u32 crc,\n+\t\t\t\t\t u32 *crcp)\n+{\n+\tstruct sk_buff *frag_iter;\n+\tint copy, err;\n+\n \tskb_walk_frags(skb, frag_iter) {\n-\t\t__wsum csum2;\n \t\tint end;\n \n \t\tWARN_ON(start \u003e offset + len);\n \n \t\tend = start + frag_iter-\u003elen;\n-\t\tif ((copy = end - offset) \u003e 0) {\n-\t\t\tif (copy \u003e len)\n-\t\t\t\tcopy = len;\n-\t\t\tcsum2 = skb_copy_and_csum_bits(frag_iter,\n-\t\t\t\t\t\t offset - start,\n-\t\t\t\t\t\t to, copy);\n-\t\t\tcsum = csum_block_add(csum, csum2, pos);\n-\t\t\tif ((len -= copy) == 0)\n-\t\t\t\treturn csum;\n+\t\tcopy = end - offset;\n+\t\tif (copy \u003e 0) {\n+\t\t\tcopy = min(copy, len);\n+\t\t\terr = skb_crc32c_full(frag_iter, offset - start, copy,\n+\t\t\t\t\t \u0026crc);\n+\t\t\tif (err)\n+\t\t\t\treturn err;\n+\t\t\tlen -= copy;\n+\t\t\tif (len == 0)\n+\t\t\t\tgoto out;\n \t\t\toffset += copy;\n-\t\t\tto += copy;\n-\t\t\tpos += copy;\n \t\t}\n \t\tstart = end;\n \t}\n \tif (unlikely(len)) {\n \t\tDEBUG_NET_WARN_ON_ONCE(1);\n-\t\t/* Don't hand the caller a buffer with stale bytes in it. */\n-\t\tif (len \u003e 0)\n-\t\t\tmemset(to, 0, len);\n-\t\treturn 0;\n+\t\treturn -EFAULT;\n \t}\n-\treturn csum;\n+out:\n+\t*crcp = crc;\n+\treturn 0;\n }\n-EXPORT_SYMBOL(skb_copy_and_csum_bits);\n \n-#ifdef CONFIG_NET_CRC32C\n-u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)\n+/**\n+ *\tskb_crc32c_full - CRC32C a range of an skb\n+ *\t@skb: buffer to read\n+ *\t@offset: offset in @skb to start at\n+ *\t@len: number of bytes to include\n+ *\t@crcp: the CRC to continue from; on success, updated with the range\n+ *\n+ *\tReturn: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb\n+ *\truns out before @len does, or if the range goes past the linear area\n+ *\tof an skb, @skb or one on its frag_list, that has unreadable frags.\n+ *\tOn failure *@crcp is not changed.\n+ */\n+int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)\n {\n \tint start = skb_headlen(skb);\n \tint i, copy = start - offset;\n-\tstruct sk_buff *frag_iter;\n+\tu32 crc = *crcp;\n+\n+\tif (unlikely(len \u003c 0)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EINVAL;\n+\t}\n \n \tif (copy \u003e 0) {\n \t\tcopy = min(copy, len);\n \t\tcrc = crc32c(crc, skb-\u003edata + offset, copy);\n \t\tlen -= copy;\n \t\tif (len == 0)\n-\t\t\treturn crc;\n+\t\t\tgoto out;\n \t\toffset += copy;\n \t}\n \n-\tif (WARN_ON_ONCE(!skb_frags_readable(skb)))\n-\t\treturn 0;\n+\tif (!skb_frags_readable(skb))\n+\t\treturn -EFAULT;\n \n \tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n \t\tint end;\n@@ -3762,44 +3929,57 @@ u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)\n \t\t\t}\n \t\t\tlen -= copy;\n \t\t\tif (len == 0)\n-\t\t\t\treturn crc;\n+\t\t\t\tgoto out;\n \t\t\toffset += copy;\n \t\t}\n \t\tstart = end;\n \t}\n \n-\tskb_walk_frags(skb, frag_iter) {\n-\t\tint end;\n+\treturn skb_crc32c_frag_list(skb, start, offset, len, crc, crcp);\n+out:\n+\t*crcp = crc;\n+\treturn 0;\n+}\n+EXPORT_SYMBOL(skb_crc32c_full);\n \n-\t\tWARN_ON(start \u003e offset + len);\n+/* skb_crc32c() has no way to report failure, so it returns 0, which is a\n+ * valid CRC. Use skb_crc32c_full() in new code.\n+ */\n+u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)\n+{\n+\tint err = skb_crc32c_full(skb, offset, len, \u0026crc);\n \n-\t\tend = start + frag_iter-\u003elen;\n-\t\tcopy = end - offset;\n-\t\tif (copy \u003e 0) {\n-\t\t\tcopy = min(copy, len);\n-\t\t\tcrc = skb_crc32c(frag_iter, offset - start, copy, crc);\n-\t\t\tlen -= copy;\n-\t\t\tif (len == 0)\n-\t\t\t\treturn crc;\n-\t\t\toffset += copy;\n-\t\t}\n-\t\tstart = end;\n-\t}\n-\tif (unlikely(len)) {\n-\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\tif (unlikely(err)) {\n+\t\tWARN_ON_ONCE(err == -EFAULT \u0026\u0026 !skb_frags_readable(skb));\n \t\treturn 0;\n \t}\n-\n \treturn crc;\n }\n EXPORT_SYMBOL(skb_crc32c);\n #endif /* CONFIG_NET_CRC32C */\n \n+/* The data can't be checksummed, so it can't be valid either. The caller has\n+ * put the pseudo header's checksum in skb-\u003ecsum, so don't leave the skb\n+ * CHECKSUM_COMPLETE for a later validator to take that for the packet's.\n+ */\n+static __sum16 skb_checksum_complete_failed(struct sk_buff *skb)\n+{\n+\tif (!skb_shared(skb)) {\n+\t\tskb_checksum_complete_unset(skb);\n+\t\tskb-\u003ecsum_valid = 0;\n+\t}\n+\treturn (__force __sum16)1;\n+}\n+\n __sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)\n {\n+\t__wsum csum = skb-\u003ecsum;\n \t__sum16 sum;\n \n-\tsum = csum_fold(skb_checksum(skb, 0, len, skb-\u003ecsum));\n+\tif (skb_checksum_full(skb, 0, len, \u0026csum))\n+\t\treturn skb_checksum_complete_failed(skb);\n+\n+\tsum = csum_fold(csum);\n \t/* See comments in __skb_checksum_complete(). */\n \tif (likely(!sum)) {\n \t\tif (unlikely(skb-\u003eip_summed == CHECKSUM_COMPLETE) \u0026\u0026\n@@ -3819,14 +3999,16 @@ EXPORT_SYMBOL(__skb_checksum_complete_head);\n *\n * It returns non-zero if the recomputed checksum is still invalid, otherwise\n * zero. The new checksum is stored back into skb-\u003ecsum unless the skb is\n- * shared.\n+ * shared. If the skb can't be checksummed it returns non-zero, skb-\u003ecsum is\n+ * left alone, and the skb is no longer CHECKSUM_COMPLETE unless it's shared.\n */\n __sum16 __skb_checksum_complete(struct sk_buff *skb)\n {\n-\t__wsum csum;\n+\t__wsum csum = 0;\n \t__sum16 sum;\n \n-\tcsum = skb_checksum(skb, 0, skb-\u003elen, 0);\n+\tif (skb_checksum_full(skb, 0, skb-\u003elen, \u0026csum))\n+\t\treturn skb_checksum_complete_failed(skb);\n \n \tsum = csum_fold(csum_add(skb-\u003ecsum, csum));\n \t/* This check is inverted, because we already knew the hardware\n@@ -3897,8 +4079,10 @@ EXPORT_SYMBOL_GPL(skb_zerocopy_headlen);\n *\tReturn value:\n *\t0: everything is OK\n *\t-ENOMEM: couldn't orphan frags of @from due to lack of memory\n- *\t-EFAULT: skb_copy_bits() found some problem with skb geometry, or readable head\n- * payload would be mixed with unreadable frags.\n+ *\t-EFAULT: skb_copy_bits() found some problem with skb geometry, @from has\n+ *\tno head_frag and @hlen is 0 while @len doesn't fit in @to's tailroom,\n+ *\tor readable head payload would be mixed with unreadable frags.\n+ *\t-EINVAL: @len or @hlen is negative\n */\n int\n skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)\n@@ -3909,15 +4093,23 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)\n \tstruct page *page;\n \tunsigned int offset;\n \n-\tif (unlikely(!from-\u003ehead_frag \u0026\u0026 !hlen)) {\n+\tif (unlikely(len \u003c 0 || hlen \u003c 0)) {\n \t\tDEBUG_NET_WARN_ON_ONCE(1);\n-\t\treturn -EFAULT;\n+\t\treturn -EINVAL;\n \t}\n \n \t/* dont bother with small payloads */\n \tif (len \u003c= skb_tailroom(to))\n \t\treturn skb_copy_bits(from, 0, skb_put(to, len), len);\n \n+\t/* Without a head_frag the head can't be referenced as a page, so the\n+\t * caller has to ask for it to be copied.\n+\t */\n+\tif (unlikely(!from-\u003ehead_frag \u0026\u0026 !hlen)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EFAULT;\n+\t}\n+\n \tto-\u003epp_recycle = from-\u003epp_recycle;\n \tif (hlen) {\n \t\tret = skb_copy_bits(from, 0, skb_put(to, hlen), hlen);\n@@ -3980,6 +4172,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)\n \t__wsum csum;\n \tlong csstart;\n \n+\t/* skb_headlen() underflows if data_len is bigger than len, and then\n+\t * the checks below don't bound the copy from the linear area.\n+\t */\n+\tif (unlikely(skb-\u003edata_len \u003e skb-\u003elen)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\tmemset(to, 0, skb-\u003elen);\n+\t\treturn;\n+\t}\n+\n \tif (skb-\u003eip_summed == CHECKSUM_PARTIAL)\n \t\tcsstart = skb_checksum_start_offset(skb);\n \telse\n@@ -4001,9 +4202,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)\n \tskb_copy_from_linear_data(skb, to, csstart);\n \n \tcsum = 0;\n-\tif (csstart != skb-\u003elen)\n-\t\tcsum = skb_copy_and_csum_bits(skb, csstart, to + csstart,\n-\t\t\t\t\t skb-\u003elen - csstart);\n+\tif (csstart != skb-\u003elen \u0026\u0026\n+\t skb_copy_and_csum_bits(skb, csstart, to + csstart,\n+\t\t\t\t skb-\u003elen - csstart, \u0026csum)) {\n+\t\t/* Send zeroes rather than intact headers on a payload that\n+\t\t * couldn't be copied.\n+\t\t */\n+\t\tmemset(to, 0, skb-\u003elen);\n+\t\treturn;\n+\t}\n \n \tif (skb-\u003eip_summed == CHECKSUM_PARTIAL) {\n \t\tlong csstuff = csstart + skb-\u003ecsum_offset;\n@@ -4957,7 +5164,16 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,\n \t\tint hsize;\n \t\tint size;\n \n+\t\t/* list_skb runs out early if head_skb-\u003elen counts data that\n+\t\t * this walk can't find: bytes that aren't there, or a member's\n+\t\t * own frag_list, which the walk never looks inside.\n+\t\t */\n \t\tif (unlikely(gso_by_frags)) {\n+\t\t\tif (unlikely(!list_skb)) {\n+\t\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\t\t\terr = -EINVAL;\n+\t\t\t\tgoto err;\n+\t\t\t}\n \t\t\tlen = list_skb-\u003elen;\n \t\t} else {\n \t\t\tlen = head_skb-\u003elen - offset;\n@@ -4967,7 +5183,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,\n \n \t\thsize = skb_headlen(head_skb) - offset;\n \n-\t\tif (hsize \u003c= 0 \u0026\u0026 i \u003e= nfrags \u0026\u0026 skb_headlen(list_skb) \u0026\u0026\n+\t\tif (hsize \u003c= 0 \u0026\u0026 i \u003e= nfrags \u0026\u0026 list_skb \u0026\u0026\n+\t\t skb_headlen(list_skb) \u0026\u0026\n \t\t (skb_headlen(list_skb) == len || sg)) {\n \t\t\tif (unlikely(skb_headlen(list_skb) \u003e len)) {\n \t\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n@@ -5057,16 +5274,20 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,\n \t\t\tif (!csum) {\n \t\t\t\tif (!nskb-\u003eremcsum_offload)\n \t\t\t\t\tnskb-\u003eip_summed = CHECKSUM_NONE;\n-\t\t\t\tSKB_GSO_CB(nskb)-\u003ecsum =\n-\t\t\t\t\tskb_copy_and_csum_bits(head_skb, offset,\n-\t\t\t\t\t\t\t skb_put(nskb,\n-\t\t\t\t\t\t\t\t len),\n-\t\t\t\t\t\t\t len);\n+\t\t\t\tif (skb_copy_and_csum_bits(head_skb, offset,\n+\t\t\t\t\t\t\t skb_put(nskb, len),\n+\t\t\t\t\t\t\t len,\n+\t\t\t\t\t\t\t \u0026SKB_GSO_CB(nskb)-\u003ecsum)) {\n+\t\t\t\t\terr = -EFAULT;\n+\t\t\t\t\tgoto err;\n+\t\t\t\t}\n \t\t\t\tSKB_GSO_CB(nskb)-\u003ecsum_start =\n \t\t\t\t\tskb_headroom(nskb) + doffset;\n \t\t\t} else {\n-\t\t\t\tif (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len))\n+\t\t\t\tif (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len)) {\n+\t\t\t\t\terr = -EFAULT;\n \t\t\t\t\tgoto err;\n+\t\t\t\t}\n \t\t\t}\n \t\t\tcontinue;\n \t\t}\n@@ -5085,6 +5306,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,\n \n \t\twhile (pos \u003c offset + len) {\n \t\t\tif (i \u003e= nfrags) {\n+\t\t\t\tif (unlikely(!list_skb)) {\n+\t\t\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\t\t\t\terr = -EINVAL;\n+\t\t\t\t\tgoto err;\n+\t\t\t\t}\n+\n \t\t\t\tif (skb_shinfo(nskb)-\u003enr_frags \u0026\u0026\n \t\t\t\t nskb-\u003epp_recycle != list_skb-\u003epp_recycle) {\n \t\t\t\t\tnskb-\u003edata_len = pos - offset - hsize;\n@@ -5175,9 +5402,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,\n \n \t\t\tif (!nskb-\u003eremcsum_offload)\n \t\t\t\tnskb-\u003eip_summed = CHECKSUM_NONE;\n-\t\t\tSKB_GSO_CB(nskb)-\u003ecsum =\n-\t\t\t\tskb_checksum(nskb, doffset,\n-\t\t\t\t\t nskb-\u003elen - doffset, 0);\n+\t\t\tSKB_GSO_CB(nskb)-\u003ecsum = 0;\n+\t\t\tif (skb_checksum_full(nskb, doffset,\n+\t\t\t\t\t nskb-\u003elen - doffset,\n+\t\t\t\t\t \u0026SKB_GSO_CB(nskb)-\u003ecsum)) {\n+\t\t\t\terr = -EFAULT;\n+\t\t\t\tgoto err;\n+\t\t\t}\n \t\t\tSKB_GSO_CB(nskb)-\u003ecsum_start =\n \t\t\t\tskb_headroom(nskb) + doffset;\n \t\t}\n@@ -5410,8 +5641,9 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len,\n *\n *\tFill the specified scatter-gather list with mappings/pointers into a\n *\tregion of the buffer space attached to a socket buffer. Returns either\n- *\tthe number of scatterlist items used, or -EMSGSIZE if the contents\n- *\tcould not fit.\n+ *\tthe number of scatterlist items used, -EMSGSIZE if the contents\n+ *\tcould not fit, or -EINVAL if @offset and @len run past the end of\n+ *\tthe skb.\n */\n int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)\n {\n@@ -6281,7 +6513,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,\n \t\t bool *fragstolen, int *delta_truesize)\n {\n \tstruct skb_shared_info *to_shinfo, *from_shinfo;\n-\tint i, delta, len = from-\u003elen;\n+\tunsigned int len = from-\u003elen;\n+\tint i, delta;\n \n \t*fragstolen = false;\n \n@@ -6326,9 +6559,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,\n \t\treturn false;\n \n \tif (skb_headlen(from) != 0) {\n-\t\tstruct page *page;\n-\t\tunsigned int offset;\n-\n \t\tif (to_shinfo-\u003enr_frags +\n \t\t from_shinfo-\u003enr_frags \u003e= MAX_SKB_FRAGS)\n \t\t\treturn false;\n@@ -6337,13 +6567,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,\n \t\t\treturn false;\n \n \t\tdelta = from-\u003etruesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));\n-\n-\t\tpage = virt_to_head_page(from-\u003ehead);\n-\t\toffset = from-\u003edata - (unsigned char *)page_address(page);\n-\n-\t\tskb_fill_page_desc(to, to_shinfo-\u003enr_frags,\n-\t\t\t\t page, offset, skb_headlen(from));\n-\t\t*fragstolen = true;\n \t} else {\n \t\tif (to_shinfo-\u003enr_frags +\n \t\t from_shinfo-\u003enr_frags \u003e MAX_SKB_FRAGS)\n@@ -6352,7 +6575,19 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,\n \t\tdelta = from-\u003etruesize - SKB_TRUESIZE(skb_end_offset(from));\n \t}\n \n-\tWARN_ON_ONCE(delta \u003c len);\n+\t/* @from claims more data than it has memory for. Leave @to alone. */\n+\tif (WARN_ON_ONCE(delta \u003c 0 || delta \u003c len))\n+\t\treturn false;\n+\n+\tif (skb_headlen(from) != 0) {\n+\t\tstruct page *page = virt_to_head_page(from-\u003ehead);\n+\t\tunsigned int offset;\n+\n+\t\toffset = from-\u003edata - (unsigned char *)page_address(page);\n+\t\tskb_fill_page_desc(to, to_shinfo-\u003enr_frags,\n+\t\t\t\t page, offset, skb_headlen(from));\n+\t\t*fragstolen = true;\n+\t}\n \n \tmemcpy(to_shinfo-\u003efrags + to_shinfo-\u003enr_frags,\n \t from_shinfo-\u003efrags,\ndiff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c\nindex 90c0e22c29bea6..35008785e3d228 100644\n--- a/net/ipv4/icmp.c\n+++ b/net/ipv4/icmp.c\n@@ -364,12 +364,15 @@ static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,\n \tDEFINE_RAW_FLEX(struct icmp_bxm, icmp_param, replyopts.opt.__data,\n \t\t\tIP_OPTIONS_DATA_FIXED_SIZE);\n \t__wsum csum;\n+\tint err;\n \n \ticmp_param = from;\n \n-\tcsum = skb_copy_and_csum_bits(icmp_param-\u003eskb,\n-\t\t\t\t icmp_param-\u003eoffset + offset,\n-\t\t\t\t to, len);\n+\terr = skb_copy_and_csum_bits(icmp_param-\u003eskb,\n+\t\t\t\t icmp_param-\u003eoffset + offset,\n+\t\t\t\t to, len, \u0026csum);\n+\tif (err)\n+\t\treturn err;\n \n \tskb-\u003ecsum = csum_block_add(skb-\u003ecsum, csum, odd);\n \tif (icmp_param-\u003edata.icmph.type \u003c= NR_ICMP_TYPES \u0026\u0026\ndiff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c\nindex 3396f177a18d09..f7da4538d05b5c 100644\n--- a/net/ipv4/ip_output.c\n+++ b/net/ipv4/ip_output.c\n@@ -1162,9 +1162,14 @@ static int __ip_append_data(struct sock *sk,\n \t\t\tdata += fragheaderlen + exthdrlen;\n \n \t\t\tif (fraggap) {\n-\t\t\t\tskb-\u003ecsum = skb_copy_and_csum_bits(\n-\t\t\t\t\tskb_prev, maxfraglen,\n-\t\t\t\t\tdata + transhdrlen, fraggap);\n+\t\t\t\tif (skb_copy_and_csum_bits(skb_prev, maxfraglen,\n+\t\t\t\t\t\t\t data + transhdrlen,\n+\t\t\t\t\t\t\t fraggap,\n+\t\t\t\t\t\t\t \u0026skb-\u003ecsum)) {\n+\t\t\t\t\terr = -EFAULT;\n+\t\t\t\t\tkfree_skb(skb);\n+\t\t\t\t\tgoto error;\n+\t\t\t\t}\n \t\t\t\tskb_prev-\u003ecsum = csum_sub(skb_prev-\u003ecsum,\n \t\t\t\t\t\t\t skb-\u003ecsum);\n \t\t\t\tdata += fraggap;\ndiff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c\nindex a95b0351824f32..31ca3da80b1f1e 100644\n--- a/net/ipv6/icmp.c\n+++ b/net/ipv6/icmp.c\n@@ -322,9 +322,12 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st\n \tstruct icmpv6_msg *msg = (struct icmpv6_msg *) from;\n \tstruct sk_buff *org_skb = msg-\u003eskb;\n \t__wsum csum;\n+\tint err;\n \n-\tcsum = skb_copy_and_csum_bits(org_skb, msg-\u003eoffset + offset,\n-\t\t\t\t to, len);\n+\terr = skb_copy_and_csum_bits(org_skb, msg-\u003eoffset + offset,\n+\t\t\t\t to, len, \u0026csum);\n+\tif (err)\n+\t\treturn err;\n \tskb-\u003ecsum = csum_block_add(skb-\u003ecsum, csum, odd);\n \tif (!(msg-\u003etype \u0026 ICMPV6_INFOMSG_MASK))\n \t\tnf_ct_attach(skb, org_skb);\ndiff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c\nindex 25fe0ba98b1a6a..d259e7dca8ba21 100644\n--- a/net/ipv6/ip6_output.c\n+++ b/net/ipv6/ip6_output.c\n@@ -1724,9 +1724,14 @@ static int __ip6_append_data(struct sock *sk,\n \t\t\tskb-\u003etransport_header = (skb-\u003enetwork_header +\n \t\t\t\t\t\t fragheaderlen);\n \t\t\tif (fraggap) {\n-\t\t\t\tskb-\u003ecsum = skb_copy_and_csum_bits(\n-\t\t\t\t\tskb_prev, maxfraglen,\n-\t\t\t\t\tdata + transhdrlen, fraggap);\n+\t\t\t\tif (skb_copy_and_csum_bits(skb_prev, maxfraglen,\n+\t\t\t\t\t\t\t data + transhdrlen,\n+\t\t\t\t\t\t\t fraggap,\n+\t\t\t\t\t\t\t \u0026skb-\u003ecsum)) {\n+\t\t\t\t\terr = -EFAULT;\n+\t\t\t\t\tkfree_skb(skb);\n+\t\t\t\t\tgoto error;\n+\t\t\t\t}\n \t\t\t\tskb_prev-\u003ecsum = csum_sub(skb_prev-\u003ecsum,\n \t\t\t\t\t\t\t skb-\u003ecsum);\n \t\t\t\tdata += fraggap;\ndiff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c\nindex d8d8842c7de5cd..5d780ad4ae3a03 100644\n--- a/net/sunrpc/socklib.c\n+++ b/net/sunrpc/socklib.c\n@@ -49,7 +49,9 @@ xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)\n \tif (desc-\u003eneed_checksum) {\n \t\t__wsum csum;\n \n-\t\tcsum = skb_copy_and_csum_bits(desc-\u003eskb, desc-\u003eoffset, to, len);\n+\t\tif (unlikely(skb_copy_and_csum_bits(desc-\u003eskb, desc-\u003eoffset,\n+\t\t\t\t\t\t to, len, \u0026csum)))\n+\t\t\treturn 0;\n \t\tdesc-\u003ecsum = csum_block_add(desc-\u003ecsum, csum, desc-\u003eoffset);\n \t} else {\n \t\tif (unlikely(skb_copy_bits(desc-\u003eskb, desc-\u003eoffset, to, len)))\n@@ -142,11 +144,6 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)\n \tdesc.csum = csum_partial(skb-\u003edata, desc.offset, skb-\u003ecsum);\n \tif (xdr_partial_copy_from_skb(xdr, \u0026desc) \u003c 0)\n \t\treturn -1;\n-\tif (desc.offset != skb-\u003elen) {\n-\t\t__wsum csum2;\n-\t\tcsum2 = skb_checksum(skb, desc.offset, skb-\u003elen - desc.offset, 0);\n-\t\tdesc.csum = csum_block_add(desc.csum, csum2, desc.offset);\n-\t}\n \tif (desc.count)\n \t\treturn -1;\n \tif (csum_fold(desc.csum))\ndiff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c\nindex 771e02bff51999..748ae27f2b881c 100644\n--- a/net/tls/tls_sw.c\n+++ b/net/tls/tls_sw.c\n@@ -142,12 +142,16 @@ static int __skb_nsg(struct sk_buff *skb, int offset, int len,\n start = end;\n }\n }\n- BUG_ON(len);\n+\tif (unlikely(len)) {\n+\t\tDEBUG_NET_WARN_ON_ONCE(1);\n+\t\treturn -EINVAL;\n+\t}\n return elt;\n }\n \n /* Return the number of scatterlist elements required to completely map the\n- * skb, or -EMSGSIZE if the recursion depth is exceeded.\n+ * skb, -EMSGSIZE if the recursion depth is exceeded, or -EINVAL if the skb\n+ * runs out before @len does.\n */\n static int skb_nsg(struct sk_buff *skb, int offset, int len)\n {\n"
} |
| 2/1 | 2026/11/07 14:34 | agent | patch-evaluator |
3mModel:core Args: null Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"INET",
"IPV6",
"TLS",
"IP_SCTP"
],
"FocusSymbols": [
"skb_segment",
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_checksum_help",
"skb_crc32c_csum_help",
"skb_zerocopy",
"skb_try_coalesce",
"skb_copy_and_csum_dev",
"__skb_gro_checksum_complete"
],
"Reasoning": "The patch introduces extensive error-propagation and sanity checks across core networking skb operations (skb_segment, skb_checksum_full, skb_copy_and_csum_bits, skb_crc32c_full, skb_try_coalesce, skb_zerocopy). It modifies skb segmentation and checksumming logic, alters return signatures, and adds multiple DEBUG_NET_WARN_ON_ONCE invariant checks in reachable core networking execution paths. Fuzzing is warranted to verify that complex skb geometries (e.g. frag lists, non-linear buffers, GSO/GRO) do not trigger new assertions, regressions, or edge-case fault conditions.",
"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 7eab7c1eee34f51ba1f3d4538574f0ac9fb72156
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Nov 7 14:34:09 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethernet/sun/sunvnet_common.c
index 5cca958690521f..4f229fcecc32f1 100644
--- a/drivers/net/ethernet/sun/sunvnet_common.c
+++ b/drivers/net/ethernet/sun/sunvnet_common.c
@@ -1167,9 +1167,13 @@ static inline struct sk_buff *vnet_skb_shape(struct sk_buff *skb, int ncookies)
/* copy the rest, with csum calculation */
*(__sum16 *)(skb->data + offset) = 0;
- csum = skb_copy_and_csum_bits(skb, start,
- nskb->data + start,
- skb->len - start);
+ if (skb_copy_and_csum_bits(skb, start,
+ nskb->data + start,
+ skb->len - start, &csum)) {
+ dev_kfree_skb(nskb);
+ dev_kfree_skb(skb);
+ return NULL;
+ }
/* add in the header checksums */
if (skb->protocol == htons(ETH_P_IP)) {
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fdcb91042f2906..17811d81937c6e 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -695,7 +695,12 @@ static struct sk_buff *bounce_skb(const struct sk_buff *skb)
/* Set the tail pointer and length */
skb_put(n, skb->len);
- BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len));
+ if (unlikely(skb_copy_bits(skb, -headerlen, n->head,
+ headerlen + skb->len))) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ kfree_skb(n);
+ return NULL;
+ }
skb_copy_header(n, skb);
return n;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6787fcf6ac3e43..5581ed3cbf479d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4280,8 +4280,10 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
- int len);
+int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
+ u8 *to, int len, __wsum *csump);
+int __must_check skb_checksum_full(const struct sk_buff *skb, int offset,
+ int len, __wsum *csump);
int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
@@ -4330,6 +4332,8 @@ static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
__wsum csum);
+int __must_check skb_crc32c_full(const struct sk_buff *skb, int offset,
+ int len, u32 *crcp);
u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc);
static inline void * __must_check
@@ -4890,7 +4894,7 @@ static inline void skb_checksum_complete_unset(struct sk_buff *skb)
* 0: checksum is validated or try to in skb_checksum_complete. In the latter
* case the ip_summed will not be CHECKSUM_UNNECESSARY and the pseudo
* checksum is stored in skb->csum for use in __skb_checksum_complete
- * non-zero: value of invalid checksum
+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed
*
*/
static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,
@@ -4930,7 +4934,7 @@ static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)
*
* Return values:
* 0: checksum is validated or try to in skb_checksum_complete
- * non-zero: value of invalid checksum
+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed
*/
#define __skb_checksum_validate(skb, proto, complete, \
zero_okay, check, compute_pseudo) \
diff --git a/net/core/dev.c b/net/core/dev.c
index 3ac700d37e596f..f9878db781df7c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3665,7 +3665,7 @@ void skb_warn_bad_offload(const struct sk_buff *skb)
*/
int skb_checksum_help(struct sk_buff *skb)
{
- __wsum csum;
+ __wsum csum = 0;
int ret = 0, offset;
if (skb->ip_summed == CHECKSUM_COMPLETE)
@@ -3697,13 +3697,16 @@ int skb_checksum_help(struct sk_buff *skb)
offset, skb_headlen(skb));
goto out;
}
- csum = skb_checksum(skb, offset, skb->len - offset, 0);
+ ret = skb_checksum_full(skb, offset, skb->len - offset, &csum);
+ if (ret)
+ goto out;
offset += skb->csum_offset;
if (unlikely(offset + sizeof(__sum16) > skb_headlen(skb))) {
DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
WARN_ONCE(true, "offset+2 (%zu) > skb_headlen() (%u)\n",
offset + sizeof(__sum16), skb_headlen(skb));
+ ret = -EINVAL;
goto out;
}
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
@@ -3749,8 +3752,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb)
if (ret)
goto out;
- crc = ~skb_crc32c(skb, start, skb->len - start, ~0);
- *(__le32 *)(skb->data + offset) = cpu_to_le32(crc);
+ crc = ~0;
+ ret = skb_crc32c_full(skb, start, skb->len - start, &crc);
+ if (ret)
+ goto out;
+ *(__le32 *)(skb->data + offset) = cpu_to_le32(~crc);
skb_reset_csum_not_inet(skb);
out:
return ret;
diff --git a/net/core/filter.c b/net/core/filter.c
index 09c60a58c82abe..9881ac89e94c12 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3723,9 +3723,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
shinfo->gso_segs = 0;
/* Due to header growth, MSS needs to be downgraded.
- * There is a BUG_ON() when segmenting the frag_list with
- * head_frag true, so linearize the skb after downgrading
- * the MSS.
+ * Segmenting a frag_list with head_frag true at the new MSS
+ * fails and the packet gets dropped, so linearize the skb
+ * after downgrading the MSS.
*/
if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) {
skb_decrease_gso_size(shinfo, len_diff);
diff --git a/net/core/gro.c b/net/core/gro.c
index 1b033855a20db6..e2e847c95270c7 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -798,10 +798,17 @@ EXPORT_SYMBOL(napi_gro_frags);
*/
__sum16 __skb_gro_checksum_complete(struct sk_buff *skb)
{
- __wsum wsum;
+ __wsum wsum = 0;
__sum16 sum;
- wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb), 0);
+ /* If the data can't be checksummed it can't be valid either, and
+ * NAPI_GRO_CB(skb)->csum only holds the pseudo checksum.
+ */
+ if (skb_checksum_full(skb, skb_gro_offset(skb), skb_gro_len(skb),
+ &wsum)) {
+ NAPI_GRO_CB(skb)->csum_valid = 0;
+ return (__force __sum16)1;
+ }
/* NAPI_GRO_CB(skb)->csum holds pseudo checksum */
sum = csum_fold(csum_add(NAPI_GRO_CB(skb)->csum, wsum));
diff --git a/net/core/net_test.c b/net/core/net_test.c
index 2b5080c226636c..976d14896251df 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -41,6 +41,17 @@ enum gso_test_nr {
GSO_TEST_RESEGMENT_MULTI,
GSO_TEST_RESEGMENT_TAIL,
GSO_TEST_RESEGMENT_ONE_MSS,
+ GSO_TEST_FRAG_LIST_NON_UNIFORM_SG,
+ GSO_TEST_FRAG_LIST_NESTED,
+ GSO_TEST_SHORT_LINEAR,
+ GSO_TEST_SHORT_LINEAR_STRADDLE,
+ GSO_TEST_SHORT_FRAG_LIST,
+ GSO_TEST_SHORT_GSO_BY_FRAGS,
+ GSO_TEST_FRAG_LIST_NESTED_NO_SG,
+ GSO_TEST_SHORT_LINEAR_NO_SG,
+ GSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,
+ GSO_TEST_SHORT_FRAG_LIST_NO_SG,
+ GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,
};
struct gso_test_case {
@@ -58,11 +69,18 @@ struct gso_test_case {
unsigned int gso_type;
/* skbs from alloc_skb() instead of build_skb(), head_frag clear */
bool no_head_frag;
+ /* bytes that skb->len counts but the skb doesn't hold */
+ unsigned int missing_len;
+ /* segment without NETIF_F_SG */
+ bool no_sg;
/* output as expected */
unsigned int nr_segs;
const unsigned int *segs;
const unsigned int *gso_segs;
+
+ /* skb_segment() is expected to fail with this error */
+ int err;
};
static struct gso_test_case cases[] = {
@@ -241,6 +259,110 @@ static struct gso_test_case cases[] = {
},
.gso_segs = (const unsigned int[]) { 0, 0, 0, 0 },
},
+ {
+ /* frag_list members that don't end on gso_size boundaries
+ * can't be segmented with SG
+ */
+ .id = GSO_TEST_FRAG_LIST_NON_UNIFORM_SG,
+ .name = "frag_list_non_uniform_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 4,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, 1, GSO_TEST_SIZE, 2 },
+ .err = -EINVAL,
+ },
+ {
+ /* the second frag_list member hangs off the first one's
+ * frag_list instead of off the head's
+ */
+ .id = GSO_TEST_FRAG_LIST_NESTED,
+ .name = "frag_list_nested",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
+ .err = -EINVAL,
+ },
+ {
+ /* the data runs out on a segment boundary */
+ .id = GSO_TEST_SHORT_LINEAR,
+ .name = "short_linear",
+ .linear_len = GSO_TEST_SIZE,
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ /* the data runs out in the middle of a segment */
+ .id = GSO_TEST_SHORT_LINEAR_STRADDLE,
+ .name = "short_linear_straddle",
+ .linear_len = GSO_TEST_SIZE + 500,
+ .missing_len = 700,
+ .err = -EINVAL,
+ },
+ {
+ .id = GSO_TEST_SHORT_FRAG_LIST,
+ .name = "short_frag_list",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 1,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ .id = GSO_TEST_SHORT_GSO_BY_FRAGS,
+ .name = "short_gso_by_frags",
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { 100, 200 },
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ /* without SG the nested data is copied by skb_copy_bits(),
+ * which does look inside a member's own frag_list
+ */
+ .id = GSO_TEST_FRAG_LIST_NESTED_NO_SG,
+ .name = "frag_list_nested_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
+ .no_sg = true,
+ .nr_segs = 3,
+ .segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, GSO_TEST_SIZE },
+ },
+ {
+ /* without SG it is skb_copy_bits() that runs out of data */
+ .id = GSO_TEST_SHORT_LINEAR_NO_SG,
+ .name = "short_linear_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,
+ .name = "short_linear_straddle_no_sg",
+ .linear_len = GSO_TEST_SIZE + 500,
+ .missing_len = 700,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_FRAG_LIST_NO_SG,
+ .name = "short_frag_list_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 1,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,
+ .name = "short_gso_by_frags_no_sg",
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { 100, 200 },
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EINVAL,
+ },
};
static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)
@@ -337,21 +459,49 @@ static void gso_test_func(struct kunit *test)
skb->data_len += total_size;
skb->truesize += total_true_size;
- if (tcase->id == GSO_TEST_GSO_BY_FRAGS)
+ if (tcase->id == GSO_TEST_GSO_BY_FRAGS ||
+ tcase->id == GSO_TEST_SHORT_GSO_BY_FRAGS ||
+ tcase->id == GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG)
skb_shinfo(skb)->gso_size = GSO_BY_FRAGS;
+
+ if (tcase->id == GSO_TEST_FRAG_LIST_NESTED ||
+ tcase->id == GSO_TEST_FRAG_LIST_NESTED_NO_SG) {
+ struct sk_buff *first = skb_shinfo(skb)->frag_list;
+
+ skb_shinfo(first)->frag_list = first->next;
+ first->next = NULL;
+ first->len += tcase->frag_skbs[1];
+ first->data_len += tcase->frag_skbs[1];
+ }
}
+ skb->len += tcase->missing_len;
+ skb->data_len += tcase->missing_len;
+
features = NETIF_F_SG | NETIF_F_HW_CSUM;
if (tcase->id == GSO_TEST_GSO_PARTIAL)
features |= NETIF_F_GSO_PARTIAL;
- /* TODO: this should also work with SG,
- * rather than hit BUG_ON(i >= nfrags)
+ /* TODO: this should also work with SG, rather than fail the
+ * i >= nfrags check in skb_segment()
*/
- if (tcase->id == GSO_TEST_FRAG_LIST_NON_UNIFORM)
+ if (tcase->id == GSO_TEST_FRAG_LIST_NON_UNIFORM || tcase->no_sg)
features &= ~NETIF_F_SG;
SKB_GSO_CB(skb)->max_segs = tcase->max_segs;
+
+ if (tcase->err) {
+ /* the suppression block doesn't run if it can't be set up */
+ segs = NULL;
+ kunit_warning_suppress(test) {
+ segs = skb_segment(skb, features);
+ }
+ KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(segs), tcase->err);
+ if (!IS_ERR_OR_NULL(segs))
+ kfree_skb_list(segs);
+ goto free_gso_skb;
+ }
+
segs = skb_segment(skb, features);
if (IS_ERR(segs)) {
KUNIT_FAIL(test, "segs error %pe", segs);
@@ -1374,7 +1524,7 @@ static void netmem_ref_test_skb_segment(struct kunit *test)
/* 5. Linear head_skb (nr_frags=0) + mixed pp_recycle frag_list where
* member A has linear + frag (pp_recycle=1) and tail member B has
* linear len == skb_headlen(A) (pp_recycle=0): keeps SG clone path
- * synchronized without hitting BUG_ON(i >= nfrags).
+ * synchronized without failing the i >= nfrags check.
*/
head = alloc_skb(64, GFP_KERNEL);
list = alloc_skb(64, GFP_KERNEL);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 48f67641172433..29951ce11850b9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2821,9 +2821,23 @@ static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)
int delta = skb->len - len;
if (skb_frags_readable(skb)) {
- skb->csum = csum_block_sub(skb->csum,
- skb_checksum(skb, len, delta, 0),
- len);
+ __wsum csum = 0;
+ int err;
+
+ if (!skb_checksum_full(skb, len, delta, &csum)) {
+ skb->csum = csum_block_sub(skb->csum, csum, len);
+ return 0;
+ }
+
+ /* The trimmed bytes can't be checksummed, so skb->csum can't
+ * be adjusted. Software can checksum the remaining packet
+ * after trimming, as long as it can read it.
+ */
+ csum = 0;
+ err = skb_checksum_full(skb, 0, len, &csum);
+ if (err)
+ return err;
+ skb->ip_summed = CHECKSUM_NONE;
return 0;
}
@@ -3536,27 +3550,88 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
}
EXPORT_SYMBOL(skb_store_bits);
-/* Checksum skb data. */
-__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
+/* The frag_list part of skb_checksum_full(). It's out of line so that taking
+ * the address of csum2 doesn't cost every caller a stack protector.
+ */
+static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,
+ int offset, int len, int pos,
+ __wsum csum, __wsum *csump)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
+ skb_walk_frags(skb, frag_iter) {
+ int end;
+
+ WARN_ON(start > offset + len);
+
+ end = start + frag_iter->len;
+ copy = end - offset;
+ if (copy > 0) {
+ __wsum csum2 = 0;
+
+ if (copy > len)
+ copy = len;
+ err = skb_checksum_full(frag_iter, offset - start, copy,
+ &csum2);
+ if (err)
+ return err;
+ csum = csum_block_add(csum, csum2, pos);
+ len -= copy;
+ if (len == 0)
+ goto out;
+ offset += copy;
+ pos += copy;
+ }
+ start = end;
+ }
+ if (unlikely(len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EFAULT;
+ }
+out:
+ *csump = csum;
+ return 0;
+}
+
+/**
+ * skb_checksum_full - checksum a range of an skb
+ * @skb: buffer to checksum
+ * @offset: offset in @skb to start at
+ * @len: number of bytes to checksum
+ * @csump: the sum to add to; on success the range's sum is added to it
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * runs out before @len does, or if the range goes past the linear area
+ * of an skb, @skb or one on its frag_list, that has unreadable frags.
+ * On failure *@csump is not changed.
+ */
+int skb_checksum_full(const struct sk_buff *skb, int offset, int len,
+ __wsum *csump)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
+ __wsum csum = *csump;
int pos = 0;
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+
/* Checksum header. */
if (copy > 0) {
if (copy > len)
copy = len;
csum = csum_partial(skb->data + offset, copy, csum);
if ((len -= copy) == 0)
- return csum;
+ goto out;
offset += copy;
pos = copy;
}
- if (WARN_ON_ONCE(!skb_frags_readable(skb)))
- return 0;
+ if (!skb_frags_readable(skb))
+ return -EFAULT;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;
@@ -3585,52 +3660,114 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
}
if (!(len -= copy))
- return csum;
+ goto out;
offset += copy;
}
start = end;
}
+ return skb_checksum_frag_list(skb, start, offset, len, pos, csum,
+ csump);
+out:
+ *csump = csum;
+ return 0;
+}
+EXPORT_SYMBOL(skb_checksum_full);
+
+/* skb_checksum() has no way to report failure, so it returns 0, which is a
+ * valid checksum. Use skb_checksum_full() in new code.
+ */
+__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
+{
+ int err = skb_checksum_full(skb, offset, len, &csum);
+
+ if (unlikely(err)) {
+ WARN_ON_ONCE(err == -EFAULT && !skb_frags_readable(skb));
+ return 0;
+ }
+ return csum;
+}
+EXPORT_SYMBOL(skb_checksum);
+
+/* The frag_list part of skb_copy_and_csum_bits(). It's out of line so that
+ * taking the address of csum2 doesn't cost every caller a stack protector.
+ */
+static noinline int skb_copy_and_csum_frag_list(const struct sk_buff *skb,
+ int start, int offset, u8 *to,
+ int len, int pos, __wsum csum,
+ __wsum *csump)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
skb_walk_frags(skb, frag_iter) {
+ __wsum csum2;
int end;
WARN_ON(start > offset + len);
end = start + frag_iter->len;
- if ((copy = end - offset) > 0) {
- __wsum csum2;
+ copy = end - offset;
+ if (copy > 0) {
if (copy > len)
copy = len;
- csum2 = skb_checksum(frag_iter, offset - start, copy,
- 0);
+ err = skb_copy_and_csum_bits(frag_iter, offset - start,
+ to, copy, &csum2);
+ if (err) {
+ /* The child zeroed its part; zero the rest. */
+ memset(to + copy, 0, len - copy);
+ return err;
+ }
csum = csum_block_add(csum, csum2, pos);
- if ((len -= copy) == 0)
- return csum;
+ len -= copy;
+ if (len == 0)
+ goto out;
offset += copy;
+ to += copy;
pos += copy;
}
start = end;
}
if (unlikely(len)) {
DEBUG_NET_WARN_ON_ONCE(1);
- return 0;
+ /* Don't hand the caller a buffer with stale bytes in it. */
+ memset(to, 0, len);
+ return -EFAULT;
}
-
- return csum;
+out:
+ *csump = csum;
+ return 0;
}
-EXPORT_SYMBOL(skb_checksum);
-
-/* Both of above in one bottle. */
-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
- u8 *to, int len)
+/**
+ * skb_copy_and_csum_bits - copy data out of an skb and checksum it
+ * @skb: source buffer
+ * @offset: offset in @skb to start copying from
+ * @to: destination buffer
+ * @len: number of bytes to copy
+ * @csump: where to store the checksum of the copied bytes
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * has unreadable frags or runs out before @len does. On failure *@csump
+ * is not set. On -EFAULT the part of @to that couldn't be filled is
+ * zeroed, and on -EINVAL @to is not touched.
+ */
+int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
+ u8 *to, int len, __wsum *csump)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
int pos = 0;
__wsum csum = 0;
+ /* Everything below clamps its copy to @len, so a negative one would
+ * turn into a huge copy.
+ */
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+
/* Copy header. */
if (copy > 0) {
if (copy > len)
@@ -3638,7 +3775,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
csum = csum_partial_copy_nocheck(skb->data + offset, to,
copy);
if ((len -= copy) == 0)
- return csum;
+ goto out;
offset += copy;
to += copy;
pos = copy;
@@ -3646,9 +3783,8 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
if (!skb_frags_readable(skb)) {
/* Don't hand the caller a buffer with stale bytes in it. */
- if (len > 0)
- memset(to, 0, len);
- return 0;
+ memset(to, 0, len);
+ return -EFAULT;
}
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
@@ -3680,64 +3816,95 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
}
if (!(len -= copy))
- return csum;
+ goto out;
offset += copy;
to += copy;
}
start = end;
}
+ return skb_copy_and_csum_frag_list(skb, start, offset, to, len, pos,
+ csum, csump);
+out:
+ *csump = csum;
+ return 0;
+}
+EXPORT_SYMBOL(skb_copy_and_csum_bits);
+
+#ifdef CONFIG_NET_CRC32C
+/* The frag_list part of skb_crc32c_full(). It's out of line so that taking
+ * the address of crc doesn't cost every caller a stack protector.
+ */
+static noinline int skb_crc32c_frag_list(const struct sk_buff *skb, int start,
+ int offset, int len, u32 crc,
+ u32 *crcp)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
skb_walk_frags(skb, frag_iter) {
- __wsum csum2;
int end;
WARN_ON(start > offset + len);
end = start + frag_iter->len;
- if ((copy = end - offset) > 0) {
- if (copy > len)
- copy = len;
- csum2 = skb_copy_and_csum_bits(frag_iter,
- offset - start,
- to, copy);
- csum = csum_block_add(csum, csum2, pos);
- if ((len -= copy) == 0)
- return csum;
+ copy = end - offset;
+ if (copy > 0) {
+ copy = min(copy, len);
+ err = skb_crc32c_full(frag_iter, offset - start, copy,
+ &crc);
+ if (err)
+ return err;
+ len -= copy;
+ if (len == 0)
+ goto out;
offset += copy;
- to += copy;
- pos += copy;
}
start = end;
}
if (unlikely(len)) {
DEBUG_NET_WARN_ON_ONCE(1);
- /* Don't hand the caller a buffer with stale bytes in it. */
- if (len > 0)
- memset(to, 0, len);
- return 0;
+ return -EFAULT;
}
- return csum;
+out:
+ *crcp = crc;
+ return 0;
}
-EXPORT_SYMBOL(skb_copy_and_csum_bits);
-#ifdef CONFIG_NET_CRC32C
-u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
+/**
+ * skb_crc32c_full - CRC32C a range of an skb
+ * @skb: buffer to read
+ * @offset: offset in @skb to start at
+ * @len: number of bytes to include
+ * @crcp: the CRC to continue from; on success, updated with the range
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * runs out before @len does, or if the range goes past the linear area
+ * of an skb, @skb or one on its frag_list, that has unreadable frags.
+ * On failure *@crcp is not changed.
+ */
+int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
+ u32 crc = *crcp;
+
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
if (copy > 0) {
copy = min(copy, len);
crc = crc32c(crc, skb->data + offset, copy);
len -= copy;
if (len == 0)
- return crc;
+ goto out;
offset += copy;
}
- if (WARN_ON_ONCE(!skb_frags_readable(skb)))
- return 0;
+ if (!skb_frags_readable(skb))
+ return -EFAULT;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;
@@ -3762,44 +3929,57 @@ u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
}
len -= copy;
if (len == 0)
- return crc;
+ goto out;
offset += copy;
}
start = end;
}
- skb_walk_frags(skb, frag_iter) {
- int end;
+ return skb_crc32c_frag_list(skb, start, offset, len, crc, crcp);
+out:
+ *crcp = crc;
+ return 0;
+}
+EXPORT_SYMBOL(skb_crc32c_full);
- WARN_ON(start > offset + len);
+/* skb_crc32c() has no way to report failure, so it returns 0, which is a
+ * valid CRC. Use skb_crc32c_full() in new code.
+ */
+u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
+{
+ int err = skb_crc32c_full(skb, offset, len, &crc);
- end = start + frag_iter->len;
- copy = end - offset;
- if (copy > 0) {
- copy = min(copy, len);
- crc = skb_crc32c(frag_iter, offset - start, copy, crc);
- len -= copy;
- if (len == 0)
- return crc;
- offset += copy;
- }
- start = end;
- }
- if (unlikely(len)) {
- DEBUG_NET_WARN_ON_ONCE(1);
+ if (unlikely(err)) {
+ WARN_ON_ONCE(err == -EFAULT && !skb_frags_readable(skb));
return 0;
}
-
return crc;
}
EXPORT_SYMBOL(skb_crc32c);
#endif /* CONFIG_NET_CRC32C */
+/* The data can't be checksummed, so it can't be valid either. The caller has
+ * put the pseudo header's checksum in skb->csum, so don't leave the skb
+ * CHECKSUM_COMPLETE for a later validator to take that for the packet's.
+ */
+static __sum16 skb_checksum_complete_failed(struct sk_buff *skb)
+{
+ if (!skb_shared(skb)) {
+ skb_checksum_complete_unset(skb);
+ skb->csum_valid = 0;
+ }
+ return (__force __sum16)1;
+}
+
__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)
{
+ __wsum csum = skb->csum;
__sum16 sum;
- sum = csum_fold(skb_checksum(skb, 0, len, skb->csum));
+ if (skb_checksum_full(skb, 0, len, &csum))
+ return skb_checksum_complete_failed(skb);
+
+ sum = csum_fold(csum);
/* See comments in __skb_checksum_complete(). */
if (likely(!sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -3819,14 +3999,16 @@ EXPORT_SYMBOL(__skb_checksum_complete_head);
*
* It returns non-zero if the recomputed checksum is still invalid, otherwise
* zero. The new checksum is stored back into skb->csum unless the skb is
- * shared.
+ * shared. If the skb can't be checksummed it returns non-zero, skb->csum is
+ * left alone, and the skb is no longer CHECKSUM_COMPLETE unless it's shared.
*/
__sum16 __skb_checksum_complete(struct sk_buff *skb)
{
- __wsum csum;
+ __wsum csum = 0;
__sum16 sum;
- csum = skb_checksum(skb, 0, skb->len, 0);
+ if (skb_checksum_full(skb, 0, skb->len, &csum))
+ return skb_checksum_complete_failed(skb);
sum = csum_fold(csum_add(skb->csum, csum));
/* This check is inverted, because we already knew the hardware
@@ -3897,8 +4079,10 @@ EXPORT_SYMBOL_GPL(skb_zerocopy_headlen);
* Return value:
* 0: everything is OK
* -ENOMEM: couldn't orphan frags of @from due to lack of memory
- * -EFAULT: skb_copy_bits() found some problem with skb geometry, or readable head
- * payload would be mixed with unreadable frags.
+ * -EFAULT: skb_copy_bits() found some problem with skb geometry, @from has
+ * no head_frag and @hlen is 0 while @len doesn't fit in @to's tailroom,
+ * or readable head payload would be mixed with unreadable frags.
+ * -EINVAL: @len or @hlen is negative
*/
int
skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
@@ -3909,15 +4093,23 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
struct page *page;
unsigned int offset;
- if (unlikely(!from->head_frag && !hlen)) {
+ if (unlikely(len < 0 || hlen < 0)) {
DEBUG_NET_WARN_ON_ONCE(1);
- return -EFAULT;
+ return -EINVAL;
}
/* dont bother with small payloads */
if (len <= skb_tailroom(to))
return skb_copy_bits(from, 0, skb_put(to, len), len);
+ /* Without a head_frag the head can't be referenced as a page, so the
+ * caller has to ask for it to be copied.
+ */
+ if (unlikely(!from->head_frag && !hlen)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EFAULT;
+ }
+
to->pp_recycle = from->pp_recycle;
if (hlen) {
ret = skb_copy_bits(from, 0, skb_put(to, hlen), hlen);
@@ -3980,6 +4172,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
__wsum csum;
long csstart;
+ /* skb_headlen() underflows if data_len is bigger than len, and then
+ * the checks below don't bound the copy from the linear area.
+ */
+ if (unlikely(skb->data_len > skb->len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ memset(to, 0, skb->len);
+ return;
+ }
+
if (skb->ip_summed == CHECKSUM_PARTIAL)
csstart = skb_checksum_start_offset(skb);
else
@@ -4001,9 +4202,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
skb_copy_from_linear_data(skb, to, csstart);
csum = 0;
- if (csstart != skb->len)
- csum = skb_copy_and_csum_bits(skb, csstart, to + csstart,
- skb->len - csstart);
+ if (csstart != skb->len &&
+ skb_copy_and_csum_bits(skb, csstart, to + csstart,
+ skb->len - csstart, &csum)) {
+ /* Send zeroes rather than intact headers on a payload that
+ * couldn't be copied.
+ */
+ memset(to, 0, skb->len);
+ return;
+ }
if (skb->ip_summed == CHECKSUM_PARTIAL) {
long csstuff = csstart + skb->csum_offset;
@@ -4957,7 +5164,16 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
int hsize;
int size;
+ /* list_skb runs out early if head_skb->len counts data that
+ * this walk can't find: bytes that aren't there, or a member's
+ * own frag_list, which the walk never looks inside.
+ */
if (unlikely(gso_by_frags)) {
+ if (unlikely(!list_skb)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ err = -EINVAL;
+ goto err;
+ }
len = list_skb->len;
} else {
len = head_skb->len - offset;
@@ -4967,7 +5183,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
hsize = skb_headlen(head_skb) - offset;
- if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
+ if (hsize <= 0 && i >= nfrags && list_skb &&
+ skb_headlen(list_skb) &&
(skb_headlen(list_skb) == len || sg)) {
if (unlikely(skb_headlen(list_skb) > len)) {
DEBUG_NET_WARN_ON_ONCE(1);
@@ -5057,16 +5274,20 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (!csum) {
if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
- SKB_GSO_CB(nskb)->csum =
- skb_copy_and_csum_bits(head_skb, offset,
- skb_put(nskb,
- len),
- len);
+ if (skb_copy_and_csum_bits(head_skb, offset,
+ skb_put(nskb, len),
+ len,
+ &SKB_GSO_CB(nskb)->csum)) {
+ err = -EFAULT;
+ goto err;
+ }
SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset;
} else {
- if (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len))
+ if (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len)) {
+ err = -EFAULT;
goto err;
+ }
}
continue;
}
@@ -5085,6 +5306,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
while (pos < offset + len) {
if (i >= nfrags) {
+ if (unlikely(!list_skb)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ err = -EINVAL;
+ goto err;
+ }
+
if (skb_shinfo(nskb)->nr_frags &&
nskb->pp_recycle != list_skb->pp_recycle) {
nskb->data_len = pos - offset - hsize;
@@ -5175,9 +5402,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
- SKB_GSO_CB(nskb)->csum =
- skb_checksum(nskb, doffset,
- nskb->len - doffset, 0);
+ SKB_GSO_CB(nskb)->csum = 0;
+ if (skb_checksum_full(nskb, doffset,
+ nskb->len - doffset,
+ &SKB_GSO_CB(nskb)->csum)) {
+ err = -EFAULT;
+ goto err;
+ }
SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset;
}
@@ -5410,8 +5641,9 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len,
*
* Fill the specified scatter-gather list with mappings/pointers into a
* region of the buffer space attached to a socket buffer. Returns either
- * the number of scatterlist items used, or -EMSGSIZE if the contents
- * could not fit.
+ * the number of scatterlist items used, -EMSGSIZE if the contents
+ * could not fit, or -EINVAL if @offset and @len run past the end of
+ * the skb.
*/
int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
{
@@ -6281,7 +6513,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
bool *fragstolen, int *delta_truesize)
{
struct skb_shared_info *to_shinfo, *from_shinfo;
- int i, delta, len = from->len;
+ unsigned int len = from->len;
+ int i, delta;
*fragstolen = false;
@@ -6326,9 +6559,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
return false;
if (skb_headlen(from) != 0) {
- struct page *page;
- unsigned int offset;
-
if (to_shinfo->nr_frags +
from_shinfo->nr_frags >= MAX_SKB_FRAGS)
return false;
@@ -6337,13 +6567,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
return false;
delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
-
- page = virt_to_head_page(from->head);
- offset = from->data - (unsigned char *)page_address(page);
-
- skb_fill_page_desc(to, to_shinfo->nr_frags,
- page, offset, skb_headlen(from));
- *fragstolen = true;
} else {
if (to_shinfo->nr_frags +
from_shinfo->nr_frags > MAX_SKB_FRAGS)
@@ -6352,7 +6575,19 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
delta = from->truesize - SKB_TRUESIZE(skb_end_offset(from));
}
- WARN_ON_ONCE(delta < len);
+ /* @from claims more data than it has memory for. Leave @to alone. */
+ if (WARN_ON_ONCE(delta < 0 || delta < len))
+ return false;
+
+ if (skb_headlen(from) != 0) {
+ struct page *page = virt_to_head_page(from->head);
+ unsigned int offset;
+
+ offset = from->data - (unsigned char *)page_address(page);
+ skb_fill_page_desc(to, to_shinfo->nr_frags,
+ page, offset, skb_headlen(from));
+ *fragstolen = true;
+ }
memcpy(to_shinfo->frags + to_shinfo->nr_frags,
from_shinfo->frags,
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 90c0e22c29bea6..35008785e3d228 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -364,12 +364,15 @@ static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,
DEFINE_RAW_FLEX(struct icmp_bxm, icmp_param, replyopts.opt.__data,
IP_OPTIONS_DATA_FIXED_SIZE);
__wsum csum;
+ int err;
icmp_param = from;
- csum = skb_copy_and_csum_bits(icmp_param->skb,
- icmp_param->offset + offset,
- to, len);
+ err = skb_copy_and_csum_bits(icmp_param->skb,
+ icmp_param->offset + offset,
+ to, len, &csum);
+ if (err)
+ return err;
skb->csum = csum_block_add(skb->csum, csum, odd);
if (icmp_param->data.icmph.type <= NR_ICMP_TYPES &&
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 3396f177a18d09..f7da4538d05b5c 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1162,9 +1162,14 @@ static int __ip_append_data(struct sock *sk,
data += fragheaderlen + exthdrlen;
if (fraggap) {
- skb->csum = skb_copy_and_csum_bits(
- skb_prev, maxfraglen,
- data + transhdrlen, fraggap);
+ if (skb_copy_and_csum_bits(skb_prev, maxfraglen,
+ data + transhdrlen,
+ fraggap,
+ &skb->csum)) {
+ err = -EFAULT;
+ kfree_skb(skb);
+ goto error;
+ }
skb_prev->csum = csum_sub(skb_prev->csum,
skb->csum);
data += fraggap;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index a95b0351824f32..31ca3da80b1f1e 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -322,9 +322,12 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st
struct icmpv6_msg *msg = (struct icmpv6_msg *) from;
struct sk_buff *org_skb = msg->skb;
__wsum csum;
+ int err;
- csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
- to, len);
+ err = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
+ to, len, &csum);
+ if (err)
+ return err;
skb->csum = csum_block_add(skb->csum, csum, odd);
if (!(msg->type & ICMPV6_INFOMSG_MASK))
nf_ct_attach(skb, org_skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 25fe0ba98b1a6a..d259e7dca8ba21 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1724,9 +1724,14 @@ static int __ip6_append_data(struct sock *sk,
skb->transport_header = (skb->network_header +
fragheaderlen);
if (fraggap) {
- skb->csum = skb_copy_and_csum_bits(
- skb_prev, maxfraglen,
- data + transhdrlen, fraggap);
+ if (skb_copy_and_csum_bits(skb_prev, maxfraglen,
+ data + transhdrlen,
+ fraggap,
+ &skb->csum)) {
+ err = -EFAULT;
+ kfree_skb(skb);
+ goto error;
+ }
skb_prev->csum = csum_sub(skb_prev->csum,
skb->csum);
data += fraggap;
diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c
index d8d8842c7de5cd..5d780ad4ae3a03 100644
--- a/net/sunrpc/socklib.c
+++ b/net/sunrpc/socklib.c
@@ -49,7 +49,9 @@ xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)
if (desc->need_checksum) {
__wsum csum;
- csum = skb_copy_and_csum_bits(desc->skb, desc->offset, to, len);
+ if (unlikely(skb_copy_and_csum_bits(desc->skb, desc->offset,
+ to, len, &csum)))
+ return 0;
desc->csum = csum_block_add(desc->csum, csum, desc->offset);
} else {
if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len)))
@@ -142,11 +144,6 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
if (xdr_partial_copy_from_skb(xdr, &desc) < 0)
return -1;
- if (desc.offset != skb->len) {
- __wsum csum2;
- csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
- desc.csum = csum_block_add(desc.csum, csum2, desc.offset);
- }
if (desc.count)
return -1;
if (csum_fold(desc.csum))
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 771e02bff51999..748ae27f2b881c 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -142,12 +142,16 @@ static int __skb_nsg(struct sk_buff *skb, int offset, int len,
start = end;
}
}
- BUG_ON(len);
+ if (unlikely(len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
return elt;
}
/* Return the number of scatterlist elements required to completely map the
- * skb, or -EMSGSIZE if the recursion depth is exceeded.
+ * skb, -EMSGSIZE if the recursion depth is exceeded, or -EINVAL if the skb
+ * runs out before @len does.
*/
static int skb_nsg(struct sk_buff *skb, int offset, int len)
{
|
| 3/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19844 output: 37 thoughts: 1207 Thoughts: **Analysis of Kernel Patch Series: Fuzzing Target Identification** Okay, so the user wants me to evaluate this patch series applied as HEAD in the kernel repo. My initial thought is to figure out the scope of these changes. Let's see... what files are touched? Ah, okay: `drivers/net/ethernet/sun/sunvnet_common.c`, `drivers/net/xen-netfront.c`, `include/linux/skbuff.h`, `net/core/dev.c`, `net/core/filter.c`, `net/core/gro.c`, `net/core/net_test.c`, `net/core/skbuff.c`, `net/ipv4/icmp.c`, `net/ipv4/ip_output.c`, `net/ipv6/icmp.c`, `net/ipv6/ip6_output.c`, `net/sunrpc/socklib.c`, and `net/tls/tls_sw.c`. Hmm, a fairly wide range, but primarily networking. Aha! This is a good sign. Looks like the patch is making changes to core networking SKB handling: `skb_checksum_full`, `skb_checksum`, `skb_copy_and_csum_bits`, `skb_crc32c_full`, `skb_segment`, and many others. It's messing with fundamental stuff in `net/core/skbuff.c`, `net/core/dev.c`, `net/ipv4/`, `net/ipv6/`, `net/tls/`, etc. This looks like *really* reachable core networking code. This involves new checks, error handling, new functions like `skb_checksum_full` and `skb_crc32c_full`, plus some `DEBUG_NET_WARN_ON_ONCE` assertions and changes to return values and signatures like with `skb_copy_and_csum_bits`. Given the scope of these changes and that they involve changes to checksum and CRC calculation, I'm thinking this definitely warrants fuzzing. The changes are fundamental and potentially introduce subtle bugs. So, `WorthFuzzing = true`. Now, let's nail down a fuzzing strategy. First, target architecture is amd64. Easy enough. Next is reachability. We are dealing with core networking code, so this should be reachable through VFS/sockets/netlink/tun/tap/loopback, etc. That's a good set of entry points. Now, let's get into those FocusSymbols. We need specific, non-ubiquitous functions. I need to figure out which functions were modified or added. Let's dig into that: In `net/core/skbuff.c`: We have `skb_checksum_full` (newly added function, exported), `skb_checksum_frag_list` (static helper), `skb_copy_and_csum_bits` (modified signature and behavior), `skb_copy_and_csum_frag_list` (static helper), `skb_crc32c_full` (newly added function), `skb_crc32c_frag_list` (static helper), `pskb_trim_rcsum_complete` (static) -> called by `pskb_trim_rcsum`, `skb_copy_and_csum_dev`, `skb_segment`, `skb_zerocopy`, `skb_try_coalesce`, `__skb_checksum_complete`, and `__skb_checksum_complete_head`. In `net/core/dev.c`: `skb_checksum_help` and `skb_crc32c_csum_help`. In `net/core/gro.c`: `__skb_gro_checksum_complete`. In `net/ipv4/icmp.c`: `icmp_glue_bits` (static). In `net/ipv4/ip_output.c`: `__ip_append_data`. In `net/ipv6/icmp.c`: `icmpv6_getfrag`. In `net/ipv6/ip6_output.c`: `__ip6_append_data`. In `net/sunrpc/socklib.c`: `xdr_skb_read_bits` and `csum_partial_copy_to_xdr`. In `net/tls/tls_sw.c`: `__skb_nsg` / `skb_nsg`. In `drivers/net/xen-netfront.c`: `bounce_skb`. Now, |
| 4/2 | 2026/11/07 14:34 | tool | grepper |
0mArgs:{
"Expression": "^int skb_checksum_full",
"PathPrefixes": [
"net/core/skbuff.c"
]
}Results: {
"Output": "net/core/skbuff.c=3556=static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,\n--\nnet/core/skbuff.c-3608- */\nnet/core/skbuff.c:3609:int skb_checksum_full(const struct sk_buff *skb, int offset, int len,\nnet/core/skbuff.c-3610-\t\t __wsum *csump)\n"
} |
| 5/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22246 output: 30 thoughts: 404 Thoughts: **Analyzing Potential Targets for Network Fuzzing** Okay, let's dive in. My initial thought is to examine a handful of functions related to SKBs. I'm focusing on the following candidates: `skb_segment`, `skb_checksum_help`, `skb_crc32c_csum_help`, `skb_copy_and_csum_bits`, `skb_checksum_full`, `skb_crc32c_full`, `skb_try_coalesce`, and `skb_zerocopy`. My gut feeling is that `skb_checksum_full` and `skb_copy_and_csum_bits` are going to be fruitful targets, so let's check for their ubiquity. Now, while `skb_checksum` is probably quite common across the networking stack, `skb_copy_and_csum_bits` seems much more specialized, which might make it a prime candidate for uncovering less-obvious vulnerabilities. `skb_segment` immediately caught my eye - GSO segmentation! This looks like a goldmine for syzkaller network fuzzing. There are several interesting angles to explore there, relating to GSO/GRO, virtio_net, and tun/tap. What about `skb_checksum_help`? Aha, this is used in the TX path when the device doesn't support hardware checksumming, or for specific tunnel scenarios. That warrants a deeper look. `skb_crc32c_csum_help` is used in SCTP checksumming. That's another specific area I'll need to remember. `skb_try_coalesce` deals with TCP and SKB coalescing. This could reveal interesting interactions and potential race conditions. And finally, `skb_zerocopy` also merits investigation. Oh, and there's `__skb_gro_checksum_complete` – a checksum path specifically for GRO. Worth noting! Now, I need to check the relevant Kconfig options. In `net/core/skbuff.c`, I see that `#ifdef CONFIG_NET_CRC32C` surrounds `skb_crc32c_full` and `skb_crc32c`. I'll need to figure out where `CONFIG_NET_CRC32C` is defined in the Kconfig hierarchy. |
| 6/2 | 2026/11/07 14:34 | tool | grepper |
0mArgs:{
"Expression": "config NET_CRC32C",
"PathPrefixes": [
"net/"
]
}Results: {
"Output": "net/Kconfig=74=config NET_SHAPER\n--\nnet/Kconfig-76-\nnet/Kconfig:77:config NET_CRC32C\nnet/Kconfig-78-\tbool\n"
} |
| 7/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23260 output: 31 thoughts: 16 Thoughts: Okay, let's dive into this. I'm going to pull up the `net/Kconfig` file, specifically around line 77. My intention here is to understand a specific configuration option or section within the network subsystem. Given that it's `Kconfig`, I'm expecting to see definitions for kernel configuration options, dependencies, help text, and likely some default values. I'll need to analyze the surrounding context to get a clear picture of what this particular section is intended to do, and which dependencies or constraints apply. The goal is to fully grasp the scope and implications of the code at that specific line. |
| 8/2 | 2026/11/07 14:34 | tool | read-file |
0mArgs:{
"File": "net/Kconfig",
"FirstLine": 75,
"LineCount": 20
}Results: {
"Contents": " 75:\t\tbool\n 76:\t\n 77:\tconfig NET_CRC32C\n 78:\t\tbool\n 79:\t\tselect CRC32\n 80:\t\n 81:\tmenu \"Networking options\"\n 82:\t\n 83:\tsource \"net/packet/Kconfig\"\n 84:\tsource \"net/psp/Kconfig\"\n 85:\tsource \"net/unix/Kconfig\"\n 86:\tsource \"net/tls/Kconfig\"\n 87:\tsource \"net/xfrm/Kconfig\"\n 88:\tsource \"net/iucv/Kconfig\"\n 89:\tsource \"net/smc/Kconfig\"\n 90:\tsource \"drivers/dibs/Kconfig\"\n 91:\tsource \"net/xdp/Kconfig\"\n 92:\t\n 93:\tconfig NET_HANDSHAKE\n 94:\t\tbool\n"
} |
| 9/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23683 output: 21 thoughts: 25 Thoughts: Here's my thought process, as if I were considering this myself: **Investigating the `NET_CRC32C` Configuration Option** Okay, so I need to figure out the dependencies or the rationale behind enabling `NET_CRC32C`. I want to know who is pulling in this specific CRC32C option during configuration. My immediate instinct is to dig into the Kconfig files. I know the standard way to trace this is by searching for its selection. Let's fire up `grep` and search the kernel source for the phrase "`select NET_CRC32C`". That should reveal which other configurations, or perhaps which modules or subsystems, explicitly choose to include it. This will provide valuable insight to understand the broader context and dependencies surrounding `NET_CRC32C`. |
| 10/2 | 2026/11/07 14:34 | tool | grepper |
0mArgs:{
"Expression": "select NET_CRC32C"
}Results: {
"Output": "drivers/infiniband/sw/siw/Kconfig=1=config RDMA_SIW\n--\ndrivers/infiniband/sw/siw/Kconfig-5-\tselect CRC32\ndrivers/infiniband/sw/siw/Kconfig:6:\tselect NET_CRC32C\ndrivers/infiniband/sw/siw/Kconfig-7-\thelp\n--\ndrivers/nvme/host/Kconfig=83=config NVME_TCP\n--\ndrivers/nvme/host/Kconfig-87-\tselect CRC32\ndrivers/nvme/host/Kconfig:88:\tselect NET_CRC32C\ndrivers/nvme/host/Kconfig-89-\tselect NVME_FABRICS\n--\nnet/batman-adv/Kconfig=34=config BATMAN_ADV_BLA\n--\nnet/batman-adv/Kconfig-37-\tselect CRC16\nnet/batman-adv/Kconfig:38:\tselect NET_CRC32C\nnet/batman-adv/Kconfig-39-\tdefault y\n--\nnet/netfilter/Kconfig=201=config NF_CT_PROTO_SCTP\n--\nnet/netfilter/Kconfig-204-\tdefault y\nnet/netfilter/Kconfig:205:\tselect NET_CRC32C\nnet/netfilter/Kconfig-206-\thelp\n--\nnet/netfilter/Kconfig=455=config NF_TABLES\nnet/netfilter/Kconfig-456-\tselect NETFILTER_NETLINK\nnet/netfilter/Kconfig:457:\tselect NET_CRC32C\nnet/netfilter/Kconfig-458-\ttristate \"Netfilter nf_tables support\"\n--\nnet/netfilter/ipvs/Kconfig=106=config IP_VS_PROTO_SCTP\nnet/netfilter/ipvs/Kconfig-107-\tbool \"SCTP load balancing support\"\nnet/netfilter/ipvs/Kconfig:108:\tselect NET_CRC32C\nnet/netfilter/ipvs/Kconfig-109-\thelp\n--\nnet/openvswitch/Kconfig=6=config OPENVSWITCH\n--\nnet/openvswitch/Kconfig-14-\tselect MPLS\nnet/openvswitch/Kconfig:15:\tselect NET_CRC32C\nnet/openvswitch/Kconfig-16-\tselect NET_MPLS_GSO\n--\nnet/sched/Kconfig=808=config NET_ACT_CSUM\n--\nnet/sched/Kconfig-810-\tdepends on NET_CLS_ACT \u0026\u0026 INET\nnet/sched/Kconfig:811:\tselect NET_CRC32C\nnet/sched/Kconfig-812-\thelp\n--\nnet/sctp/Kconfig=6=menuconfig IP_SCTP\n--\nnet/sctp/Kconfig-11-\tselect CRYPTO_LIB_UTILS\nnet/sctp/Kconfig:12:\tselect NET_CRC32C\nnet/sctp/Kconfig-13-\tselect NET_UDP_TUNNEL\n"
} |
| 11/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24682 output: 28 thoughts: 163 Thoughts: **Kernel Configuration Dependencies: A Quick Audit** Okay, so I'm looking at these kernel modules and their dependencies. It's becoming a bit of a dance, isn't it? Let's see... `IP_SCTP`, `NF_TABLES`, and `OPENVSWITCH` all pull in `NET_CRC32C`. No surprises there; these are fairly standard dependencies. But now I'm thinking, what about other areas? Let's check `net/tls/tls_sw.c`. Ah, right, that's expecting `CONFIG_TLS`. Seems logical. And what about the IPv6 stack, located under `net/ipv6/`? It stands to reason that one needs `CONFIG_IPV6`, so I'll check that. And, of course, the IPv4 stack (`net/ipv4/`) is going to need `CONFIG_INET`. Need to remember that. Now, I'm thinking more broadly – what about some of the more niche or specialized drivers? Let's consider `sunvnet` or `xen-netfront`? Let me look at `sunvnet_common.c`. Alright, so that's obviously related to the SUNVNET driver, designed for SPARC hypervisor virtual networks, or something similar. Time to delve into the `sunvnet_common.c` Kconfig file to confirm what exactly is needed. |
| 12/2 | 2026/11/07 14:34 | tool | grepper |
0mArgs:{
"Expression": "sunvnet",
"PathPrefixes": [
"drivers/net/"
]
}Results: {
"Output": "\nFull output is too long, showing 200 out of 341 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (5 files in total):\ndrivers/net/ethernet/sun/Makefile:2\ndrivers/net/ethernet/sun/ldmvsw.c:18\ndrivers/net/ethernet/sun/sunvnet.c:21\ndrivers/net/ethernet/sun/sunvnet_common.c:41\ndrivers/net/ethernet/sun/sunvnet_common.h:17\n\ndrivers/net/ethernet/sun/Makefile=10=obj-$(CONFIG_CASSINI) += cassini.o\ndrivers/net/ethernet/sun/Makefile:11:obj-$(CONFIG_SUNVNET_COMMON) += sunvnet_common.o\ndrivers/net/ethernet/sun/Makefile:12:obj-$(CONFIG_SUNVNET) += sunvnet.o\ndrivers/net/ethernet/sun/Makefile-13-obj-$(CONFIG_LDMVSW) += ldmvsw.o\n--\ndrivers/net/ethernet/sun/ldmvsw.c-32-\ndrivers/net/ethernet/sun/ldmvsw.c:33:/* This driver makes use of the common code in sunvnet_common.c */\ndrivers/net/ethernet/sun/ldmvsw.c:34:#include \"sunvnet_common.h\"\ndrivers/net/ethernet/sun/ldmvsw.c-35-\n--\ndrivers/net/ethernet/sun/ldmvsw.c=115=static netdev_tx_t vsw_start_xmit(struct sk_buff *skb, struct net_device *dev)\ndrivers/net/ethernet/sun/ldmvsw.c-116-{\ndrivers/net/ethernet/sun/ldmvsw.c:117:\treturn sunvnet_start_xmit_common(skb, dev, vsw_tx_port_find);\ndrivers/net/ethernet/sun/ldmvsw.c-118-}\n--\ndrivers/net/ethernet/sun/ldmvsw.c=120=static void vsw_set_rx_mode(struct net_device *dev)\n--\ndrivers/net/ethernet/sun/ldmvsw.c-123-\ndrivers/net/ethernet/sun/ldmvsw.c:124:\treturn sunvnet_set_rx_mode_common(dev, port-\u003evp);\ndrivers/net/ethernet/sun/ldmvsw.c-125-}\n--\ndrivers/net/ethernet/sun/ldmvsw.c=141=static void vsw_poll_controller(struct net_device *dev)\n--\ndrivers/net/ethernet/sun/ldmvsw.c-144-\ndrivers/net/ethernet/sun/ldmvsw.c:145:\treturn sunvnet_poll_controller_common(dev, port-\u003evp);\ndrivers/net/ethernet/sun/ldmvsw.c-146-}\n--\ndrivers/net/ethernet/sun/ldmvsw.c=149=static const struct net_device_ops vsw_ops = {\ndrivers/net/ethernet/sun/ldmvsw.c-150-\t.ndo_open\t\t= ldmvsw_open,\ndrivers/net/ethernet/sun/ldmvsw.c:151:\t.ndo_stop\t\t= sunvnet_close_common,\ndrivers/net/ethernet/sun/ldmvsw.c-152-\t.ndo_set_rx_mode\t= vsw_set_rx_mode,\ndrivers/net/ethernet/sun/ldmvsw.c:153:\t.ndo_set_mac_address\t= sunvnet_set_mac_addr_common,\ndrivers/net/ethernet/sun/ldmvsw.c-154-\t.ndo_validate_addr\t= eth_validate_addr,\ndrivers/net/ethernet/sun/ldmvsw.c:155:\t.ndo_tx_timeout\t\t= sunvnet_tx_timeout_common,\ndrivers/net/ethernet/sun/ldmvsw.c-156-\t.ndo_start_xmit\t\t= vsw_start_xmit,\n--\ndrivers/net/ethernet/sun/ldmvsw.c=260=static struct ldc_channel_config vsw_ldc_cfg = {\ndrivers/net/ethernet/sun/ldmvsw.c:261:\t.event\t\t= sunvnet_event_common,\ndrivers/net/ethernet/sun/ldmvsw.c-262-\t.mtu\t\t= 64,\n--\ndrivers/net/ethernet/sun/ldmvsw.c=266=static struct vio_driver_ops vsw_vio_ops = {\ndrivers/net/ethernet/sun/ldmvsw.c:267:\t.send_attr\t\t= sunvnet_send_attr_common,\ndrivers/net/ethernet/sun/ldmvsw.c:268:\t.handle_attr\t\t= sunvnet_handle_attr_common,\ndrivers/net/ethernet/sun/ldmvsw.c:269:\t.handshake_complete\t= sunvnet_handshake_complete_common,\ndrivers/net/ethernet/sun/ldmvsw.c-270-};\n--\ndrivers/net/ethernet/sun/ldmvsw.c=275=static int vsw_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)\n--\ndrivers/net/ethernet/sun/ldmvsw.c-341-\t * rather than the net_device in the vnet (which is used\ndrivers/net/ethernet/sun/ldmvsw.c:342:\t * by sunvnet). This bit is used by the VNET_PORT_TO_NET_DEVICE\ndrivers/net/ethernet/sun/ldmvsw.c-343-\t * macro.\n--\ndrivers/net/ethernet/sun/ldmvsw.c-358-\ndrivers/net/ethernet/sun/ldmvsw.c:359:\tnetif_napi_add(dev, \u0026port-\u003enapi, sunvnet_poll_common);\ndrivers/net/ethernet/sun/ldmvsw.c-360-\n--\ndrivers/net/ethernet/sun/ldmvsw.c-364-\ndrivers/net/ethernet/sun/ldmvsw.c:365:\ttimer_setup(\u0026port-\u003eclean_timer, sunvnet_clean_timer_expire_common, 0);\ndrivers/net/ethernet/sun/ldmvsw.c-366-\n--\ndrivers/net/ethernet/sun/ldmvsw.c-373-\tspin_lock_irqsave(\u0026vp-\u003elock, flags);\ndrivers/net/ethernet/sun/ldmvsw.c:374:\tsunvnet_port_add_txq_common(port);\ndrivers/net/ethernet/sun/ldmvsw.c-375-\tspin_unlock_irqrestore(\u0026vp-\u003elock, flags);\n--\ndrivers/net/ethernet/sun/ldmvsw.c=405=static void vsw_port_remove(struct vio_dev *vdev)\n--\ndrivers/net/ethernet/sun/ldmvsw.c-420-\t\tspin_lock_irqsave(\u0026port-\u003evp-\u003elock, flags);\ndrivers/net/ethernet/sun/ldmvsw.c:421:\t\tsunvnet_port_rm_txq_common(port);\ndrivers/net/ethernet/sun/ldmvsw.c-422-\t\tspin_unlock_irqrestore(\u0026port-\u003evp-\u003elock, flags);\ndrivers/net/ethernet/sun/ldmvsw.c-423-\t\tnetif_napi_del(\u0026port-\u003enapi);\ndrivers/net/ethernet/sun/ldmvsw.c:424:\t\tsunvnet_port_free_tx_bufs_common(port);\ndrivers/net/ethernet/sun/ldmvsw.c-425-\t\tvio_ldc_free(\u0026port-\u003evio);\n--\ndrivers/net/ethernet/sun/sunvnet.c-1-// SPDX-License-Identifier: GPL-2.0\ndrivers/net/ethernet/sun/sunvnet.c:2:/* sunvnet.c: Sun LDOM Virtual Network Driver.\ndrivers/net/ethernet/sun/sunvnet.c-3- *\n--\ndrivers/net/ethernet/sun/sunvnet.c-33-\ndrivers/net/ethernet/sun/sunvnet.c:34:#include \"sunvnet_common.h\"\ndrivers/net/ethernet/sun/sunvnet.c-35-\n--\ndrivers/net/ethernet/sun/sunvnet.c-40-\ndrivers/net/ethernet/sun/sunvnet.c:41:#define DRV_MODULE_NAME\t\t\"sunvnet\"\ndrivers/net/ethernet/sun/sunvnet.c-42-#define DRV_MODULE_VERSION\t\"2.0\"\n--\ndrivers/net/ethernet/sun/sunvnet.c=191=static struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb)\n--\ndrivers/net/ethernet/sun/sunvnet.c-197-\thlist_for_each_entry_rcu(port, hp, hash) {\ndrivers/net/ethernet/sun/sunvnet.c:198:\t\tif (!sunvnet_port_is_up_common(port))\ndrivers/net/ethernet/sun/sunvnet.c-199-\t\t\tcontinue;\n--\ndrivers/net/ethernet/sun/sunvnet.c-205-\t\t\tcontinue;\ndrivers/net/ethernet/sun/sunvnet.c:206:\t\tif (!sunvnet_port_is_up_common(port))\ndrivers/net/ethernet/sun/sunvnet.c-207-\t\t\tcontinue;\n--\ndrivers/net/ethernet/sun/sunvnet.c=235=static netdev_tx_t vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)\ndrivers/net/ethernet/sun/sunvnet.c-236-{\ndrivers/net/ethernet/sun/sunvnet.c:237:\treturn sunvnet_start_xmit_common(skb, dev, vnet_tx_port_find);\ndrivers/net/ethernet/sun/sunvnet.c-238-}\n--\ndrivers/net/ethernet/sun/sunvnet.c=240=static void vnet_set_rx_mode(struct net_device *dev)\n--\ndrivers/net/ethernet/sun/sunvnet.c-243-\ndrivers/net/ethernet/sun/sunvnet.c:244:\treturn sunvnet_set_rx_mode_common(dev, vp);\ndrivers/net/ethernet/sun/sunvnet.c-245-}\n--\ndrivers/net/ethernet/sun/sunvnet.c=248=static void vnet_poll_controller(struct net_device *dev)\n--\ndrivers/net/ethernet/sun/sunvnet.c-251-\ndrivers/net/ethernet/sun/sunvnet.c:252:\treturn sunvnet_poll_controller_common(dev, vp);\ndrivers/net/ethernet/sun/sunvnet.c-253-}\n--\ndrivers/net/ethernet/sun/sunvnet.c=256=static const struct net_device_ops vnet_ops = {\ndrivers/net/ethernet/sun/sunvnet.c:257:\t.ndo_open\t\t= sunvnet_open_common,\ndrivers/net/ethernet/sun/sunvnet.c:258:\t.ndo_stop\t\t= sunvnet_close_common,\ndrivers/net/ethernet/sun/sunvnet.c-259-\t.ndo_set_rx_mode\t= vnet_set_rx_mode,\ndrivers/net/ethernet/sun/sunvnet.c:260:\t.ndo_set_mac_address\t= sunvnet_set_mac_addr_common,\ndrivers/net/ethernet/sun/sunvnet.c-261-\t.ndo_validate_addr\t= eth_validate_addr,\ndrivers/net/ethernet/sun/sunvnet.c:262:\t.ndo_tx_timeout\t\t= sunvnet_tx_timeout_common,\ndrivers/net/ethernet/sun/sunvnet.c-263-\t.ndo_start_xmit\t\t= vnet_start_xmit,\n--\ndrivers/net/ethernet/sun/sunvnet.c=397=static struct ldc_channel_config vnet_ldc_cfg = {\ndrivers/net/ethernet/sun/sunvnet.c:398:\t.event\t\t= sunvnet_event_common,\ndrivers/net/ethernet/sun/sunvnet.c-399-\t.mtu\t\t= 64,\n--\ndrivers/net/ethernet/sun/sunvnet.c=403=static struct vio_driver_ops vnet_vio_ops = {\ndrivers/net/ethernet/sun/sunvnet.c:404:\t.send_attr\t\t= sunvnet_send_attr_common,\ndrivers/net/ethernet/sun/sunvnet.c:405:\t.handle_attr\t\t= sunvnet_handle_attr_common,\ndrivers/net/ethernet/sun/sunvnet.c:406:\t.handshake_complete\t= sunvnet_handshake_complete_common,\ndrivers/net/ethernet/sun/sunvnet.c-407-};\n--\ndrivers/net/ethernet/sun/sunvnet.c=411=static int vnet_port_probe(struct vio_dev *vdev, const struct vio_device_id *id)\n--\ndrivers/net/ethernet/sun/sunvnet.c-458-\ndrivers/net/ethernet/sun/sunvnet.c:459:\tnetif_napi_add(port-\u003evp-\u003edev, \u0026port-\u003enapi, sunvnet_poll_common);\ndrivers/net/ethernet/sun/sunvnet.c-460-\n--\ndrivers/net/ethernet/sun/sunvnet.c-477-\t\t\t \u0026vp-\u003eport_hash[vnet_hashfn(port-\u003eraddr)]);\ndrivers/net/ethernet/sun/sunvnet.c:478:\tsunvnet_port_add_txq_common(port);\ndrivers/net/ethernet/sun/sunvnet.c-479-\tspin_unlock_irqrestore(\u0026vp-\u003elock, flags);\n--\ndrivers/net/ethernet/sun/sunvnet.c-485-\ndrivers/net/ethernet/sun/sunvnet.c:486:\ttimer_setup(\u0026port-\u003eclean_timer, sunvnet_clean_timer_expire_common, 0);\ndrivers/net/ethernet/sun/sunvnet.c-487-\n--\ndrivers/net/ethernet/sun/sunvnet.c=503=static void vnet_port_remove(struct vio_dev *vdev)\n--\ndrivers/net/ethernet/sun/sunvnet.c-516-\t\ttimer_shutdown_sync(\u0026port-\u003eclean_timer);\ndrivers/net/ethernet/sun/sunvnet.c:517:\t\tsunvnet_port_rm_txq_common(port);\ndrivers/net/ethernet/sun/sunvnet.c-518-\t\tnetif_napi_del(\u0026port-\u003enapi);\ndrivers/net/ethernet/sun/sunvnet.c:519:\t\tsunvnet_port_free_tx_bufs_common(port);\ndrivers/net/ethernet/sun/sunvnet.c-520-\t\tvio_ldc_free(\u0026port-\u003evio);\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-1-// SPDX-License-Identifier: GPL-2.0\ndrivers/net/ethernet/sun/sunvnet_common.c:2:/* sunvnet.c: Sun LDOM Virtual Network Driver.\ndrivers/net/ethernet/sun/sunvnet_common.c-3- *\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-20-#define CREATE_TRACE_POINTS\ndrivers/net/ethernet/sun/sunvnet_common.c:21:#include \u003ctrace/events/sunvnet.h\u003e\ndrivers/net/ethernet/sun/sunvnet_common.c-22-\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-34-\ndrivers/net/ethernet/sun/sunvnet_common.c:35:#include \"sunvnet_common.h\"\ndrivers/net/ethernet/sun/sunvnet_common.c-36-\n--\ndrivers/net/ethernet/sun/sunvnet_common.c=67=static int vnet_port_alloc_tx_ring(struct vnet_port *port);\ndrivers/net/ethernet/sun/sunvnet_common.c-68-\ndrivers/net/ethernet/sun/sunvnet_common.c:69:int sunvnet_send_attr_common(struct vio_driver_state *vio)\ndrivers/net/ethernet/sun/sunvnet_common.c-70-{\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-129-}\ndrivers/net/ethernet/sun/sunvnet_common.c:130:EXPORT_SYMBOL_GPL(sunvnet_send_attr_common);\ndrivers/net/ethernet/sun/sunvnet_common.c-131-\n--\ndrivers/net/ethernet/sun/sunvnet_common.c=233=static int handle_attr_nack(struct vio_driver_state *vio,\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-240-\ndrivers/net/ethernet/sun/sunvnet_common.c:241:int sunvnet_handle_attr_common(struct vio_driver_state *vio, void *arg)\ndrivers/net/ethernet/sun/sunvnet_common.c-242-{\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-258-}\ndrivers/net/ethernet/sun/sunvnet_common.c:259:EXPORT_SYMBOL_GPL(sunvnet_handle_attr_common);\ndrivers/net/ethernet/sun/sunvnet_common.c-260-\ndrivers/net/ethernet/sun/sunvnet_common.c:261:void sunvnet_handshake_complete_common(struct vio_driver_state *vio)\ndrivers/net/ethernet/sun/sunvnet_common.c-262-{\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-272-}\ndrivers/net/ethernet/sun/sunvnet_common.c:273:EXPORT_SYMBOL_GPL(sunvnet_handshake_complete_common);\ndrivers/net/ethernet/sun/sunvnet_common.c-274-\n--\ndrivers/net/ethernet/sun/sunvnet_common.c=760=static void maybe_tx_wakeup(struct vnet_port *port)\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-771-\ndrivers/net/ethernet/sun/sunvnet_common.c:772:bool sunvnet_port_is_up_common(struct vnet_port *vnet)\ndrivers/net/ethernet/sun/sunvnet_common.c-773-{\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-777-}\ndrivers/net/ethernet/sun/sunvnet_common.c:778:EXPORT_SYMBOL_GPL(sunvnet_port_is_up_common);\ndrivers/net/ethernet/sun/sunvnet_common.c-779-\ndrivers/net/ethernet/sun/sunvnet_common.c=780=static int vnet_event_napi(struct vnet_port *port, int budget)\n\n"
} |
| 13/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30261 output: 29 thoughts: 20 Thoughts: Here's my analysis of the provided text, rendered as a first-person expert summary: **Digging into the SUNVNET_COMMON Configuration** Okay, so the directive is to examine the `drivers/net/ethernet/sun/Kconfig` file, specifically focusing on the `SUNVNET_COMMON` configuration option. Right, this immediately tells me we're looking at the network configuration options related to Sun Microsystems (or legacy Sun hardware, depending on the kernel version). `Kconfig` files are the heart of the kernel's build system and the user's configuration interface. I'm thinking: this suggests we are in the configuration space for configuring the driver for a Virtual Network Interface card, and it is likely that the `SUNVNET_COMMON` option is a base or common component that several other sun virtual network interfaces inherit or depend on. My initial questions are: What exactly does `SUNVNET_COMMON` control? Is it enabling the core VNET functionality, common registers, or perhaps a set of helper functions or data structures used by all the Sun-specific Ethernet drivers? Are there dependencies I need to be aware of? Are there other `Kconfig` options that rely on this one, which will have a direct impact on the available configuration options? I'm expecting to see things like: * **Dependencies:** `depends on` statements indicating hardware features or other modules this common code requires. * **Default values:** Perhaps it provides a default configuration for some aspect of VNET, and I'll need to figure out when to override them. * **Help text:** Hopefully, there's clear and concise help text that explains what enabling/disabling `SUNVNET_COMMON` actually *does* for the system. * **Conditional compilation:** This might define the inclusion of certain code sections or features, depending on the configuration. Alright, time to get into the details and see what this `Kconfig` file reveals. |
| 14/2 | 2026/11/07 14:34 | tool | grepper |
0mArgs:{
"Expression": "config SUNVNET",
"PathPrefixes": [
"drivers/net/"
]
}Results: {
"Output": "drivers/net/ethernet/sun/Kconfig=65=config CASSINI\n--\ndrivers/net/ethernet/sun/Kconfig-72-\ndrivers/net/ethernet/sun/Kconfig:73:config SUNVNET_COMMON\ndrivers/net/ethernet/sun/Kconfig-74-\ttristate \"Common routines to support Sun Virtual Networking\"\n--\ndrivers/net/ethernet/sun/Kconfig-78-\ndrivers/net/ethernet/sun/Kconfig:79:config SUNVNET\ndrivers/net/ethernet/sun/Kconfig-80-\ttristate \"Sun Virtual Network support\"\n"
} |
| 15/2 | 2026/11/07 14:34 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30893 output: 38 thoughts: 23 Thoughts: Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person: **Navigating the Network Driver Configuration Landscape** Alright, so the task at hand seems to involve configuring or examining a network driver. Specifically, I need to dive into `drivers/net/ethernet/sun/Kconfig`, and my initial focus is around line 70. This suggests I'm likely looking at the configuration options for a Sun Ethernet adapter, or perhaps some dependency related to it. Line 70 could be the start of a specific feature, a hardware variant, or perhaps a dependency declaration for a particular feature set. I need to understand what's defined there in order to proceed. I might be looking to enable, disable, understand the implications of a particular setting, or perhaps debug an issue related to this driver. My familiarity with the Kconfig system means I know what to expect - dependencies, defaults, prompts, and help text are all likely candidates for what awaits me. Let's dig in and see what's what. |
| 16/2 | 2026/11/07 14:35 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/sun/Kconfig",
"FirstLine": 70,
"LineCount": 25
}Results: {
"Contents": " 70:\t\t Support for the Sun Cassini chip, aka Sun GigaSwift Ethernet. See also\n 71:\t\t \u003chttp://docs.oracle.com/cd/E19113-01/giga.ether.pci/817-4341-10/817-4341-10.pdf\u003e.\n 72:\t\n 73:\tconfig SUNVNET_COMMON\n 74:\t\ttristate \"Common routines to support Sun Virtual Networking\"\n 75:\t\tdepends on SUN_LDOMS\n 76:\t\tdepends on INET\n 77:\t\tdefault m\n 78:\t\n 79:\tconfig SUNVNET\n 80:\t\ttristate \"Sun Virtual Network support\"\n 81:\t\tdefault m\n 82:\t\tdepends on SUN_LDOMS\n 83:\t\tdepends on SUNVNET_COMMON\n 84:\t\thelp\n 85:\t\t Support for virtual network devices under Sun Logical Domains.\n 86:\t\n 87:\tconfig LDMVSW\n 88:\t\ttristate \"Sun4v LDoms Virtual Switch support\"\n 89:\t\tdefault m\n 90:\t\tdepends on SUN_LDOMS\n 91:\t\tdepends on SUNVNET_COMMON\n 92:\t\thelp\n 93:\t\t Support for virtual switch devices under Sun4v Logical Domains.\n 94:\t\t This driver adds a network interface for every vsw-port node\n"
} |
| 17/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31544 output: 28 thoughts: 1274 Thoughts: **Refactoring of SKB Checksum and Copy Operations** Okay, so I'm looking at this patch series and my initial thought is, this seems significant. SUN_LDOMS is just one of the call sites impacted, but that's not the whole story. The real meat of it is in `net/core/skbuff.c`, `net/core/dev.c`, `net/core/gro.c`, and the IPv4/IPv6 areas. What's the goal here? Let's break it down: First, `skb_copy_and_csum_bits` has been changed. It used to return a checksum, but now it returns an `int` error code. It takes a pointer to a checksum, `*csump`, instead. Why? Because the old return value could be confused with a valid checksum, even if there was an error like an unreadable fragment. This is a solid approach; explicit error codes are much clearer. Next, we have these new functions: `skb_checksum_full()` and `skb_crc32c_full()`. They follow the same pattern - return an error code and update a checksum pointer, `*csump` or `*crcp`. The existing `skb_checksum()` and `skb_crc32c()` are now just wrappers around these new, error-aware functions. This makes the error handling consistent. Then, `skb_segment()` is updated. Now, it checks for failures from those `skb_copy_and_csum_bits` and `skb_checksum_full` calls, along with more checks and returning `-EINVAL` / `-EFAULT` instead of things that can lead to crashes. Good. This proactively prevents bugs from bubbling up. `skb_checksum_help`, `skb_crc32c_csum_help`, `pskb_trim_rcsum_complete`, `__skb_checksum_complete_head`, `__skb_checksum_complete` have also been updated, using the new error-aware functions and adding better error handling. We also see some explicit checks in `skb_zerocopy` and `skb_copy_and_csum_dev` to catch bad lengths and data issues, returning `-EINVAL` if there is a problem. Also some added sanity checks in `skb_try_coalesce`. It's not just new code; they're also hardening existing code. For example, in `net/tls/tls_sw.c` and `xen-netfront.c`, the patch replaces `BUG_ON` calls with more graceful error handling using `DEBUG_NET_WARN_ON_ONCE` and `-EINVAL`. This is a big win for stability. Finally, there are KUnit tests in `net/core/net_test.c` for GSO and frag lists, which is great. These are key for testing the new checksum path. So, overall, this is a comprehensive refactoring aimed at hardening the core networking SKB operations. It's about improved error propagation, catching potential bugs early, and preventing crashes. Given the changes to assertions and the core networking subsystems, this definitely needs fuzzing. And that means checking the config options. `INET`, `IPV6`, `NET_CRC32C`, `IP_SCTP`, `TLS`, and likely a KUnit-related option are going to be important to have enabled to build and test this code. Let's see what `net/core/Makefile` says about `net_test.c`. |
| 18/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "net_test",
"PathPrefixes": [
"net/core/"
]
}Results: {
"Output": "net/core/Makefile=50=obj-$(CONFIG_OF)\t+= of_net.o\nnet/core/Makefile:51:obj-$(CONFIG_NET_TEST) += net_test.o\nnet/core/Makefile-52-obj-$(CONFIG_NET_DEVMEM) += devmem.o\n--\nnet/core/net_test.c=1760=static void netmem_ref_test_tcp_devmem_recv(struct kunit *test)\n--\nnet/core/net_test.c-1873-\nnet/core/net_test.c:1874:static struct kunit_case net_test_cases[] = {\nnet/core/net_test.c-1875-\tKUNIT_CASE_PARAM(gso_test_func, gso_test_gen_params),\n--\nnet/core/net_test.c-1893-\nnet/core/net_test.c:1894:static struct kunit_suite net_test_suite = {\nnet/core/net_test.c-1895-\t.name\t\t= \"net_core\",\nnet/core/net_test.c:1896:\t.test_cases\t= net_test_cases,\nnet/core/net_test.c-1897-};\nnet/core/net_test.c:1898:kunit_test_suite(net_test_suite);\nnet/core/net_test.c-1899-\n--\nnet/core/selftests.c-16-\nnet/core/selftests.c:17:static u8 net_test_next_id;\nnet/core/selftests.c-18-\nnet/core/selftests.c:19:struct sk_buff *net_test_get_skb(struct net_device *ndev, u8 id,\nnet/core/selftests.c-20-\t\t\t\t struct net_packet_attrs *attr)\n--\nnet/core/selftests.c-156-}\nnet/core/selftests.c:157:EXPORT_SYMBOL_GPL(net_test_get_skb);\nnet/core/selftests.c-158-\nnet/core/selftests.c:159:static int net_test_loopback_validate(struct sk_buff *skb,\nnet/core/selftests.c-160-\t\t\t\t struct net_device *ndev,\n--\nnet/core/selftests.c-163-{\nnet/core/selftests.c:164:\tstruct net_test_priv *tpriv = pt-\u003eaf_packet_priv;\nnet/core/selftests.c-165-\tconst unsigned char *src = tpriv-\u003epacket-\u003esrc;\n--\nnet/core/selftests.c-232-\nnet/core/selftests.c:233:static int __net_test_loopback(struct net_device *ndev,\nnet/core/selftests.c-234-\t\t\t struct net_packet_attrs *attr)\nnet/core/selftests.c-235-{\nnet/core/selftests.c:236:\tstruct net_test_priv *tpriv;\nnet/core/selftests.c-237-\tstruct sk_buff *skb = NULL;\n--\nnet/core/selftests.c-247-\ttpriv-\u003ept.type = htons(ETH_P_IP);\nnet/core/selftests.c:248:\ttpriv-\u003ept.func = net_test_loopback_validate;\nnet/core/selftests.c-249-\ttpriv-\u003ept.dev = ndev;\n--\nnet/core/selftests.c-253-\nnet/core/selftests.c:254:\tskb = net_test_get_skb(ndev, net_test_next_id, attr);\nnet/core/selftests.c-255-\tif (!skb) {\n--\nnet/core/selftests.c-259-\nnet/core/selftests.c:260:\tnet_test_next_id++;\nnet/core/selftests.c-261-\tret = dev_direct_xmit(skb, attr-\u003equeue_mapping);\n--\nnet/core/selftests.c-285-\nnet/core/selftests.c:286:static int net_test_netif_carrier(struct net_device *ndev)\nnet/core/selftests.c-287-{\n--\nnet/core/selftests.c-290-\nnet/core/selftests.c:291:static int net_test_phy_phydev(struct net_device *ndev)\nnet/core/selftests.c-292-{\n--\nnet/core/selftests.c-295-\nnet/core/selftests.c:296:static int net_test_phy_loopback_enable(struct net_device *ndev)\nnet/core/selftests.c-297-{\n--\nnet/core/selftests.c-303-\nnet/core/selftests.c:304:static int net_test_phy_loopback_disable(struct net_device *ndev)\nnet/core/selftests.c-305-{\n--\nnet/core/selftests.c-311-\nnet/core/selftests.c:312:static int net_test_phy_loopback_udp(struct net_device *ndev)\nnet/core/selftests.c-313-{\n--\nnet/core/selftests.c-316-\tattr.dst = ndev-\u003edev_addr;\nnet/core/selftests.c:317:\treturn __net_test_loopback(ndev, \u0026attr);\nnet/core/selftests.c-318-}\nnet/core/selftests.c-319-\nnet/core/selftests.c:320:static int net_test_phy_loopback_udp_mtu(struct net_device *ndev)\nnet/core/selftests.c-321-{\n--\nnet/core/selftests.c-325-\tattr.max_size = ndev-\u003emtu;\nnet/core/selftests.c:326:\treturn __net_test_loopback(ndev, \u0026attr);\nnet/core/selftests.c-327-}\nnet/core/selftests.c-328-\nnet/core/selftests.c:329:static int net_test_phy_loopback_tcp(struct net_device *ndev)\nnet/core/selftests.c-330-{\n--\nnet/core/selftests.c-334-\tattr.tcp = true;\nnet/core/selftests.c:335:\treturn __net_test_loopback(ndev, \u0026attr);\nnet/core/selftests.c-336-}\n--\nnet/core/selftests.c-338-/**\nnet/core/selftests.c:339: * net_test_phy_loopback_tcp_bad_csum - PHY loopback test with a deliberately\nnet/core/selftests.c-340- *\t\t\t\t\tcorrupted TCP checksum\n--\nnet/core/selftests.c-343- * Builds the same minimal Ethernet/IPv4/TCP frame as\nnet/core/selftests.c:344: * net_test_phy_loopback_tcp(), then flips the least-significant bit of the TCP\nnet/core/selftests.c-345- * checksum so the resulting value is provably invalid (neither 0 nor 0xFFFF).\n--\nnet/core/selftests.c-363- */\nnet/core/selftests.c:364:static int net_test_phy_loopback_tcp_bad_csum(struct net_device *ndev)\nnet/core/selftests.c-365-{\n--\nnet/core/selftests.c-370-\tattr.bad_csum = true;\nnet/core/selftests.c:371:\treturn __net_test_loopback(ndev, \u0026attr);\nnet/core/selftests.c-372-}\nnet/core/selftests.c-373-\nnet/core/selftests.c:374:static const struct net_test {\nnet/core/selftests.c-375-\tchar name[ETH_GSTRING_LEN];\n--\nnet/core/selftests.c-379-\t\t.name = \"Carrier \",\nnet/core/selftests.c:380:\t\t.fn = net_test_netif_carrier,\nnet/core/selftests.c-381-\t}, {\nnet/core/selftests.c-382-\t\t.name = \"PHY dev is present \",\nnet/core/selftests.c:383:\t\t.fn = net_test_phy_phydev,\nnet/core/selftests.c-384-\t}, {\n--\nnet/core/selftests.c-386-\t\t.name = \"PHY internal loopback, enable \",\nnet/core/selftests.c:387:\t\t.fn = net_test_phy_loopback_enable,\nnet/core/selftests.c-388-\t}, {\nnet/core/selftests.c-389-\t\t.name = \"PHY internal loopback, UDP \",\nnet/core/selftests.c:390:\t\t.fn = net_test_phy_loopback_udp,\nnet/core/selftests.c-391-\t}, {\nnet/core/selftests.c-392-\t\t.name = \"PHY internal loopback, MTU \",\nnet/core/selftests.c:393:\t\t.fn = net_test_phy_loopback_udp_mtu,\nnet/core/selftests.c-394-\t}, {\nnet/core/selftests.c-395-\t\t.name = \"PHY internal loopback, TCP \",\nnet/core/selftests.c:396:\t\t.fn = net_test_phy_loopback_tcp,\nnet/core/selftests.c-397-\t}, {\nnet/core/selftests.c-398-\t\t.name = \"PHY loopback, bad TCP csum \",\nnet/core/selftests.c:399:\t\t.fn = net_test_phy_loopback_tcp_bad_csum,\nnet/core/selftests.c-400-\t}, {\n--\nnet/core/selftests.c-402-\t\t.name = \"PHY internal loopback, disable\",\nnet/core/selftests.c:403:\t\t.fn = net_test_phy_loopback_disable,\nnet/core/selftests.c-404-\t},\n--\nnet/core/selftests.c=407=void net_selftest(struct net_device *ndev, struct ethtool_test *etest, u64 *buf)\n--\nnet/core/selftests.c-412-\tmemset(buf, 0, sizeof(*buf) * count);\nnet/core/selftests.c:413:\tnet_test_next_id = 0;\nnet/core/selftests.c-414-\n--\nnet/core/sock.c=769=bool sk_mc_loop(const struct sock *sk)\n--\nnet/core/sock.c-778-\tcase AF_INET:\nnet/core/sock.c:779:\t\treturn inet_test_bit(MC_LOOP, sk);\nnet/core/sock.c-780-#if IS_ENABLED(CONFIG_IPV6)\n"
} |
| 19/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36620 output: 18 thoughts: 13 Thoughts: Here's my take on those thoughts: **Checking `NET_TEST` in Kconfig** Okay, time to dive into the configuration. My immediate thought is, "Let's track down `NET_TEST` within the Kconfig system." I'm mentally parsing where I'd expect to find it – likely somewhere related to networking features, perhaps under a general "Networking" category, or maybe more specifically nested within a "Testing" or "Debugging" submenu if it's a dedicated test feature. I need to understand what this configuration option controls. Is it a built-in feature, a module, or something else entirely? What dependencies does it have? Are there any associated symbols or definitions I need to be aware of? Ultimately, I need to figure out the context and functionality tied to `NET_TEST` to evaluate it properly. Let's start with a quick search and see what Kconfig reveals. |
| 20/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "config NET_TEST"
}Results: {
"Output": "net/Kconfig=528=config NETDEV_ADDR_LIST_TEST\n--\nnet/Kconfig-532-\nnet/Kconfig:533:config NET_TEST\nnet/Kconfig-534-\ttristate \"KUnit tests for networking\" if !KUNIT_ALL_TESTS\n"
} |
| 21/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36930 output: 18 thoughts: 193 Thoughts: **Analyzing the Scope of a KUnit Test in Relation to Syzkaller Fuzzing** Alright, so `NET_TEST` is a KUnit test, but here's the catch: Syzkaller is focused on fuzzing the *running* kernel, not isolated KUnit tests. The two approaches are distinct, and so, the first thing I need to do is map the relevant kernel features affected by the patch. I need to figure out what config options are germane to the changes made. Let's see... we've got the obvious ones: `NET` for base networking, `INET` for IPv4, as things like `icmp.c` and `ip_output.c` are clearly involved here, and then `IPV6` for IPv6 networking, because those same files are IPv6 compatible. Then there's `NET_CRC32C` – that's for CRC32C checksumming, and I need to check how `skb_crc32c_full` and `skb_crc32c_csum_help` come into play. The presence of `TLS` is interesting too; it's got to be involved in the TLS sockets and `tls_sw.c` interaction. And finally, the telltale sign: `DEBUG_NET`. I can't ignore it because there are multiple `DEBUG_NET_WARN_ON_ONCE(1)` statements in the patch. I'll need to dig into where `DEBUG_NET` is defined and how it's actually *used* to understand the implications of these warnings. Time to track down that macro definition and its contexts. |
| 22/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "config DEBUG_NET"
}Results: {
"Output": "net/Kconfig.debug=12=config NET_NS_REFCNT_TRACKER\n--\nnet/Kconfig.debug-20-\nnet/Kconfig.debug:21:config DEBUG_NET\nnet/Kconfig.debug-22-\tbool \"Add generic networking debug\"\n--\nnet/Kconfig.debug-27-\nnet/Kconfig.debug:28:config DEBUG_NET_SMALL_RTNL\nnet/Kconfig.debug-29-\tbool \"Add extra per-netns mutex inside RTNL\"\n"
} |
| 23/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 37631 output: 29 thoughts: 239 Thoughts: **My Assessment of the Debugging Strategy** Okay, so `DEBUG_NET` is *absolutely critical* here. I see they've peppered the code with `DEBUG_NET_WARN_ON_ONCE(1)` calls. Specifically in functions like `skb_checksum_frag_list`, `skb_checksum_full`, and a whole host of others dealing with SKBs and checksumming. They're clearly targeting some potential packet layout issues. These assertions will only trigger if `DEBUG_NET` is enabled, meaning I *must* enable it to get the full picture and catch these unexpected packet layouts. It's the key to finding what this patch is addressing. And, just to be thorough, I should also check `XEN_NETDEV_FRONTEND`, since changes were made to `drivers/net/xen-netfront.c`. Time to dive into the Kconfig and see what's what. |
| 24/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "xen-netfront",
"PathPrefixes": [
"drivers/net/"
]
}Results: {
"Output": "drivers/net/Kconfig=544=config XEN_NETDEV_FRONTEND\n--\ndrivers/net/Kconfig-559-\t should say Y here. To compile this driver as a module, chose\ndrivers/net/Kconfig:560:\t M here: the module will be called xen-netfront.\ndrivers/net/Kconfig-561-\n--\ndrivers/net/Makefile=76=obj-$(CONFIG_VMXNET3) += vmxnet3/\ndrivers/net/Makefile:77:obj-$(CONFIG_XEN_NETDEV_FRONTEND) += xen-netfront.o\ndrivers/net/Makefile-78-obj-$(CONFIG_XEN_NETDEV_BACKEND) += xen-netback/\n--\ndrivers/net/xen-netback/common.h=279=struct xenvif {\n--\ndrivers/net/xen-netback/common.h-295-\ndrivers/net/xen-netback/common.h:296:\t/* headroom requested by xen-netfront */\ndrivers/net/xen-netback/common.h-297-\tu16 xdp_headroom;\n--\ndrivers/net/xen-netback/netback.c-5- * reference front-end implementation can be found in:\ndrivers/net/xen-netback/netback.c:6: * drivers/net/xen-netfront.c\ndrivers/net/xen-netback/netback.c-7- *\n--\ndrivers/net/xen-netback/netback.c=98=MODULE_PARM_DESC(hash_cache_size, \"Number of flows in the hash cache\");\n--\ndrivers/net/xen-netback/netback.c-100-/* The module parameter tells that we have to put data\ndrivers/net/xen-netback/netback.c:101: * for xen-netfront with the XDP_PACKET_HEADROOM offset\ndrivers/net/xen-netback/netback.c-102- * needed for XDP processing\n--\ndrivers/net/xen-netfront.c=2271=static int talk_to_netback(struct xenbus_device *dev,\n--\ndrivers/net/xen-netfront.c-2309-\tif (info-\u003enetback_has_xdp_headroom) {\ndrivers/net/xen-netfront.c:2310:\t\t/* set the current xen-netfront xdp state */\ndrivers/net/xen-netfront.c-2311-\t\terr = talk_to_netback_xdp(info, info-\u003enetfront_xdp_enabled ?\n"
} |
| 25/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38745 output: 26 thoughts: 183 Thoughts: **My Analysis of Networking Code** Okay, so I'm digging into this code and trying to figure out the relevant areas. My initial thought is, "Is `xen-netfront` actually relevant here?" It's only on a Xen guest, so it *could* be, since it's one of the places the code touches. But then I realize: Wait a minute, the core networking functions are also being called! I'm thinking of `skb_segment`, `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_crc32c_full`, `skb_zerocopy`, `skb_try_coalesce`, `skb_checksum_help`, `skb_crc32c_csum_help`, and `pskb_trim_rcsum_complete`. These are all fundamental. Now, let's switch gears and check out `IP_SCTP` - that's a good place to start. Aha! Looks like `IP_SCTP` specifically selects `NET_CRC32C` and uses `skb_crc32c_csum_help`. Okay, I've got something to work with. Let's do a quick grep for `skb_crc32c_csum_help` and see where else that shows up. That should give me a better understanding of the overall picture. |
| 26/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "skb_crc32c_csum_help"
}Results: {
"Output": "include/linux/netdevice.h=5353=int skb_checksum_help(struct sk_buff *skb);\ninclude/linux/netdevice.h:5354:int skb_crc32c_csum_help(struct sk_buff *skb);\ninclude/linux/netdevice.h-5355-int skb_csum_hwoffload_help(struct sk_buff *skb,\n--\ninclude/linux/skbuff.h-222- *\t must verify which offload is configured for a packet by testing the\ninclude/linux/skbuff.h:223: *\t value of \u0026sk_buff.csum_not_inet; skb_crc32c_csum_help() is provided to\ninclude/linux/skbuff.h-224- *\t resolve %CHECKSUM_PARTIAL on skbs where csum_not_inet is set to 1.\n--\nnet/core/dev.c=3722=EXPORT_SYMBOL(skb_checksum_help);\n--\nnet/core/dev.c-3724-#ifdef CONFIG_NET_CRC32C\nnet/core/dev.c:3725:int skb_crc32c_csum_help(struct sk_buff *skb)\nnet/core/dev.c-3726-{\n--\nnet/core/dev.c-3763-}\nnet/core/dev.c:3764:EXPORT_SYMBOL(skb_crc32c_csum_help);\nnet/core/dev.c-3765-#endif /* CONFIG_NET_CRC32C */\n--\nnet/core/dev.c=4117=int skb_csum_hwoffload_help(struct sk_buff *skb,\n--\nnet/core/dev.c-4121-\t\treturn !!(features \u0026 NETIF_F_SCTP_CRC) ? 0 :\nnet/core/dev.c:4122:\t\t\tskb_crc32c_csum_help(skb);\nnet/core/dev.c-4123-\n--\nnet/netfilter/nfnetlink_queue.c=676=static int nf_queue_checksum_help(struct sk_buff *entskb)\n--\nnet/netfilter/nfnetlink_queue.c-684-\tif (skb_csum_is_sctp(entskb))\nnet/netfilter/nfnetlink_queue.c:685:\t\treturn skb_crc32c_csum_help(entskb);\nnet/netfilter/nfnetlink_queue.c-686-\n"
} |
| 27/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 39918 output: 25 thoughts: 75 Thoughts: Okay, here's my understanding, thinking through this step-by-step: **Analyzing the Checksum Offload Path** Right, so I see `skb_csum_hwoffload_help` is directly calling `skb_crc32c_csum_help(skb)`. This is interesting, and it looks like a key function involved in checksum offload. More specifically, I remember that `skb_csum_hwoffload_help` is *always* used during the packet transmit process. I need to understand where this function fits into the overall scheme, so let me trace the call path of `skb_csum_hwoffload_help` to get a better handle on the big picture. Where are you actually being called from? |
| 28/2 | 2026/11/07 14:35 | tool | grepper |
0mArgs:{
"Expression": "skb_csum_hwoffload_help"
}Results: {
"Output": "Documentation/networking/checksum-offloads.rst=61=favor of NETIF_F_HW_CSUM. New devices should use NETIF_F_HW_CSUM to advertise\nDocumentation/networking/checksum-offloads.rst:62:generic checksum offload. The skb_csum_hwoffload_help() helper can resolve\nDocumentation/networking/checksum-offloads.rst-63-CHECKSUM_PARTIAL according to the device's advertised checksum capabilities,\n--\nDocumentation/networking/checksum-offloads.rst=72=corresponding offload in software. In the case of TX Checksum Offload, that\nDocumentation/networking/checksum-offloads.rst:73:means calling skb_csum_hwoffload_help(skb, features).\nDocumentation/networking/checksum-offloads.rst-74-\n--\ndrivers/net/ppp/ppp_generic.c=2334=static void ppp_bridge_xmit(struct ppp_channel *chan, struct sk_buff *skb)\n--\ndrivers/net/ppp/ppp_generic.c-2339-\tif (!chan-\u003exmit_offload \u0026\u0026 skb-\u003eip_summed == CHECKSUM_PARTIAL \u0026\u0026\ndrivers/net/ppp/ppp_generic.c:2340:\t skb_csum_hwoffload_help(skb, 0))\ndrivers/net/ppp/ppp_generic.c-2341-\t\tgoto drop;\n--\ninclude/linux/netdevice.h=5354=int skb_crc32c_csum_help(struct sk_buff *skb);\ninclude/linux/netdevice.h:5355:int skb_csum_hwoffload_help(struct sk_buff *skb,\ninclude/linux/netdevice.h-5356-\t\t\t const netdev_features_t features);\n--\ninclude/linux/skbuff.h-185- * checksum offload capability.\ninclude/linux/skbuff.h:186: * skb_csum_hwoffload_help() can be called to resolve %CHECKSUM_PARTIAL based\ninclude/linux/skbuff.h-187- * on network device checksumming capabilities: if a packet does not match\n--\nnet/core/dev.c=4108=static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,\n--\nnet/core/dev.c-4116-\nnet/core/dev.c:4117:int skb_csum_hwoffload_help(struct sk_buff *skb,\nnet/core/dev.c-4118-\t\t\t const netdev_features_t features)\n--\nnet/core/dev.c-4140-}\nnet/core/dev.c:4141:EXPORT_SYMBOL(skb_csum_hwoffload_help);\nnet/core/dev.c-4142-\n--\nnet/core/dev.c=4208=static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device *dev, bool *again)\n--\nnet/core/dev.c-4254-\t\t\t\t\t\t\t skb_checksum_start_offset(skb));\nnet/core/dev.c:4255:\t\t\tif (skb_csum_hwoffload_help(skb, features))\nnet/core/dev.c-4256-\t\t\t\tgoto out_kfree_skb;\n--\nnet/mac80211/tx.c=3758=ieee80211_tx_skb_fixup(struct sk_buff *skb, netdev_features_t features)\n--\nnet/mac80211/tx.c-3783-\nnet/mac80211/tx.c:3784:\t\tif (skb_csum_hwoffload_help(skb, features))\nnet/mac80211/tx.c-3785-\t\t\tgoto free;\n--\nnet/openvswitch/datapath.c=452=static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,\n--\nnet/openvswitch/datapath.c-493-\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL \u0026\u0026\nnet/openvswitch/datapath.c:494:\t (err = skb_csum_hwoffload_help(skb, 0)))\nnet/openvswitch/datapath.c-495-\t\tgoto out;\n"
} |
| 29/2 | 2026/11/07 14:35 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 41318 output: 19 thoughts: 91 Thoughts: Okay, here's my breakdown of what's going on here. **Deconstructing the Transmission Path** Right, so `validate_xmit_skb` is the function that's critical here. It's the gatekeeper, I need to understand its behaviour and the consequences of its interactions. Specifically, I'm noting that `skb_csum_hwoffload_help` is called *within* `validate_xmit_skb`. This immediately tells me there's a link between checksum offloading and the general validation process – which is exactly what I'd expect. Now, here's the key: `skb_segment` is also called *inside* `validate_xmit_skb`, but *only* when Generic Segmentation Offload (GSO) is active. This suggests a conditional path that depends on the GSO flag and I need to understand it. Furthermore, `skb_checksum_help` is called by `skb_csum_hwoffload_help`. This likely handles the actual details of checksum offload setup. So, since `skb_segment` is called in `validate_xmit_skb`, and it depends on GSO, and is likely a very costly operation on the skb structure, I need to know where *else* it is being called. That's the next step; I need to trace *all* call sites of `skb_segment` to build a complete picture of its impact and implications within the network stack. It's time to dig deeper into the codebase. |
| 30/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "skb_segment\\("
}Results: {
"Output": "Documentation/networking/segmentation-offloads.rst=205=Instead, the SCTP protocol layer builds an skb with the segments correctly\nDocumentation/networking/segmentation-offloads.rst:206:padded and stored as chained skbs, and skb_segment() splits based on those.\nDocumentation/networking/segmentation-offloads.rst-207-To signal this, gso_size is set to the special value GSO_BY_FRAGS.\n--\ndrivers/net/ppp/ppp_generic.c=2294=static struct sk_buff *ppp_bridge_gso_segment(struct sk_buff *skb,\n--\ndrivers/net/ppp/ppp_generic.c-2320-\ndrivers/net/ppp/ppp_generic.c:2321:\t/* No checksum offload: skb_segment() computes the checksums. */\ndrivers/net/ppp/ppp_generic.c-2322-\tsegs = skb_gso_segment(skb, features);\n--\ndrivers/s390/net/qeth_core_main.c=6890=netdev_features_t qeth_features_check(struct sk_buff *skb,\n--\ndrivers/s390/net/qeth_core_main.c-6931-\tif (netif_needs_gso(skb, features)) {\ndrivers/s390/net/qeth_core_main.c:6932:\t\t/* match skb_segment(): */\ndrivers/s390/net/qeth_core_main.c-6933-\t\tunsigned int doffset = skb-\u003edata - skb_mac_header(skb);\n--\ninclude/linux/skbuff.h=4301=void skb_scrub_packet(struct sk_buff *skb, bool xnet);\ninclude/linux/skbuff.h:4302:struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);\ninclude/linux/skbuff.h-4303-struct sk_buff *skb_segment_list(struct sk_buff *skb, netdev_features_t features,\n--\nnet/core/gro.c=92=int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb)\n--\nnet/core/gro.c-189-merge:\nnet/core/gro.c:190:\t/* skb_segment() cannot split the linear part of a frag_list member. */\nnet/core/gro.c-191-\tif (unlikely(headlen \u003e offset + skb_shinfo(p)-\u003egso_size))\n--\nnet/core/net_test.c=57=struct gso_test_case {\n--\nnet/core/net_test.c-81-\nnet/core/net_test.c:82:\t/* skb_segment() is expected to fail with this error */\nnet/core/net_test.c-83-\tint err;\n--\nnet/core/net_test.c=375=static void gso_test_func(struct kunit *test)\n--\nnet/core/net_test.c-485-\t/* TODO: this should also work with SG, rather than fail the\nnet/core/net_test.c:486:\t * i \u003e= nfrags check in skb_segment()\nnet/core/net_test.c-487-\t */\n--\nnet/core/net_test.c-496-\t\tkunit_warning_suppress(test) {\nnet/core/net_test.c:497:\t\t\tsegs = skb_segment(skb, features);\nnet/core/net_test.c-498-\t\t}\n--\nnet/core/net_test.c-504-\nnet/core/net_test.c:505:\tsegs = skb_segment(skb, features);\nnet/core/net_test.c-506-\tif (IS_ERR(segs)) {\n--\nnet/core/net_test.c=730=static void netmem_ref_test_pp_page(struct kunit *test)\n--\nnet/core/net_test.c-884-\tskb_shinfo(skb)-\u003egso_size = 16;\nnet/core/net_test.c:885:\tsplit = skb_segment(skb, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-886-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(split));\n--\nnet/core/net_test.c=1140=static void netmem_ref_test_release_data(struct kunit *test)\n--\nnet/core/net_test.c-1326-\nnet/core/net_test.c:1327:static void netmem_ref_test_skb_segment(struct kunit *test)\nnet/core/net_test.c-1328-{\n--\nnet/core/net_test.c-1381-\nnet/core/net_test.c:1382:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1383-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1420-\nnet/core/net_test.c:1421:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1422-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1463-\nnet/core/net_test.c:1464:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1465-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1507-\nnet/core/net_test.c:1508:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1509-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1553-\nnet/core/net_test.c:1554:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1555-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/skbuff.c=5041=EXPORT_SYMBOL_GPL(skb_segment_list);\n--\nnet/core/skbuff.c-5051- */\nnet/core/skbuff.c:5052:struct sk_buff *skb_segment(struct sk_buff *head_skb,\nnet/core/skbuff.c-5053-\t\t\t netdev_features_t features)\n--\nnet/ipv4/tcp_offload.c=133=struct sk_buff *tcp_gso_segment(struct sk_buff *skb,\n--\nnet/ipv4/tcp_offload.c-180-\nnet/ipv4/tcp_offload.c:181:\tsegs = skb_segment(skb, features);\nnet/ipv4/tcp_offload.c-182-\tif (IS_ERR(segs))\n--\nnet/ipv4/udp_offload.c=481=struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,\n--\nnet/ipv4/udp_offload.c-550-\nnet/ipv4/udp_offload.c:551:\tsegs = skb_segment(gso_skb, features);\nnet/ipv4/udp_offload.c-552-\tif (IS_ERR_OR_NULL(segs)) {\n--\nnet/ipv4/udp_offload.c=633=static struct sk_buff *udp4_ufo_fragment(struct sk_buff *skb,\n--\nnet/ipv4/udp_offload.c-687-\t */\nnet/ipv4/udp_offload.c:688:\tsegs = skb_segment(skb, features);\nnet/ipv4/udp_offload.c-689-out:\n--\nnet/ipv6/udp_offload.c=19=static struct sk_buff *udp6_ufo_fragment(struct sk_buff *skb,\n--\nnet/ipv6/udp_offload.c-108-\t\t */\nnet/ipv6/udp_offload.c:109:\t\tsegs = skb_segment(skb, features);\nnet/ipv6/udp_offload.c-110-\t}\n--\nnet/sctp/offload.c=39=static struct sk_buff *sctp_gso_segment(struct sk_buff *skb,\n--\nnet/sctp/offload.c-71-\nnet/sctp/offload.c:72:\tsegs = skb_segment(skb, (features | NETIF_F_HW_CSUM) \u0026 ~NETIF_F_SG);\nnet/sctp/offload.c-73-\tif (IS_ERR(segs))\n"
} |
| 31/2 | 2026/11/07 14:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44235 output: 35 thoughts: 1623 Thoughts: **Focus Symbol Candidate Analysis** Okay, let's break this down. First, I see that `skb_segment` is called by several GSO-related functions: `tcp_gso_segment`, `__udp_gso_segment`, `udp4_ufo_fragment`, `udp6_ufo_fragment`, and `sctp_gso_segment`. Now, looking at the direct modifications, I've got a list of functions that were touched in this patch. I see a bunch of `skb_*` functions, including the segmenter, checksum helpers, copy routines, coalesce functions, and some other support functions related to checksum completion, IP append, and even TLS offload with `skb_nsg`. I also have `__skb_gro_checksum_complete`. Let's check if they're good candidates for focus symbols. These need to not be ubiquitous hot-paths, as per the rules. `skb_segment` is only called during GSO segmentation, checksum routines are specific, copy functions relate to specialized scenarios, and the coalesce/zerocopy routines have very specific use cases. That's good. They don't look like generic memory allocators or synchronization primitives, so far so good. Now, let's see if these functions are exported. `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_segment`, `skb_crc32c_full`, `skb_checksum_help`, `skb_crc32c_csum_help`, `skb_try_coalesce`, and `skb_zerocopy`, and `__skb_gro_checksum_complete` are all EXPORT_SYMBOL'd. However, I notice that `skb_nsg` is static. Looks like I need to double-check that; I'll check it in `net/tls/tls_sw.c`. The other functions are all non-static, so, I'm pretty confident. Alright, these seem like solid choices based on the criteria. The list of focus symbols should therefore include `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_segment`, `skb_crc32c_full`, `skb_checksum_help`, `skb_crc32c_csum_help`, `skb_try_coalesce`, `skb_zerocopy`, and `__skb_gro_checksum_complete`. I need to ensure that `skb_nsg` will not be included, since it is static, and will not be accessible to the fuzzer. |
| 32/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "skb_nsg",
"PathPrefixes": [
"net/tls/tls_sw.c"
]
}Results: {
"Output": "net/tls/tls_sw.c=71=noinline void tls_err_abort(struct sock *sk, int err)\n--\nnet/tls/tls_sw.c-80-\nnet/tls/tls_sw.c:81:static int __skb_nsg(struct sk_buff *skb, int offset, int len,\nnet/tls/tls_sw.c-82- unsigned int recursion_level)\n--\nnet/tls/tls_sw.c-131- chunk = len;\nnet/tls/tls_sw.c:132: ret = __skb_nsg(frag_iter, offset - start, chunk,\nnet/tls/tls_sw.c-133- recursion_level + 1);\n--\nnet/tls/tls_sw.c-155- */\nnet/tls/tls_sw.c:156:static int skb_nsg(struct sk_buff *skb, int offset, int len)\nnet/tls/tls_sw.c-157-{\nnet/tls/tls_sw.c:158: return __skb_nsg(skb, offset, len, 0);\nnet/tls/tls_sw.c-159-}\n--\nnet/tls/tls_sw.c=1269=static int tls_decrypt_sg(struct sock *sk, struct iov_iter *out_iov,\n--\nnet/tls/tls_sw.c-1289-\nnet/tls/tls_sw.c:1290:\tn_sgin = skb_nsg(skb, rxm-\u003eoffset + prot-\u003eprepend_size,\nnet/tls/tls_sw.c-1291-\t\t\t rxm-\u003efull_len - prot-\u003eprepend_size);\n"
} |
| 33/2 | 2026/11/07 14:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 46926 output: 38 thoughts: 101 Thoughts: Okay, here's my breakdown of this little code snippet's analysis, as if I'm thinking it: **Digging into the `skb_nsg` Static Function** Alright, so `skb_nsg` is declared as `static` inside `tls_sw.c`. That *immediately* raises a flag. We're using it in `tls_decrypt_sg` (or `tls_sw_recvmsg` – same difference for this purpose). Static functions have scope only within their translation unit, which means the compiler is free to optimize them away or inline them aggressively. This makes it trickier to trace and reason about across a larger system. My preference, *especially* when we're dealing with networking and security like this, is to have non-static or exported symbols when possible because they make debugging, tracing, and even analysis with tools easier. They're part of the public API, so to speak. So, the next obvious step is to dig a little deeper. I need to see if `__ip_append_data` and `__ip6_append_data` are declared `static` or, crucially, are they exported? It makes such a difference when trying to do things like see where it’s actually being *called* from. I can check with grepper. |
| 34/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "int __ip_append_data",
"PathPrefixes": [
"net/ipv4/ip_output.c"
]
}Results: {
"Output": "net/ipv4/ip_output.c=955=EXPORT_SYMBOL(ip_generic_getfrag);\nnet/ipv4/ip_output.c-956-\nnet/ipv4/ip_output.c:957:static int __ip_append_data(struct sock *sk,\nnet/ipv4/ip_output.c-958-\t\t\t struct flowi4 *fl4,\n"
} |
| 35/2 | 2026/11/07 14:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 47456 output: 24 thoughts: 305 Thoughts: **Analyzing Data Append Functions and Configuration Dependencies** Okay, let's break this down. I'm focusing on these `append_data` functions. It looks like `__ip_append_data` is declared as static, and is used internally by both `ip_append_data` and `ip_make_skb`. Interesting. But `ip_append_data` is *exported*, so it's visible outside the immediate module. And the IPv6 equivalent, `__ip6_append_data`, mirrors this, being static and called by both `ip6_append_data` and `ip6_make_skb`. Now, the real question is: What configuration options are relevant here? We need to figure out the minimal set of dependencies. Let's look at the modified files for clues. We're looking at `net/core/skbuff.c` and `net/core/dev.c`. Clearly, `CONFIG_NET` is essential; networking is fundamental, so that's a given. Next, it looks like `CONFIG_NET_CRC32C` is important. In `skbuff.c`, both `skb_crc32c_full` and `skb_crc32c` are guarded by `#ifdef CONFIG_NET_CRC32C`. In `dev.c`, `skb_crc32c_csum_help` is also conditional on the same config option. So, CRC32C support is definitely a dependency. Finally, we have `CONFIG_DEBUG_NET`. The presence of all those `DEBUG_NET_WARN_ON_ONCE(1)` statements indicates that any debug-related functionality is conditionally compiled under `CONFIG_DEBUG_NET`. I should check `include/net/net_debug.h` or wherever `DEBUG_NET_WARN_ON_ONCE` is defined to be sure. That's a classic debugging pattern, easy to spot. |
| 36/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "DEBUG_NET_WARN_ON_ONCE"
}Results: {
"Output": "\nFull output is too long, showing 200 out of 1132 lines.\nUse more precise expression or PathPrefixes if possible.\n\nNumber of matching lines per file (83 files in total):\ndrivers/net/ethernet/google/gve/gve_rx_dqo.c:1\ndrivers/net/macsec.c:1\ndrivers/net/netconsole.c:1\ndrivers/net/ovpn/crypto_aead.c:1\ndrivers/net/ovpn/io.c:1\ndrivers/net/ovpn/tcp.c:1\ndrivers/net/vxlan/vxlan_core.c:1\ndrivers/net/xen-netfront.c:1\ninclude/linux/netdevice.h:1\ninclude/linux/skbuff.h:21\ninclude/linux/udp.h:1\ninclude/linux/virtio_vsock.h:1\ninclude/net/ip6_fib.h:1\ninclude/net/net_debug.h:2\ninclude/net/netlink.h:1\ninclude/net/netmem.h:2\ninclude/net/request_sock.h:1\ninclude/net/sch_generic.h:3\ninclude/net/sock.h:2\ninclude/net/tcp.h:2\nnet/core/dev.c:8\nnet/core/dst_cache.c:2\nnet/core/flow_dissector.c:1\nnet/core/gro.c:1\nnet/core/lwtunnel.c:1\nnet/core/neighbour.c:2\nnet/core/rtnetlink.c:1\nnet/core/skbuff.c:40\nnet/core/sock.c:3\nnet/ethtool/netlink.h:1\nnet/ipv4/fib_semantics.c:4\nnet/ipv4/inet_diag.c:1\nnet/ipv4/ip_tunnel.c:1\nnet/ipv4/netfilter/nf_tproxy_ipv4.c:1\nnet/ipv4/tcp_diag.c:1\nnet/ipv4/tcp_input.c:1\nnet/ipv4/tcp_output.c:3\nnet/ipv4/udp.c:1\nnet/ipv6/ip6_gre.c:1\nnet/ipv6/netfilter/nf_tproxy_ipv6.c:1\nnet/ipv6/udp.c:1\nnet/mptcp/fastopen.c:1\nnet/mptcp/protocol.c:3\nnet/mptcp/protocol.h:1\nnet/mptcp/subflow.c:1\nnet/netfilter/ipset/ip_set_bitmap_gen.h:1\nnet/netfilter/ipset/ip_set_list_set.c:1\nnet/netfilter/nf_conncount.c:3\nnet/netfilter/nf_conntrack_expect.c:1\nnet/netfilter/nf_conntrack_proto_gre.c:2\n... and 33 more files\n\ndrivers/net/ethernet/google/gve/gve_rx_dqo.c=1003=static int gve_rx_complete_rsc(struct sk_buff *skb,\n--\ndrivers/net/ethernet/google/gve/gve_rx_dqo.c-1047-\t\t */\ndrivers/net/ethernet/google/gve/gve_rx_dqo.c:1048:\t\tDEBUG_NET_WARN_ON_ONCE(!skb_frag_size(frag));\ndrivers/net/ethernet/google/gve/gve_rx_dqo.c-1049-\t\tskb_frag_off_add(frag, hdr_len);\n--\ndrivers/net/macsec.c=1017=static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)\n--\ndrivers/net/macsec.c-1054-\t\t\t\t */\ndrivers/net/macsec.c:1055:\t\t\t\tDEBUG_NET_WARN_ON_ONCE(!ops-\u003erx_uses_md_dst);\ndrivers/net/macsec.c-1056-\t\t\t\trx_sc = find_rx_sc(\u0026macsec-\u003esecy,\n--\ndrivers/net/netconsole.c=486=static int netcons_netpoll_setup(struct netconsole_target *nt)\n--\ndrivers/net/netconsole.c-565-put:\ndrivers/net/netconsole.c:566:\tDEBUG_NET_WARN_ON_ONCE(np-\u003edev);\ndrivers/net/netconsole.c-567-\tif (ip_overwritten)\n--\ndrivers/net/ovpn/crypto_aead.c=56=static unsigned int ovpn_aead_crypto_tmp_size(struct crypto_aead *tfm,\n--\ndrivers/net/ovpn/crypto_aead.c-60-\ndrivers/net/ovpn/crypto_aead.c:61:\tDEBUG_NET_WARN_ON_ONCE(crypto_aead_ivsize(tfm) != OVPN_NONCE_SIZE);\ndrivers/net/ovpn/crypto_aead.c-62-\n--\ndrivers/net/ovpn/io.c=310=static bool ovpn_encrypt_one(struct ovpn_peer *peer, struct sk_buff *skb)\n--\ndrivers/net/ovpn/io.c-322-\tif (unlikely(!ovpn_peer_hold(peer))) {\ndrivers/net/ovpn/io.c:323:\t\tDEBUG_NET_WARN_ON_ONCE(1);\ndrivers/net/ovpn/io.c-324-\t\tovpn_crypto_key_slot_put(ks);\n--\ndrivers/net/ovpn/tcp.c=510=int ovpn_tcp_socket_attach(struct ovpn_socket *ovpn_sock,\n--\ndrivers/net/ovpn/tcp.c-536-\tif (ret \u003c 0) {\ndrivers/net/ovpn/tcp.c:537:\t\tDEBUG_NET_WARN_ON_ONCE(1);\ndrivers/net/ovpn/tcp.c-538-\t\tgoto err;\n--\ndrivers/net/vxlan/vxlan_core.c=2397=void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/vxlan/vxlan_core.c-2493-\t\tdefault:\ndrivers/net/vxlan/vxlan_core.c:2494:\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\ndrivers/net/vxlan/vxlan_core.c-2495-\t\t\tgoto drop;\n--\ndrivers/net/xen-netfront.c=676=static struct sk_buff *bounce_skb(const struct sk_buff *skb)\n--\ndrivers/net/xen-netfront.c-699-\t\t\t\t headerlen + skb-\u003elen))) {\ndrivers/net/xen-netfront.c:700:\t\tDEBUG_NET_WARN_ON_ONCE(1);\ndrivers/net/xen-netfront.c-701-\t\tkfree_skb(n);\n--\ninclude/linux/netdevice.h=2742=struct netdev_queue *netdev_get_tx_queue(const struct net_device *dev,\n--\ninclude/linux/netdevice.h-2744-{\ninclude/linux/netdevice.h:2745:\tDEBUG_NET_WARN_ON_ONCE(index \u003e= dev-\u003enum_tx_queues);\ninclude/linux/netdevice.h-2746-\treturn \u0026dev-\u003e_tx[index];\n--\ninclude/linux/skbuff.h=1174=static inline void skb_dst_check_unset(struct sk_buff *skb)\ninclude/linux/skbuff.h-1175-{\ninclude/linux/skbuff.h:1176:\tDEBUG_NET_WARN_ON_ONCE((skb-\u003e_skb_refdst \u0026 SKB_DST_PTRMASK) \u0026\u0026\ninclude/linux/skbuff.h-1177-\t\t\t !(skb-\u003e_skb_refdst \u0026 SKB_DST_NOREF));\n--\ninclude/linux/skbuff.h=2682=static inline void skb_add_rx_frag_netmem(struct sk_buff *skb, int i,\n--\ninclude/linux/skbuff.h-2685-{\ninclude/linux/skbuff.h:2686:\tDEBUG_NET_WARN_ON_ONCE(size \u003e truesize);\ninclude/linux/skbuff.h-2687-\n--\ninclude/linux/skbuff.h=2817=static inline void *__skb_push(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2818-{\ninclude/linux/skbuff.h:2819:\tDEBUG_NET_WARN_ON_ONCE(len \u003e INT_MAX);\ninclude/linux/skbuff.h-2820-\ninclude/linux/skbuff.h-2821-\tskb-\u003edata -= len;\ninclude/linux/skbuff.h:2822:\tDEBUG_NET_WARN_ON_ONCE(skb-\u003edata \u003c skb-\u003ehead);\ninclude/linux/skbuff.h-2823-\tskb-\u003elen += len;\n--\ninclude/linux/skbuff.h=2828=static __always_inline void *__skb_pull(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2829-{\ninclude/linux/skbuff.h:2830:\tDEBUG_NET_WARN_ON_ONCE(len \u003e INT_MAX);\ninclude/linux/skbuff.h-2831-\n--\ninclude/linux/skbuff.h=2854=pskb_may_pull_reason(struct sk_buff *skb, unsigned int len)\ninclude/linux/skbuff.h-2855-{\ninclude/linux/skbuff.h:2856:\tDEBUG_NET_WARN_ON_ONCE(len \u003e INT_MAX);\ninclude/linux/skbuff.h-2857-\tskb_might_realloc(skb);\n--\ninclude/linux/skbuff.h=2992=static inline void skb_reset_mac_len(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-2994-\tif (!skb_mac_header_was_set(skb)) {\ninclude/linux/skbuff.h:2995:\t\tDEBUG_NET_WARN_ON_ONCE(1);\ninclude/linux/skbuff.h-2996-\t\tskb-\u003emac_len = 0;\n--\ninclude/linux/skbuff.h=3013=static inline void skb_reset_inner_transport_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3016-\ninclude/linux/skbuff.h:3017:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003einner_transport_header))offset);\ninclude/linux/skbuff.h-3018-\tskb-\u003einner_transport_header = offset;\n--\ninclude/linux/skbuff.h=3033=static inline void skb_reset_inner_network_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3036-\ninclude/linux/skbuff.h:3037:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003einner_network_header))offset);\ninclude/linux/skbuff.h-3038-\tskb-\u003einner_network_header = offset;\n--\ninclude/linux/skbuff.h=3058=static inline void skb_reset_inner_mac_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3061-\ninclude/linux/skbuff.h:3062:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003einner_mac_header))offset);\ninclude/linux/skbuff.h-3063-\tskb-\u003einner_mac_header = offset;\n--\ninclude/linux/skbuff.h=3082=static inline unsigned char *skb_transport_header(const struct sk_buff *skb)\ninclude/linux/skbuff.h-3083-{\ninclude/linux/skbuff.h:3084:\tDEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));\ninclude/linux/skbuff.h-3085-\treturn skb-\u003ehead + skb-\u003etransport_header;\n--\ninclude/linux/skbuff.h=3088=static inline void skb_reset_transport_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3091-\ninclude/linux/skbuff.h:3092:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003etransport_header))offset);\ninclude/linux/skbuff.h-3093-\tskb-\u003etransport_header = offset;\n--\ninclude/linux/skbuff.h=3155=static inline void skb_reset_network_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3158-\ninclude/linux/skbuff.h:3159:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003enetwork_header))offset);\ninclude/linux/skbuff.h-3160-\tskb-\u003enetwork_header = offset;\n--\ninclude/linux/skbuff.h=3169=static inline unsigned char *skb_mac_header(const struct sk_buff *skb)\ninclude/linux/skbuff.h-3170-{\ninclude/linux/skbuff.h:3171:\tDEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));\ninclude/linux/skbuff.h-3172-\treturn skb-\u003ehead + skb-\u003emac_header;\n--\ninclude/linux/skbuff.h=3180=static inline u32 skb_mac_header_len(const struct sk_buff *skb)\ninclude/linux/skbuff.h-3181-{\ninclude/linux/skbuff.h:3182:\tDEBUG_NET_WARN_ON_ONCE(!skb_mac_header_was_set(skb));\ninclude/linux/skbuff.h-3183-\treturn skb-\u003enetwork_header - skb-\u003emac_header;\n--\ninclude/linux/skbuff.h=3191=static inline void skb_reset_mac_header(struct sk_buff *skb)\n--\ninclude/linux/skbuff.h-3194-\ninclude/linux/skbuff.h:3195:\tDEBUG_NET_WARN_ON_ONCE(offset != (typeof(skb-\u003emac_header))offset);\ninclude/linux/skbuff.h-3196-\tskb-\u003emac_header = offset;\n--\ninclude/linux/skbuff.h=3262=static inline u32 skb_network_header_len(const struct sk_buff *skb)\ninclude/linux/skbuff.h-3263-{\ninclude/linux/skbuff.h:3264:\tDEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));\ninclude/linux/skbuff.h-3265-\treturn skb-\u003etransport_header - skb-\u003enetwork_header;\n--\ninclude/linux/skbuff.h=4689=static inline void skb_postpull_data_move(struct sk_buff *skb,\n--\ninclude/linux/skbuff.h-4692-{\ninclude/linux/skbuff.h:4693:\tDEBUG_NET_WARN_ON_ONCE(len \u003e INT_MAX);\ninclude/linux/skbuff.h-4694-\tskb_data_move(skb, len, n);\n--\ninclude/linux/skbuff.h=4705=static inline void skb_postpush_data_move(struct sk_buff *skb,\n--\ninclude/linux/skbuff.h-4708-{\ninclude/linux/skbuff.h:4709:\tDEBUG_NET_WARN_ON_ONCE(len \u003e INT_MAX);\ninclude/linux/skbuff.h-4710-\tskb_data_move(skb, -len, n);\n--\ninclude/linux/skbuff.h=5035=static inline void skb_set_nfct(struct sk_buff *skb, unsigned long nfct)\n--\ninclude/linux/skbuff.h-5037-#if IS_ENABLED(CONFIG_NF_CONNTRACK)\ninclude/linux/skbuff.h:5038:\tDEBUG_NET_WARN_ON_ONCE(skb-\u003e_nfct \u0026 NFCT_PTRMASK);\ninclude/linux/skbuff.h-5039-\tskb-\u003eslow_gro |= !!nfct;\n--\ninclude/linux/skbuff.h=5375=static inline void skb_checksum_none_assert(const struct sk_buff *skb)\ninclude/linux/skbuff.h-5376-{\ninclude/linux/skbuff.h:5377:\tDEBUG_NET_WARN_ON_ONCE(skb-\u003eip_summed != CHECKSUM_NONE);\ninclude/linux/skbuff.h-5378-}\n--\ninclude/linux/udp.h=47=static inline void udp_set_len_short(struct udphdr *uh, unsigned int len)\ninclude/linux/udp.h-48-{\ninclude/linux/udp.h:49:\tDEBUG_NET_WARN_ON_ONCE(len \u003e= GRO_LEGACY_MAX_SIZE);\ninclude/linux/udp.h-50-\tuh-\u003elen = htons(len);\n--\ninclude/linux/virtio_vsock.h=50=static inline void virtio_vsock_skb_put(struct sk_buff *skb, u32 len)\ninclude/linux/virtio_vsock.h-51-{\ninclude/linux/virtio_vsock.h:52:\tDEBUG_NET_WARN_ON_ONCE(skb-\u003elen);\ninclude/linux/virtio_vsock.h-53-\n--\ninclude/net/ip6_fib.h=340=static inline void fib6_info_release(struct fib6_info *f6i)\n--\ninclude/net/ip6_fib.h-342-\tif (f6i \u0026\u0026 refcount_dec_and_test(\u0026f6i-\u003efib6_ref)) {\ninclude/net/ip6_fib.h:343:\t\tDEBUG_NET_WARN_ON_ONCE(!hlist_unhashed(\u0026f6i-\u003egc_link));\ninclude/net/ip6_fib.h-344-\t\tcall_rcu_hurry(\u0026f6i-\u003ercu, fib6_info_destroy_rcu);\n--\ninclude/net/net_debug.h=114=do {\t\t\t\t\t\t\t\t\\\n--\ninclude/net/net_debug.h-151-#if defined(CONFIG_DEBUG_NET)\ninclude/net/net_debug.h:152:#define DEBUG_NET_WARN_ON_ONCE(cond) ((void)WARN_ON_ONCE(cond))\ninclude/net/net_debug.h-153-#define DEBUG_NET_WARN_ONCE(cond, format...) ((void)WARN_ONCE(cond, format))\ninclude/net/net_debug.h-154-#else\ninclude/net/net_debug.h:155:#define DEBUG_NET_WARN_ON_ONCE(cond) BUILD_BUG_ON_INVALID(cond)\ninclude/net/net_debug.h-156-#define DEBUG_NET_WARN_ONCE(cond, format...) BUILD_BUG_ON_INVALID(cond)\n--\ninclude/net/netlink.h=2261=static inline int nla_nest_end(struct sk_buff *skb, struct nlattr *start)\n--\ninclude/net/netlink.h-2264-\ninclude/net/netlink.h:2265:\tDEBUG_NET_WARN_ON_ONCE(diff \u003e U16_MAX);\ninclude/net/netlink.h-2266-\tstart-\u003enla_len = diff;\n--\ninclude/net/netmem.h=179=static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)\n\n"
} |
| 37/2 | 2026/11/07 14:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 53343 output: 38 thoughts: 365 Thoughts: **Analyzing Network Packet Buffer (skb) Functionality and Dependencies** Okay, so I need to make sure I understand these network configurations thoroughly. Let's see... `DEBUG_NET_WARN_ON_ONCE` is conditionally defined – it only expands to `WARN_ON_ONCE` if `CONFIG_DEBUG_NET` is set. Otherwise, it's a compile-time error, `BUILD_BUG_ON_INVALID(cond)`. So, `DEBUG_NET` is clearly a prerequisite to enable the warning. That's good to keep in mind. Now, let's look at `IP_SCTP` and `NET_CRC32C`. Right, `CONFIG_NET_CRC32C` directly enables checksum functions, specifically `skb_crc32c_full` and `skb_crc32c_csum_help`. `CONFIG_INET` turns on IPv4, and `CONFIG_IPV6` turns on IPv6. Of course. And `CONFIG_TLS` enables `tls_sw.c`. Finally, `CONFIG_XEN_NETDEV_FRONTEND` is optional but relevant for amd64 Xen guest scenarios. Alright, time to revisit the list of FocusSymbols I've been considering. I need to select a focused set of functions, maybe 5-10, that are not universally present or ubiquitous. Let's see... I've got `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_segment`, `skb_crc32c_full`, `skb_checksum_help`, `skb_crc32c_csum_help`, `skb_zerocopy`, `skb_try_coalesce`, `skb_copy_and_csum_dev`, and `__skb_gro_checksum_complete`. Now, I have to confirm that all of those functions actually *exist* within the current tree and are symbols in the relevant object files. I'll use grepper to find their definitions and verify their presence. Got to be thorough. |
| 38/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "EXPORT_SYMBOL.*\\(skb_segment",
"PathPrefixes": [
"net/core/skbuff.c"
]
}Results: {
"Output": "net/core/skbuff.c=4946=struct sk_buff *skb_segment_list(struct sk_buff *skb,\n--\nnet/core/skbuff.c-5040-}\nnet/core/skbuff.c:5041:EXPORT_SYMBOL_GPL(skb_segment_list);\nnet/core/skbuff.c-5042-\n--\nnet/core/skbuff.c=5052=struct sk_buff *skb_segment(struct sk_buff *head_skb,\n--\nnet/core/skbuff.c-5462-}\nnet/core/skbuff.c:5463:EXPORT_SYMBOL_GPL(skb_segment);\nnet/core/skbuff.c-5464-\n"
} |
| 39/2 | 2026/11/07 14:36 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 54409 output: 79 thoughts: 68 Thoughts: Okay, let's dive into this. Here's how I'd approach this task, playing the role of an expert: **Investigating Core SKB Checksumming and Zero-Copy Mechanisms** Right, let me get a handle on what's being looked at here. The mentions of `skb_zerocopy`, `skb_try_coalesce`, `skb_copy_and_csum_dev`, `skb_checksum_help`, `skb_crc32c_csum_help`, and `__skb_gro_checksum_complete` immediately flag a deep dive into the Standard Kernel Buffer (SKB) and its performance, particularly around checksum calculation and optimization. I immediately think these functions relate to zero-copy operations. * `skb_zerocopy` suggests we're talking about avoiding actual data copying when passing buffers, a critical performance gain. I'll need to remember to look into potential implications with shared pages and reference counting. * `skb_try_coalesce` is another strong hint that this is about memory efficiency. Coalescing SKBs reduces fragmentation and improves data locality. * `skb_copy_and_csum_dev` indicates a specific operation – the *copying* and *checksumming* of data as it's being sent by a network device. I need to understand the nuances of how this works. Is this being optimized? What hardware offload is being leveraged? Are there any potential bottlenecks? * `skb_checksum_help` and `skb_crc32c_csum_help` are, obviously, checksum calculation helpers. I want to verify which checksum algorithms are supported and how these functions handle partial checksum calculations in different contexts. * `__skb_gro_checksum_complete` – this function is clearly about Generic Receive Offload (GRO). The double underscore prefix is critical, suggesting this is an internal function for GRO. I'll need to figure out what checksum completions are. Are we looking into a specific GRO implementation or something more general? In conclusion, it looks like someone's examining the low-level SKB processing pipeline, likely with an eye on optimizing network performance, especially in scenarios that involve hardware checksum offload and zero-copy transfers. I need to see what the context is: is it a specific driver, a broader networking subsystem investigation, or a deep dive into the interaction between checksum offload and GRO? This will decide where to start digging in. |
| 40/2 | 2026/11/07 14:36 | tool | grepper |
0mArgs:{
"Expression": "EXPORT_SYMBOL.*\\((skb_zerocopy|skb_try_coalesce|skb_copy_and_csum_dev|skb_checksum_help|skb_crc32c_csum_help|__skb_gro_checksum_complete)\\)"
}Results: {
"Output": "net/core/dev.c=3666=int skb_checksum_help(struct sk_buff *skb)\n--\nnet/core/dev.c-3721-}\nnet/core/dev.c:3722:EXPORT_SYMBOL(skb_checksum_help);\nnet/core/dev.c-3723-\n--\nnet/core/dev.c=3725=int skb_crc32c_csum_help(struct sk_buff *skb)\n--\nnet/core/dev.c-3763-}\nnet/core/dev.c:3764:EXPORT_SYMBOL(skb_crc32c_csum_help);\nnet/core/dev.c-3765-#endif /* CONFIG_NET_CRC32C */\n--\nnet/core/gro.c=799=__sum16 __skb_gro_checksum_complete(struct sk_buff *skb)\n--\nnet/core/gro.c-826-}\nnet/core/gro.c:827:EXPORT_SYMBOL(__skb_gro_checksum_complete);\nnet/core/gro.c-828-\n--\nnet/core/skbuff.c=4088=skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)\n--\nnet/core/skbuff.c-4167-}\nnet/core/skbuff.c:4168:EXPORT_SYMBOL_GPL(skb_zerocopy);\nnet/core/skbuff.c-4169-\nnet/core/skbuff.c=4170=void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)\n--\nnet/core/skbuff.c-4220-}\nnet/core/skbuff.c:4221:EXPORT_SYMBOL(skb_copy_and_csum_dev);\nnet/core/skbuff.c-4222-\n--\nnet/core/skbuff.c=6512=bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,\n--\nnet/core/skbuff.c-6614-}\nnet/core/skbuff.c:6615:EXPORT_SYMBOL(skb_try_coalesce);\nnet/core/skbuff.c-6616-\n"
} |
| 41/2 | 2026/11/07 14:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 55700 output: 49 thoughts: 52 Thoughts: Here's my take on those thoughts: **Analyzing Kernel SKB Functions** Okay, so I'm looking at these functions, and it's immediately apparent that `skb_checksum_full`, `skb_copy_and_csum_bits`, and `skb_crc32c_full` are all non-static and, crucially, `EXPORT_SYMBOL`'d. This immediately tells me they're designed for external use, likely by modules, and are part of the core SKB (Socket Buffer) functionality the kernel exposes. This makes them of particular interest because of their potential impact and integration with other parts of the network stack. I should definitely drill down into how they function, as any changes here would have broad reach. I need to understand their exact purpose and how they're intended to be used within the kernel ecosystem, in terms of checksumming and CRC operations. I also want to explore where they are used to get an idea of the breadth of their dependencies. |
| 42/2 | 2026/11/07 14:37 | tool | grepper |
0mArgs:{
"Expression": "EXPORT_SYMBOL.*\\((skb_checksum_full|skb_copy_and_csum_bits|skb_crc32c_full)\\)"
}Results: {
"Output": "net/core/skbuff.c=3609=int skb_checksum_full(const struct sk_buff *skb, int offset, int len,\n--\nnet/core/skbuff.c-3674-}\nnet/core/skbuff.c:3675:EXPORT_SYMBOL(skb_checksum_full);\nnet/core/skbuff.c-3676-\n--\nnet/core/skbuff.c=3755=int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n--\nnet/core/skbuff.c-3831-}\nnet/core/skbuff.c:3832:EXPORT_SYMBOL(skb_copy_and_csum_bits);\nnet/core/skbuff.c-3833-\n--\nnet/core/skbuff.c=3886=int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)\n--\nnet/core/skbuff.c-3942-}\nnet/core/skbuff.c:3943:EXPORT_SYMBOL(skb_crc32c_full);\nnet/core/skbuff.c-3944-\n"
} |
| 43/2 | 2026/11/07 14:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 56335 output: 27 thoughts: 74 Thoughts: Okay, here's my take on those thoughts, framed as my own: **Investigating Potential Impact of Symbol Export Changes** Right, so I see these new modifications, and the first thing that jumps out is that they're all *exported symbols*. This immediately raises a red flag in my mind. Any change to exported symbols in `net/core/skbuff.c` has a high potential for downstream impact, so let's dig deeper. I need to confirm whether any other functions in `net/core/skbuff.c` were touched. I'll need to check `__skb_checksum_complete_head` and `__skb_checksum_complete`. Ah, good, they're both exported symbols as well. It's a bit of a pattern, and the scale has increased the significance of the changes. I'm focusing my attention on `__skb_checksum_complete` now. My understanding of the codebase means I should know where it's called, so I need to understand what this specifically controls. I need to be prepared to trace the impact on the checksum calculations of the network stack. |
| 44/2 | 2026/11/07 14:37 | tool | grepper |
0mArgs:{
"Expression": "EXPORT_SYMBOL.*\\(__skb_checksum_complete.*\\)"
}Results: {
"Output": "net/core/skbuff.c=3974=__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)\n--\nnet/core/skbuff.c-3992-}\nnet/core/skbuff.c:3993:EXPORT_SYMBOL(__skb_checksum_complete_head);\nnet/core/skbuff.c-3994-\n--\nnet/core/skbuff.c=4005=__sum16 __skb_checksum_complete(struct sk_buff *skb)\n--\nnet/core/skbuff.c-4036-}\nnet/core/skbuff.c:4037:EXPORT_SYMBOL(__skb_checksum_complete);\nnet/core/skbuff.c-4038-\n"
} |
| 45/2 | 2026/11/07 14:37 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 56884 output: 325 thoughts: 991 Thoughts: **Fuzzing Verdict: Network Subsystem Patch Analysis** Okay, let's break this down. My initial scan flagged a set of `FocusSymbols` – functions directly impacted by the patch: `skb_segment`, `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_crc32c_full`, `skb_checksum_help`, `skb_crc32c_csum_help`, `skb_try_coalesce`, `skb_zerocopy`, `skb_copy_and_csum_dev`, and `__skb_gro_checksum_complete`. The goal here is to determine if fuzzing is warranted and what configurations are needed. First, the ubiquity check: I'm making sure none of these are basic primitives called by everything, which would be a waste of focused fuzzing effort. *None* of them are. `skb_segment` is GSO-specific, CRC32C-related functions are for specific protocols, checksum helpers are for specific cases, and so on. They all represent specific, patch-affected logic. Perfect, we have a tight list of relevant functions. Now, required configs: The patch touches IPv4 (INET), IPv6 (IPV6), CRC32C (NET_CRC32C), SCTP (IP_SCTP), TLS, and includes assertions enabled by DEBUG_NET. No surprises, those configs are all directly related to the functions we are focusing on. I've double-checked that `CONFIG_NET` and `CONFIG_XEN_NETDEV_FRONTEND` are not critical and these can be added for extra coverage. Finally, let's make sure the output meets the requirements: The "Reasoning" is the summary here, "WorthFuzzing" is obviously true since we've identified specific, changed code. The "EnableConfigs" list will be `DEBUG_NET`, `NET_CRC32C`, `INET`, `IPV6`, `TLS`, and `IP_SCTP`. The "FocusSymbols" are the initial list. This is clean, justified, and ready to go. Let's call `set-results`. |
| 46/2 | 2026/11/07 14:37 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"INET",
"IPV6",
"TLS",
"IP_SCTP"
],
"FocusSymbols": [
"skb_segment",
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_checksum_help",
"skb_crc32c_csum_help",
"skb_zerocopy",
"skb_try_coalesce",
"skb_copy_and_csum_dev",
"__skb_gro_checksum_complete"
],
"Reasoning": "The patch introduces extensive error-propagation and sanity checks across core networking skb operations (skb_segment, skb_checksum_full, skb_copy_and_csum_bits, skb_crc32c_full, skb_try_coalesce, skb_zerocopy). It modifies skb segmentation and checksumming logic, alters return signatures, and adds multiple DEBUG_NET_WARN_ON_ONCE invariant checks in reachable core networking execution paths. Fuzzing is warranted to verify that complex skb geometries (e.g. frag lists, non-linear buffers, GSO/GRO) do not trigger new assertions, regressions, or edge-case fault conditions.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"INET",
"IPV6",
"TLS",
"IP_SCTP"
],
"FocusSymbols": [
"skb_segment",
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_checksum_help",
"skb_crc32c_csum_help",
"skb_zerocopy",
"skb_try_coalesce",
"skb_copy_and_csum_dev",
"__skb_gro_checksum_complete"
],
"Reasoning": "The patch introduces extensive error-propagation and sanity checks across core networking skb operations (skb_segment, skb_checksum_full, skb_copy_and_csum_bits, skb_crc32c_full, skb_try_coalesce, skb_zerocopy). It modifies skb segmentation and checksumming logic, alters return signatures, and adds multiple DEBUG_NET_WARN_ON_ONCE invariant checks in reachable core networking execution paths. Fuzzing is warranted to verify that complex skb geometries (e.g. frag lists, non-linear buffers, GSO/GRO) do not trigger new assertions, regressions, or edge-case fault conditions.",
"WorthFuzzing": true
} |
| 47/1 | 2026/11/07 14:37 | action | If |
1mArgs:{
"WorthFuzzing": true
}Results: null |
| 48/2 | 2026/11/07 14:37 | agent | kmsan-evaluator |
1mModel:core Args: null Results: {
"KMSANReasoning": "The patch series refactors skb checksumming and copying functions (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits) to return proper error codes rather than silently returning 0 upon failure or hitting BUG_ONs. It also improves bounds checking and error handling across skb segmentation (skb_segment), coalescing (skb_try_coalesce), and zerocopy logic to handle malformed or truncated skb frag lists gracefully.\n\nRegarding uninitialized memory:\n- All checksum output variables passed by reference across callers (e.g. in dev.c, gro.c, icmp.c, ip_output.c, skbuff.c) are either explicitly initialized (e.g., `__wsum csum = 0;`, `u32 crc = ~0;`) or guarded by `__must_check` return codes that trigger immediate error returns or packet drops prior to any use of the checksum value.\n- In partial failure scenarios within `skb_copy_and_csum_bits`, `skb_copy_and_csum_frag_list`, and `skb_copy_and_csum_dev`, destination buffers are defensively zeroed via `memset` to prevent leaving stale or uninitialized bytes in copied buffers.\n- No kernel-to-user copy paths (such as netlink, ioctl, or socket options) or uninitialized struct padding are exposed.\n\nThe failure modes touched by this patch series involve buffer boundaries, length calculations, list iteration, and NULL checks—risks such as out-of-bounds reads/writes, pointer invalidation, and assertions that are directly covered by KASAN and net debugging checks. A dedicated KMSAN fuzzing session is not justified.",
"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 7eab7c1eee34f51ba1f3d4538574f0ac9fb72156
Author: syz-cluster <triage@syzkaller.com>
Date: Sat Nov 7 14:34:09 2026 +0000
syz-cluster: applied patch under review
diff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethernet/sun/sunvnet_common.c
index 5cca958690521f..4f229fcecc32f1 100644
--- a/drivers/net/ethernet/sun/sunvnet_common.c
+++ b/drivers/net/ethernet/sun/sunvnet_common.c
@@ -1167,9 +1167,13 @@ static inline struct sk_buff *vnet_skb_shape(struct sk_buff *skb, int ncookies)
/* copy the rest, with csum calculation */
*(__sum16 *)(skb->data + offset) = 0;
- csum = skb_copy_and_csum_bits(skb, start,
- nskb->data + start,
- skb->len - start);
+ if (skb_copy_and_csum_bits(skb, start,
+ nskb->data + start,
+ skb->len - start, &csum)) {
+ dev_kfree_skb(nskb);
+ dev_kfree_skb(skb);
+ return NULL;
+ }
/* add in the header checksums */
if (skb->protocol == htons(ETH_P_IP)) {
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index fdcb91042f2906..17811d81937c6e 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -695,7 +695,12 @@ static struct sk_buff *bounce_skb(const struct sk_buff *skb)
/* Set the tail pointer and length */
skb_put(n, skb->len);
- BUG_ON(skb_copy_bits(skb, -headerlen, n->head, headerlen + skb->len));
+ if (unlikely(skb_copy_bits(skb, -headerlen, n->head,
+ headerlen + skb->len))) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ kfree_skb(n);
+ return NULL;
+ }
skb_copy_header(n, skb);
return n;
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6787fcf6ac3e43..5581ed3cbf479d 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -4280,8 +4280,10 @@ void skb_free_datagram(struct sock *sk, struct sk_buff *skb);
int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags);
int skb_copy_bits(const struct sk_buff *skb, int offset, void *to, int len);
int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);
-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset, u8 *to,
- int len);
+int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
+ u8 *to, int len, __wsum *csump);
+int __must_check skb_checksum_full(const struct sk_buff *skb, int offset,
+ int len, __wsum *csump);
int skb_splice_bits(struct sk_buff *skb, struct sock *sk, unsigned int offset,
struct pipe_inode_info *pipe, unsigned int len,
unsigned int flags);
@@ -4330,6 +4332,8 @@ static inline int memcpy_to_msg(struct msghdr *msg, void *data, int len)
__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,
__wsum csum);
+int __must_check skb_crc32c_full(const struct sk_buff *skb, int offset,
+ int len, u32 *crcp);
u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc);
static inline void * __must_check
@@ -4890,7 +4894,7 @@ static inline void skb_checksum_complete_unset(struct sk_buff *skb)
* 0: checksum is validated or try to in skb_checksum_complete. In the latter
* case the ip_summed will not be CHECKSUM_UNNECESSARY and the pseudo
* checksum is stored in skb->csum for use in __skb_checksum_complete
- * non-zero: value of invalid checksum
+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed
*
*/
static inline __sum16 __skb_checksum_validate_complete(struct sk_buff *skb,
@@ -4930,7 +4934,7 @@ static inline __wsum null_compute_pseudo(struct sk_buff *skb, int proto)
*
* Return values:
* 0: checksum is validated or try to in skb_checksum_complete
- * non-zero: value of invalid checksum
+ * non-zero: value of invalid checksum, or 1 if the skb can't be checksummed
*/
#define __skb_checksum_validate(skb, proto, complete, \
zero_okay, check, compute_pseudo) \
diff --git a/net/core/dev.c b/net/core/dev.c
index 3ac700d37e596f..f9878db781df7c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3665,7 +3665,7 @@ void skb_warn_bad_offload(const struct sk_buff *skb)
*/
int skb_checksum_help(struct sk_buff *skb)
{
- __wsum csum;
+ __wsum csum = 0;
int ret = 0, offset;
if (skb->ip_summed == CHECKSUM_COMPLETE)
@@ -3697,13 +3697,16 @@ int skb_checksum_help(struct sk_buff *skb)
offset, skb_headlen(skb));
goto out;
}
- csum = skb_checksum(skb, offset, skb->len - offset, 0);
+ ret = skb_checksum_full(skb, offset, skb->len - offset, &csum);
+ if (ret)
+ goto out;
offset += skb->csum_offset;
if (unlikely(offset + sizeof(__sum16) > skb_headlen(skb))) {
DO_ONCE_LITE(skb_dump, KERN_ERR, skb, false);
WARN_ONCE(true, "offset+2 (%zu) > skb_headlen() (%u)\n",
offset + sizeof(__sum16), skb_headlen(skb));
+ ret = -EINVAL;
goto out;
}
ret = skb_ensure_writable(skb, offset + sizeof(__sum16));
@@ -3749,8 +3752,11 @@ int skb_crc32c_csum_help(struct sk_buff *skb)
if (ret)
goto out;
- crc = ~skb_crc32c(skb, start, skb->len - start, ~0);
- *(__le32 *)(skb->data + offset) = cpu_to_le32(crc);
+ crc = ~0;
+ ret = skb_crc32c_full(skb, start, skb->len - start, &crc);
+ if (ret)
+ goto out;
+ *(__le32 *)(skb->data + offset) = cpu_to_le32(~crc);
skb_reset_csum_not_inet(skb);
out:
return ret;
diff --git a/net/core/filter.c b/net/core/filter.c
index 09c60a58c82abe..9881ac89e94c12 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -3723,9 +3723,9 @@ static int bpf_skb_net_grow(struct sk_buff *skb, u32 off, u32 len_diff,
shinfo->gso_segs = 0;
/* Due to header growth, MSS needs to be downgraded.
- * There is a BUG_ON() when segmenting the frag_list with
- * head_frag true, so linearize the skb after downgrading
- * the MSS.
+ * Segmenting a frag_list with head_frag true at the new MSS
+ * fails and the packet gets dropped, so linearize the skb
+ * after downgrading the MSS.
*/
if (!(flags & BPF_F_ADJ_ROOM_FIXED_GSO)) {
skb_decrease_gso_size(shinfo, len_diff);
diff --git a/net/core/gro.c b/net/core/gro.c
index 1b033855a20db6..e2e847c95270c7 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -798,10 +798,17 @@ EXPORT_SYMBOL(napi_gro_frags);
*/
__sum16 __skb_gro_checksum_complete(struct sk_buff *skb)
{
- __wsum wsum;
+ __wsum wsum = 0;
__sum16 sum;
- wsum = skb_checksum(skb, skb_gro_offset(skb), skb_gro_len(skb), 0);
+ /* If the data can't be checksummed it can't be valid either, and
+ * NAPI_GRO_CB(skb)->csum only holds the pseudo checksum.
+ */
+ if (skb_checksum_full(skb, skb_gro_offset(skb), skb_gro_len(skb),
+ &wsum)) {
+ NAPI_GRO_CB(skb)->csum_valid = 0;
+ return (__force __sum16)1;
+ }
/* NAPI_GRO_CB(skb)->csum holds pseudo checksum */
sum = csum_fold(csum_add(NAPI_GRO_CB(skb)->csum, wsum));
diff --git a/net/core/net_test.c b/net/core/net_test.c
index 2b5080c226636c..976d14896251df 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -41,6 +41,17 @@ enum gso_test_nr {
GSO_TEST_RESEGMENT_MULTI,
GSO_TEST_RESEGMENT_TAIL,
GSO_TEST_RESEGMENT_ONE_MSS,
+ GSO_TEST_FRAG_LIST_NON_UNIFORM_SG,
+ GSO_TEST_FRAG_LIST_NESTED,
+ GSO_TEST_SHORT_LINEAR,
+ GSO_TEST_SHORT_LINEAR_STRADDLE,
+ GSO_TEST_SHORT_FRAG_LIST,
+ GSO_TEST_SHORT_GSO_BY_FRAGS,
+ GSO_TEST_FRAG_LIST_NESTED_NO_SG,
+ GSO_TEST_SHORT_LINEAR_NO_SG,
+ GSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,
+ GSO_TEST_SHORT_FRAG_LIST_NO_SG,
+ GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,
};
struct gso_test_case {
@@ -58,11 +69,18 @@ struct gso_test_case {
unsigned int gso_type;
/* skbs from alloc_skb() instead of build_skb(), head_frag clear */
bool no_head_frag;
+ /* bytes that skb->len counts but the skb doesn't hold */
+ unsigned int missing_len;
+ /* segment without NETIF_F_SG */
+ bool no_sg;
/* output as expected */
unsigned int nr_segs;
const unsigned int *segs;
const unsigned int *gso_segs;
+
+ /* skb_segment() is expected to fail with this error */
+ int err;
};
static struct gso_test_case cases[] = {
@@ -241,6 +259,110 @@ static struct gso_test_case cases[] = {
},
.gso_segs = (const unsigned int[]) { 0, 0, 0, 0 },
},
+ {
+ /* frag_list members that don't end on gso_size boundaries
+ * can't be segmented with SG
+ */
+ .id = GSO_TEST_FRAG_LIST_NON_UNIFORM_SG,
+ .name = "frag_list_non_uniform_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 4,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, 1, GSO_TEST_SIZE, 2 },
+ .err = -EINVAL,
+ },
+ {
+ /* the second frag_list member hangs off the first one's
+ * frag_list instead of off the head's
+ */
+ .id = GSO_TEST_FRAG_LIST_NESTED,
+ .name = "frag_list_nested",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
+ .err = -EINVAL,
+ },
+ {
+ /* the data runs out on a segment boundary */
+ .id = GSO_TEST_SHORT_LINEAR,
+ .name = "short_linear",
+ .linear_len = GSO_TEST_SIZE,
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ /* the data runs out in the middle of a segment */
+ .id = GSO_TEST_SHORT_LINEAR_STRADDLE,
+ .name = "short_linear_straddle",
+ .linear_len = GSO_TEST_SIZE + 500,
+ .missing_len = 700,
+ .err = -EINVAL,
+ },
+ {
+ .id = GSO_TEST_SHORT_FRAG_LIST,
+ .name = "short_frag_list",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 1,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ .id = GSO_TEST_SHORT_GSO_BY_FRAGS,
+ .name = "short_gso_by_frags",
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { 100, 200 },
+ .missing_len = 50,
+ .err = -EINVAL,
+ },
+ {
+ /* without SG the nested data is copied by skb_copy_bits(),
+ * which does look inside a member's own frag_list
+ */
+ .id = GSO_TEST_FRAG_LIST_NESTED_NO_SG,
+ .name = "frag_list_nested_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE },
+ .no_sg = true,
+ .nr_segs = 3,
+ .segs = (const unsigned int[]) { GSO_TEST_SIZE, GSO_TEST_SIZE, GSO_TEST_SIZE },
+ },
+ {
+ /* without SG it is skb_copy_bits() that runs out of data */
+ .id = GSO_TEST_SHORT_LINEAR_NO_SG,
+ .name = "short_linear_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_LINEAR_STRADDLE_NO_SG,
+ .name = "short_linear_straddle_no_sg",
+ .linear_len = GSO_TEST_SIZE + 500,
+ .missing_len = 700,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_FRAG_LIST_NO_SG,
+ .name = "short_frag_list_no_sg",
+ .linear_len = GSO_TEST_SIZE,
+ .nr_frag_skbs = 1,
+ .frag_skbs = (const unsigned int[]) { GSO_TEST_SIZE },
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EFAULT,
+ },
+ {
+ .id = GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG,
+ .name = "short_gso_by_frags_no_sg",
+ .nr_frag_skbs = 2,
+ .frag_skbs = (const unsigned int[]) { 100, 200 },
+ .missing_len = 50,
+ .no_sg = true,
+ .err = -EINVAL,
+ },
};
static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)
@@ -337,21 +459,49 @@ static void gso_test_func(struct kunit *test)
skb->data_len += total_size;
skb->truesize += total_true_size;
- if (tcase->id == GSO_TEST_GSO_BY_FRAGS)
+ if (tcase->id == GSO_TEST_GSO_BY_FRAGS ||
+ tcase->id == GSO_TEST_SHORT_GSO_BY_FRAGS ||
+ tcase->id == GSO_TEST_SHORT_GSO_BY_FRAGS_NO_SG)
skb_shinfo(skb)->gso_size = GSO_BY_FRAGS;
+
+ if (tcase->id == GSO_TEST_FRAG_LIST_NESTED ||
+ tcase->id == GSO_TEST_FRAG_LIST_NESTED_NO_SG) {
+ struct sk_buff *first = skb_shinfo(skb)->frag_list;
+
+ skb_shinfo(first)->frag_list = first->next;
+ first->next = NULL;
+ first->len += tcase->frag_skbs[1];
+ first->data_len += tcase->frag_skbs[1];
+ }
}
+ skb->len += tcase->missing_len;
+ skb->data_len += tcase->missing_len;
+
features = NETIF_F_SG | NETIF_F_HW_CSUM;
if (tcase->id == GSO_TEST_GSO_PARTIAL)
features |= NETIF_F_GSO_PARTIAL;
- /* TODO: this should also work with SG,
- * rather than hit BUG_ON(i >= nfrags)
+ /* TODO: this should also work with SG, rather than fail the
+ * i >= nfrags check in skb_segment()
*/
- if (tcase->id == GSO_TEST_FRAG_LIST_NON_UNIFORM)
+ if (tcase->id == GSO_TEST_FRAG_LIST_NON_UNIFORM || tcase->no_sg)
features &= ~NETIF_F_SG;
SKB_GSO_CB(skb)->max_segs = tcase->max_segs;
+
+ if (tcase->err) {
+ /* the suppression block doesn't run if it can't be set up */
+ segs = NULL;
+ kunit_warning_suppress(test) {
+ segs = skb_segment(skb, features);
+ }
+ KUNIT_EXPECT_EQ(test, PTR_ERR_OR_ZERO(segs), tcase->err);
+ if (!IS_ERR_OR_NULL(segs))
+ kfree_skb_list(segs);
+ goto free_gso_skb;
+ }
+
segs = skb_segment(skb, features);
if (IS_ERR(segs)) {
KUNIT_FAIL(test, "segs error %pe", segs);
@@ -1374,7 +1524,7 @@ static void netmem_ref_test_skb_segment(struct kunit *test)
/* 5. Linear head_skb (nr_frags=0) + mixed pp_recycle frag_list where
* member A has linear + frag (pp_recycle=1) and tail member B has
* linear len == skb_headlen(A) (pp_recycle=0): keeps SG clone path
- * synchronized without hitting BUG_ON(i >= nfrags).
+ * synchronized without failing the i >= nfrags check.
*/
head = alloc_skb(64, GFP_KERNEL);
list = alloc_skb(64, GFP_KERNEL);
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 48f67641172433..29951ce11850b9 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -2821,9 +2821,23 @@ static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)
int delta = skb->len - len;
if (skb_frags_readable(skb)) {
- skb->csum = csum_block_sub(skb->csum,
- skb_checksum(skb, len, delta, 0),
- len);
+ __wsum csum = 0;
+ int err;
+
+ if (!skb_checksum_full(skb, len, delta, &csum)) {
+ skb->csum = csum_block_sub(skb->csum, csum, len);
+ return 0;
+ }
+
+ /* The trimmed bytes can't be checksummed, so skb->csum can't
+ * be adjusted. Software can checksum the remaining packet
+ * after trimming, as long as it can read it.
+ */
+ csum = 0;
+ err = skb_checksum_full(skb, 0, len, &csum);
+ if (err)
+ return err;
+ skb->ip_summed = CHECKSUM_NONE;
return 0;
}
@@ -3536,27 +3550,88 @@ int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len)
}
EXPORT_SYMBOL(skb_store_bits);
-/* Checksum skb data. */
-__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
+/* The frag_list part of skb_checksum_full(). It's out of line so that taking
+ * the address of csum2 doesn't cost every caller a stack protector.
+ */
+static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,
+ int offset, int len, int pos,
+ __wsum csum, __wsum *csump)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
+ skb_walk_frags(skb, frag_iter) {
+ int end;
+
+ WARN_ON(start > offset + len);
+
+ end = start + frag_iter->len;
+ copy = end - offset;
+ if (copy > 0) {
+ __wsum csum2 = 0;
+
+ if (copy > len)
+ copy = len;
+ err = skb_checksum_full(frag_iter, offset - start, copy,
+ &csum2);
+ if (err)
+ return err;
+ csum = csum_block_add(csum, csum2, pos);
+ len -= copy;
+ if (len == 0)
+ goto out;
+ offset += copy;
+ pos += copy;
+ }
+ start = end;
+ }
+ if (unlikely(len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EFAULT;
+ }
+out:
+ *csump = csum;
+ return 0;
+}
+
+/**
+ * skb_checksum_full - checksum a range of an skb
+ * @skb: buffer to checksum
+ * @offset: offset in @skb to start at
+ * @len: number of bytes to checksum
+ * @csump: the sum to add to; on success the range's sum is added to it
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * runs out before @len does, or if the range goes past the linear area
+ * of an skb, @skb or one on its frag_list, that has unreadable frags.
+ * On failure *@csump is not changed.
+ */
+int skb_checksum_full(const struct sk_buff *skb, int offset, int len,
+ __wsum *csump)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
+ __wsum csum = *csump;
int pos = 0;
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+
/* Checksum header. */
if (copy > 0) {
if (copy > len)
copy = len;
csum = csum_partial(skb->data + offset, copy, csum);
if ((len -= copy) == 0)
- return csum;
+ goto out;
offset += copy;
pos = copy;
}
- if (WARN_ON_ONCE(!skb_frags_readable(skb)))
- return 0;
+ if (!skb_frags_readable(skb))
+ return -EFAULT;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;
@@ -3585,52 +3660,114 @@ __wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
}
if (!(len -= copy))
- return csum;
+ goto out;
offset += copy;
}
start = end;
}
+ return skb_checksum_frag_list(skb, start, offset, len, pos, csum,
+ csump);
+out:
+ *csump = csum;
+ return 0;
+}
+EXPORT_SYMBOL(skb_checksum_full);
+
+/* skb_checksum() has no way to report failure, so it returns 0, which is a
+ * valid checksum. Use skb_checksum_full() in new code.
+ */
+__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)
+{
+ int err = skb_checksum_full(skb, offset, len, &csum);
+
+ if (unlikely(err)) {
+ WARN_ON_ONCE(err == -EFAULT && !skb_frags_readable(skb));
+ return 0;
+ }
+ return csum;
+}
+EXPORT_SYMBOL(skb_checksum);
+
+/* The frag_list part of skb_copy_and_csum_bits(). It's out of line so that
+ * taking the address of csum2 doesn't cost every caller a stack protector.
+ */
+static noinline int skb_copy_and_csum_frag_list(const struct sk_buff *skb,
+ int start, int offset, u8 *to,
+ int len, int pos, __wsum csum,
+ __wsum *csump)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
skb_walk_frags(skb, frag_iter) {
+ __wsum csum2;
int end;
WARN_ON(start > offset + len);
end = start + frag_iter->len;
- if ((copy = end - offset) > 0) {
- __wsum csum2;
+ copy = end - offset;
+ if (copy > 0) {
if (copy > len)
copy = len;
- csum2 = skb_checksum(frag_iter, offset - start, copy,
- 0);
+ err = skb_copy_and_csum_bits(frag_iter, offset - start,
+ to, copy, &csum2);
+ if (err) {
+ /* The child zeroed its part; zero the rest. */
+ memset(to + copy, 0, len - copy);
+ return err;
+ }
csum = csum_block_add(csum, csum2, pos);
- if ((len -= copy) == 0)
- return csum;
+ len -= copy;
+ if (len == 0)
+ goto out;
offset += copy;
+ to += copy;
pos += copy;
}
start = end;
}
if (unlikely(len)) {
DEBUG_NET_WARN_ON_ONCE(1);
- return 0;
+ /* Don't hand the caller a buffer with stale bytes in it. */
+ memset(to, 0, len);
+ return -EFAULT;
}
-
- return csum;
+out:
+ *csump = csum;
+ return 0;
}
-EXPORT_SYMBOL(skb_checksum);
-
-/* Both of above in one bottle. */
-__wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
- u8 *to, int len)
+/**
+ * skb_copy_and_csum_bits - copy data out of an skb and checksum it
+ * @skb: source buffer
+ * @offset: offset in @skb to start copying from
+ * @to: destination buffer
+ * @len: number of bytes to copy
+ * @csump: where to store the checksum of the copied bytes
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * has unreadable frags or runs out before @len does. On failure *@csump
+ * is not set. On -EFAULT the part of @to that couldn't be filled is
+ * zeroed, and on -EINVAL @to is not touched.
+ */
+int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
+ u8 *to, int len, __wsum *csump)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
int pos = 0;
__wsum csum = 0;
+ /* Everything below clamps its copy to @len, so a negative one would
+ * turn into a huge copy.
+ */
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
+
/* Copy header. */
if (copy > 0) {
if (copy > len)
@@ -3638,7 +3775,7 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
csum = csum_partial_copy_nocheck(skb->data + offset, to,
copy);
if ((len -= copy) == 0)
- return csum;
+ goto out;
offset += copy;
to += copy;
pos = copy;
@@ -3646,9 +3783,8 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
if (!skb_frags_readable(skb)) {
/* Don't hand the caller a buffer with stale bytes in it. */
- if (len > 0)
- memset(to, 0, len);
- return 0;
+ memset(to, 0, len);
+ return -EFAULT;
}
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
@@ -3680,64 +3816,95 @@ __wsum skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,
}
if (!(len -= copy))
- return csum;
+ goto out;
offset += copy;
to += copy;
}
start = end;
}
+ return skb_copy_and_csum_frag_list(skb, start, offset, to, len, pos,
+ csum, csump);
+out:
+ *csump = csum;
+ return 0;
+}
+EXPORT_SYMBOL(skb_copy_and_csum_bits);
+
+#ifdef CONFIG_NET_CRC32C
+/* The frag_list part of skb_crc32c_full(). It's out of line so that taking
+ * the address of crc doesn't cost every caller a stack protector.
+ */
+static noinline int skb_crc32c_frag_list(const struct sk_buff *skb, int start,
+ int offset, int len, u32 crc,
+ u32 *crcp)
+{
+ struct sk_buff *frag_iter;
+ int copy, err;
+
skb_walk_frags(skb, frag_iter) {
- __wsum csum2;
int end;
WARN_ON(start > offset + len);
end = start + frag_iter->len;
- if ((copy = end - offset) > 0) {
- if (copy > len)
- copy = len;
- csum2 = skb_copy_and_csum_bits(frag_iter,
- offset - start,
- to, copy);
- csum = csum_block_add(csum, csum2, pos);
- if ((len -= copy) == 0)
- return csum;
+ copy = end - offset;
+ if (copy > 0) {
+ copy = min(copy, len);
+ err = skb_crc32c_full(frag_iter, offset - start, copy,
+ &crc);
+ if (err)
+ return err;
+ len -= copy;
+ if (len == 0)
+ goto out;
offset += copy;
- to += copy;
- pos += copy;
}
start = end;
}
if (unlikely(len)) {
DEBUG_NET_WARN_ON_ONCE(1);
- /* Don't hand the caller a buffer with stale bytes in it. */
- if (len > 0)
- memset(to, 0, len);
- return 0;
+ return -EFAULT;
}
- return csum;
+out:
+ *crcp = crc;
+ return 0;
}
-EXPORT_SYMBOL(skb_copy_and_csum_bits);
-#ifdef CONFIG_NET_CRC32C
-u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
+/**
+ * skb_crc32c_full - CRC32C a range of an skb
+ * @skb: buffer to read
+ * @offset: offset in @skb to start at
+ * @len: number of bytes to include
+ * @crcp: the CRC to continue from; on success, updated with the range
+ *
+ * Return: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb
+ * runs out before @len does, or if the range goes past the linear area
+ * of an skb, @skb or one on its frag_list, that has unreadable frags.
+ * On failure *@crcp is not changed.
+ */
+int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)
{
int start = skb_headlen(skb);
int i, copy = start - offset;
- struct sk_buff *frag_iter;
+ u32 crc = *crcp;
+
+ if (unlikely(len < 0)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
if (copy > 0) {
copy = min(copy, len);
crc = crc32c(crc, skb->data + offset, copy);
len -= copy;
if (len == 0)
- return crc;
+ goto out;
offset += copy;
}
- if (WARN_ON_ONCE(!skb_frags_readable(skb)))
- return 0;
+ if (!skb_frags_readable(skb))
+ return -EFAULT;
for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
int end;
@@ -3762,44 +3929,57 @@ u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
}
len -= copy;
if (len == 0)
- return crc;
+ goto out;
offset += copy;
}
start = end;
}
- skb_walk_frags(skb, frag_iter) {
- int end;
+ return skb_crc32c_frag_list(skb, start, offset, len, crc, crcp);
+out:
+ *crcp = crc;
+ return 0;
+}
+EXPORT_SYMBOL(skb_crc32c_full);
- WARN_ON(start > offset + len);
+/* skb_crc32c() has no way to report failure, so it returns 0, which is a
+ * valid CRC. Use skb_crc32c_full() in new code.
+ */
+u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)
+{
+ int err = skb_crc32c_full(skb, offset, len, &crc);
- end = start + frag_iter->len;
- copy = end - offset;
- if (copy > 0) {
- copy = min(copy, len);
- crc = skb_crc32c(frag_iter, offset - start, copy, crc);
- len -= copy;
- if (len == 0)
- return crc;
- offset += copy;
- }
- start = end;
- }
- if (unlikely(len)) {
- DEBUG_NET_WARN_ON_ONCE(1);
+ if (unlikely(err)) {
+ WARN_ON_ONCE(err == -EFAULT && !skb_frags_readable(skb));
return 0;
}
-
return crc;
}
EXPORT_SYMBOL(skb_crc32c);
#endif /* CONFIG_NET_CRC32C */
+/* The data can't be checksummed, so it can't be valid either. The caller has
+ * put the pseudo header's checksum in skb->csum, so don't leave the skb
+ * CHECKSUM_COMPLETE for a later validator to take that for the packet's.
+ */
+static __sum16 skb_checksum_complete_failed(struct sk_buff *skb)
+{
+ if (!skb_shared(skb)) {
+ skb_checksum_complete_unset(skb);
+ skb->csum_valid = 0;
+ }
+ return (__force __sum16)1;
+}
+
__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)
{
+ __wsum csum = skb->csum;
__sum16 sum;
- sum = csum_fold(skb_checksum(skb, 0, len, skb->csum));
+ if (skb_checksum_full(skb, 0, len, &csum))
+ return skb_checksum_complete_failed(skb);
+
+ sum = csum_fold(csum);
/* See comments in __skb_checksum_complete(). */
if (likely(!sum)) {
if (unlikely(skb->ip_summed == CHECKSUM_COMPLETE) &&
@@ -3819,14 +3999,16 @@ EXPORT_SYMBOL(__skb_checksum_complete_head);
*
* It returns non-zero if the recomputed checksum is still invalid, otherwise
* zero. The new checksum is stored back into skb->csum unless the skb is
- * shared.
+ * shared. If the skb can't be checksummed it returns non-zero, skb->csum is
+ * left alone, and the skb is no longer CHECKSUM_COMPLETE unless it's shared.
*/
__sum16 __skb_checksum_complete(struct sk_buff *skb)
{
- __wsum csum;
+ __wsum csum = 0;
__sum16 sum;
- csum = skb_checksum(skb, 0, skb->len, 0);
+ if (skb_checksum_full(skb, 0, skb->len, &csum))
+ return skb_checksum_complete_failed(skb);
sum = csum_fold(csum_add(skb->csum, csum));
/* This check is inverted, because we already knew the hardware
@@ -3897,8 +4079,10 @@ EXPORT_SYMBOL_GPL(skb_zerocopy_headlen);
* Return value:
* 0: everything is OK
* -ENOMEM: couldn't orphan frags of @from due to lack of memory
- * -EFAULT: skb_copy_bits() found some problem with skb geometry, or readable head
- * payload would be mixed with unreadable frags.
+ * -EFAULT: skb_copy_bits() found some problem with skb geometry, @from has
+ * no head_frag and @hlen is 0 while @len doesn't fit in @to's tailroom,
+ * or readable head payload would be mixed with unreadable frags.
+ * -EINVAL: @len or @hlen is negative
*/
int
skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
@@ -3909,15 +4093,23 @@ skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)
struct page *page;
unsigned int offset;
- if (unlikely(!from->head_frag && !hlen)) {
+ if (unlikely(len < 0 || hlen < 0)) {
DEBUG_NET_WARN_ON_ONCE(1);
- return -EFAULT;
+ return -EINVAL;
}
/* dont bother with small payloads */
if (len <= skb_tailroom(to))
return skb_copy_bits(from, 0, skb_put(to, len), len);
+ /* Without a head_frag the head can't be referenced as a page, so the
+ * caller has to ask for it to be copied.
+ */
+ if (unlikely(!from->head_frag && !hlen)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EFAULT;
+ }
+
to->pp_recycle = from->pp_recycle;
if (hlen) {
ret = skb_copy_bits(from, 0, skb_put(to, hlen), hlen);
@@ -3980,6 +4172,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
__wsum csum;
long csstart;
+ /* skb_headlen() underflows if data_len is bigger than len, and then
+ * the checks below don't bound the copy from the linear area.
+ */
+ if (unlikely(skb->data_len > skb->len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ memset(to, 0, skb->len);
+ return;
+ }
+
if (skb->ip_summed == CHECKSUM_PARTIAL)
csstart = skb_checksum_start_offset(skb);
else
@@ -4001,9 +4202,15 @@ void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)
skb_copy_from_linear_data(skb, to, csstart);
csum = 0;
- if (csstart != skb->len)
- csum = skb_copy_and_csum_bits(skb, csstart, to + csstart,
- skb->len - csstart);
+ if (csstart != skb->len &&
+ skb_copy_and_csum_bits(skb, csstart, to + csstart,
+ skb->len - csstart, &csum)) {
+ /* Send zeroes rather than intact headers on a payload that
+ * couldn't be copied.
+ */
+ memset(to, 0, skb->len);
+ return;
+ }
if (skb->ip_summed == CHECKSUM_PARTIAL) {
long csstuff = csstart + skb->csum_offset;
@@ -4957,7 +5164,16 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
int hsize;
int size;
+ /* list_skb runs out early if head_skb->len counts data that
+ * this walk can't find: bytes that aren't there, or a member's
+ * own frag_list, which the walk never looks inside.
+ */
if (unlikely(gso_by_frags)) {
+ if (unlikely(!list_skb)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ err = -EINVAL;
+ goto err;
+ }
len = list_skb->len;
} else {
len = head_skb->len - offset;
@@ -4967,7 +5183,8 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
hsize = skb_headlen(head_skb) - offset;
- if (hsize <= 0 && i >= nfrags && skb_headlen(list_skb) &&
+ if (hsize <= 0 && i >= nfrags && list_skb &&
+ skb_headlen(list_skb) &&
(skb_headlen(list_skb) == len || sg)) {
if (unlikely(skb_headlen(list_skb) > len)) {
DEBUG_NET_WARN_ON_ONCE(1);
@@ -5057,16 +5274,20 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (!csum) {
if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
- SKB_GSO_CB(nskb)->csum =
- skb_copy_and_csum_bits(head_skb, offset,
- skb_put(nskb,
- len),
- len);
+ if (skb_copy_and_csum_bits(head_skb, offset,
+ skb_put(nskb, len),
+ len,
+ &SKB_GSO_CB(nskb)->csum)) {
+ err = -EFAULT;
+ goto err;
+ }
SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset;
} else {
- if (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len))
+ if (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len)) {
+ err = -EFAULT;
goto err;
+ }
}
continue;
}
@@ -5085,6 +5306,12 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
while (pos < offset + len) {
if (i >= nfrags) {
+ if (unlikely(!list_skb)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ err = -EINVAL;
+ goto err;
+ }
+
if (skb_shinfo(nskb)->nr_frags &&
nskb->pp_recycle != list_skb->pp_recycle) {
nskb->data_len = pos - offset - hsize;
@@ -5175,9 +5402,13 @@ struct sk_buff *skb_segment(struct sk_buff *head_skb,
if (!nskb->remcsum_offload)
nskb->ip_summed = CHECKSUM_NONE;
- SKB_GSO_CB(nskb)->csum =
- skb_checksum(nskb, doffset,
- nskb->len - doffset, 0);
+ SKB_GSO_CB(nskb)->csum = 0;
+ if (skb_checksum_full(nskb, doffset,
+ nskb->len - doffset,
+ &SKB_GSO_CB(nskb)->csum)) {
+ err = -EFAULT;
+ goto err;
+ }
SKB_GSO_CB(nskb)->csum_start =
skb_headroom(nskb) + doffset;
}
@@ -5410,8 +5641,9 @@ __skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len,
*
* Fill the specified scatter-gather list with mappings/pointers into a
* region of the buffer space attached to a socket buffer. Returns either
- * the number of scatterlist items used, or -EMSGSIZE if the contents
- * could not fit.
+ * the number of scatterlist items used, -EMSGSIZE if the contents
+ * could not fit, or -EINVAL if @offset and @len run past the end of
+ * the skb.
*/
int skb_to_sgvec(struct sk_buff *skb, struct scatterlist *sg, int offset, int len)
{
@@ -6281,7 +6513,8 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
bool *fragstolen, int *delta_truesize)
{
struct skb_shared_info *to_shinfo, *from_shinfo;
- int i, delta, len = from->len;
+ unsigned int len = from->len;
+ int i, delta;
*fragstolen = false;
@@ -6326,9 +6559,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
return false;
if (skb_headlen(from) != 0) {
- struct page *page;
- unsigned int offset;
-
if (to_shinfo->nr_frags +
from_shinfo->nr_frags >= MAX_SKB_FRAGS)
return false;
@@ -6337,13 +6567,6 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
return false;
delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
-
- page = virt_to_head_page(from->head);
- offset = from->data - (unsigned char *)page_address(page);
-
- skb_fill_page_desc(to, to_shinfo->nr_frags,
- page, offset, skb_headlen(from));
- *fragstolen = true;
} else {
if (to_shinfo->nr_frags +
from_shinfo->nr_frags > MAX_SKB_FRAGS)
@@ -6352,7 +6575,19 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
delta = from->truesize - SKB_TRUESIZE(skb_end_offset(from));
}
- WARN_ON_ONCE(delta < len);
+ /* @from claims more data than it has memory for. Leave @to alone. */
+ if (WARN_ON_ONCE(delta < 0 || delta < len))
+ return false;
+
+ if (skb_headlen(from) != 0) {
+ struct page *page = virt_to_head_page(from->head);
+ unsigned int offset;
+
+ offset = from->data - (unsigned char *)page_address(page);
+ skb_fill_page_desc(to, to_shinfo->nr_frags,
+ page, offset, skb_headlen(from));
+ *fragstolen = true;
+ }
memcpy(to_shinfo->frags + to_shinfo->nr_frags,
from_shinfo->frags,
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c
index 90c0e22c29bea6..35008785e3d228 100644
--- a/net/ipv4/icmp.c
+++ b/net/ipv4/icmp.c
@@ -364,12 +364,15 @@ static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,
DEFINE_RAW_FLEX(struct icmp_bxm, icmp_param, replyopts.opt.__data,
IP_OPTIONS_DATA_FIXED_SIZE);
__wsum csum;
+ int err;
icmp_param = from;
- csum = skb_copy_and_csum_bits(icmp_param->skb,
- icmp_param->offset + offset,
- to, len);
+ err = skb_copy_and_csum_bits(icmp_param->skb,
+ icmp_param->offset + offset,
+ to, len, &csum);
+ if (err)
+ return err;
skb->csum = csum_block_add(skb->csum, csum, odd);
if (icmp_param->data.icmph.type <= NR_ICMP_TYPES &&
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 3396f177a18d09..f7da4538d05b5c 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1162,9 +1162,14 @@ static int __ip_append_data(struct sock *sk,
data += fragheaderlen + exthdrlen;
if (fraggap) {
- skb->csum = skb_copy_and_csum_bits(
- skb_prev, maxfraglen,
- data + transhdrlen, fraggap);
+ if (skb_copy_and_csum_bits(skb_prev, maxfraglen,
+ data + transhdrlen,
+ fraggap,
+ &skb->csum)) {
+ err = -EFAULT;
+ kfree_skb(skb);
+ goto error;
+ }
skb_prev->csum = csum_sub(skb_prev->csum,
skb->csum);
data += fraggap;
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
index a95b0351824f32..31ca3da80b1f1e 100644
--- a/net/ipv6/icmp.c
+++ b/net/ipv6/icmp.c
@@ -322,9 +322,12 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st
struct icmpv6_msg *msg = (struct icmpv6_msg *) from;
struct sk_buff *org_skb = msg->skb;
__wsum csum;
+ int err;
- csum = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
- to, len);
+ err = skb_copy_and_csum_bits(org_skb, msg->offset + offset,
+ to, len, &csum);
+ if (err)
+ return err;
skb->csum = csum_block_add(skb->csum, csum, odd);
if (!(msg->type & ICMPV6_INFOMSG_MASK))
nf_ct_attach(skb, org_skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 25fe0ba98b1a6a..d259e7dca8ba21 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -1724,9 +1724,14 @@ static int __ip6_append_data(struct sock *sk,
skb->transport_header = (skb->network_header +
fragheaderlen);
if (fraggap) {
- skb->csum = skb_copy_and_csum_bits(
- skb_prev, maxfraglen,
- data + transhdrlen, fraggap);
+ if (skb_copy_and_csum_bits(skb_prev, maxfraglen,
+ data + transhdrlen,
+ fraggap,
+ &skb->csum)) {
+ err = -EFAULT;
+ kfree_skb(skb);
+ goto error;
+ }
skb_prev->csum = csum_sub(skb_prev->csum,
skb->csum);
data += fraggap;
diff --git a/net/sunrpc/socklib.c b/net/sunrpc/socklib.c
index d8d8842c7de5cd..5d780ad4ae3a03 100644
--- a/net/sunrpc/socklib.c
+++ b/net/sunrpc/socklib.c
@@ -49,7 +49,9 @@ xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)
if (desc->need_checksum) {
__wsum csum;
- csum = skb_copy_and_csum_bits(desc->skb, desc->offset, to, len);
+ if (unlikely(skb_copy_and_csum_bits(desc->skb, desc->offset,
+ to, len, &csum)))
+ return 0;
desc->csum = csum_block_add(desc->csum, csum, desc->offset);
} else {
if (unlikely(skb_copy_bits(desc->skb, desc->offset, to, len)))
@@ -142,11 +144,6 @@ int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
if (xdr_partial_copy_from_skb(xdr, &desc) < 0)
return -1;
- if (desc.offset != skb->len) {
- __wsum csum2;
- csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
- desc.csum = csum_block_add(desc.csum, csum2, desc.offset);
- }
if (desc.count)
return -1;
if (csum_fold(desc.csum))
diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c
index 771e02bff51999..748ae27f2b881c 100644
--- a/net/tls/tls_sw.c
+++ b/net/tls/tls_sw.c
@@ -142,12 +142,16 @@ static int __skb_nsg(struct sk_buff *skb, int offset, int len,
start = end;
}
}
- BUG_ON(len);
+ if (unlikely(len)) {
+ DEBUG_NET_WARN_ON_ONCE(1);
+ return -EINVAL;
+ }
return elt;
}
/* Return the number of scatterlist elements required to completely map the
- * skb, or -EMSGSIZE if the recursion depth is exceeded.
+ * skb, -EMSGSIZE if the recursion depth is exceeded, or -EINVAL if the skb
+ * runs out before @len does.
*/
static int skb_nsg(struct sk_buff *skb, int offset, int len)
{
|
| 49/3 | 2026/11/07 14:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 19056 output: 25 thoughts: 2060 Thoughts: **KMSAN Review: Patch Series for SKB Checksum and Copy Operations** Okay, let's break this down. The task is to determine if this patch series warrants a dedicated KMSAN session. The guiding principle is clear: if KASAN, LockDep, or other standard detectors can catch any bugs, a KMSAN session is overkill and a waste of resources. KMSAN is for *uninitialized memory* risks that are *only* exposed by KMSAN. My initial impression is that this series is primarily focused on hardening and error handling around checksum calculations and data copies within SKBs. I'm seeing a lot of changes to function signatures (specifically adding return values and `*csump` arguments to functions like `skb_copy_and_csum_bits`, `skb_checksum_full`, and `skb_crc32c_full`), and a consistent pattern of more robust error checking. It looks like the explicit handling of potential errors in data copies (particularly involving checksum calculations) is paramount. This includes zeroing out buffers in many failure paths and specific checks to prevent returning stale data. Specifically, I am noticing: * **Error Handling**: The patches extensively replace `BUG_ON` calls with error handling and `DEBUG_NET_WARN_ON_ONCE`. This is great for stability. * **Checksum Calculations**: Numerous functions now initialize checksum variables (`__wsum` and `u32`) before use. Error paths ensure those checksums are not used in an uninitialized state, and explicitly zeroing out memory regions when copies fail. * **Data Copying**: `skb_copy_and_csum_bits` is modified to prevent uninitialized memory reads. The code explicitly prevents returning a buffer with stale bytes. * **Checksum Completion**: The patches handle cases where a checksum calculation fails. My focus is on the `skb_copy_and_csum_bits`, `skb_checksum_full`, and checksum related functions, as these are the ones that could potentially introduce uninitialized memory problems or expose existing ones. The key is if any code still uses the results of the copy or checksum operations without checking the return value, or if functions use a checksum variable before it is initialized. Therefore, to confirm my initial impression, I must grep the entire tree for these functions. I need to make *absolutely sure* that the changes are complete and that I am not missing any potential issues. After grepping the whole tree, I must analyze the call sites and ensure that all callers handle the new error conditions *correctly*. Only if I find a case where the return value of any of these functions is *ignored* or if the checksum variable could be read uninitialized, then I will consider KMSAN. |
| 50/3 | 2026/11/07 14:37 | tool | grepper |
0mArgs:{
"Expression": "skb_copy_and_csum_bits"
}Results: {
"Output": "drivers/net/ethernet/sun/sunvnet_common.c=1109=static inline struct sk_buff *vnet_skb_shape(struct sk_buff *skb, int ncookies)\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-1169-\t\t\t*(__sum16 *)(skb-\u003edata + offset) = 0;\ndrivers/net/ethernet/sun/sunvnet_common.c:1170:\t\t\tif (skb_copy_and_csum_bits(skb, start,\ndrivers/net/ethernet/sun/sunvnet_common.c-1171-\t\t\t\t\t\t nskb-\u003edata + start,\n--\ninclude/linux/skbuff.h=4282=int skb_store_bits(struct sk_buff *skb, int offset, const void *from, int len);\ninclude/linux/skbuff.h:4283:int __must_check skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\ninclude/linux/skbuff.h-4284-\t\t\t\t\tu8 *to, int len, __wsum *csump);\n--\nnet/core/skbuff.c=3690=EXPORT_SYMBOL(skb_checksum);\nnet/core/skbuff.c-3691-\nnet/core/skbuff.c:3692:/* The frag_list part of skb_copy_and_csum_bits(). It's out of line so that\nnet/core/skbuff.c-3693- * taking the address of csum2 doesn't cost every caller a stack protector.\n--\nnet/core/skbuff.c=3695=static noinline int skb_copy_and_csum_frag_list(const struct sk_buff *skb,\n--\nnet/core/skbuff.c-3713-\t\t\t\tcopy = len;\nnet/core/skbuff.c:3714:\t\t\terr = skb_copy_and_csum_bits(frag_iter, offset - start,\nnet/core/skbuff.c-3715-\t\t\t\t\t\t to, copy, \u0026csum2);\n--\nnet/core/skbuff.c-3742-/**\nnet/core/skbuff.c:3743: *\tskb_copy_and_csum_bits - copy data out of an skb and checksum it\nnet/core/skbuff.c-3744- *\t@skb: source buffer\n--\nnet/core/skbuff.c-3754- */\nnet/core/skbuff.c:3755:int skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\nnet/core/skbuff.c-3756-\t\t\t u8 *to, int len, __wsum *csump)\n--\nnet/core/skbuff.c-3831-}\nnet/core/skbuff.c:3832:EXPORT_SYMBOL(skb_copy_and_csum_bits);\nnet/core/skbuff.c-3833-\n--\nnet/core/skbuff.c=4170=void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to)\n--\nnet/core/skbuff.c-4205-\tif (csstart != skb-\u003elen \u0026\u0026\nnet/core/skbuff.c:4206:\t skb_copy_and_csum_bits(skb, csstart, to + csstart,\nnet/core/skbuff.c-4207-\t\t\t\t skb-\u003elen - csstart, \u0026csum)) {\n--\nnet/core/skbuff.c=5052=struct sk_buff *skb_segment(struct sk_buff *head_skb,\n--\nnet/core/skbuff.c-5276-\t\t\t\t\tnskb-\u003eip_summed = CHECKSUM_NONE;\nnet/core/skbuff.c:5277:\t\t\t\tif (skb_copy_and_csum_bits(head_skb, offset,\nnet/core/skbuff.c-5278-\t\t\t\t\t\t\t skb_put(nskb, len),\n--\nnet/ipv4/icmp.c=361=static int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,\n--\nnet/ipv4/icmp.c-370-\nnet/ipv4/icmp.c:371:\terr = skb_copy_and_csum_bits(icmp_param-\u003eskb,\nnet/ipv4/icmp.c-372-\t\t\t\t icmp_param-\u003eoffset + offset,\n--\nnet/ipv4/ip_output.c=957=static int __ip_append_data(struct sock *sk,\n--\nnet/ipv4/ip_output.c-1164-\t\t\tif (fraggap) {\nnet/ipv4/ip_output.c:1165:\t\t\t\tif (skb_copy_and_csum_bits(skb_prev, maxfraglen,\nnet/ipv4/ip_output.c-1166-\t\t\t\t\t\t\t data + transhdrlen,\n--\nnet/ipv6/icmp.c=320=static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb)\n--\nnet/ipv6/icmp.c-326-\nnet/ipv6/icmp.c:327:\terr = skb_copy_and_csum_bits(org_skb, msg-\u003eoffset + offset,\nnet/ipv6/icmp.c-328-\t\t\t\t to, len, \u0026csum);\n--\nnet/ipv6/ip6_output.c=1453=static int __ip6_append_data(struct sock *sk,\n--\nnet/ipv6/ip6_output.c-1726-\t\t\tif (fraggap) {\nnet/ipv6/ip6_output.c:1727:\t\t\t\tif (skb_copy_and_csum_bits(skb_prev, maxfraglen,\nnet/ipv6/ip6_output.c-1728-\t\t\t\t\t\t\t data + transhdrlen,\n--\nnet/sunrpc/socklib.c=45=xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)\n--\nnet/sunrpc/socklib.c-51-\nnet/sunrpc/socklib.c:52:\t\tif (unlikely(skb_copy_and_csum_bits(desc-\u003eskb, desc-\u003eoffset,\nnet/sunrpc/socklib.c-53-\t\t\t\t\t\t to, len, \u0026csum)))\n"
} |
| 51/3 | 2026/11/07 14:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23412 output: 37 thoughts: 187 Thoughts: Okay, here's my take on those thoughts, framed as my own internal analysis: **Digging into `skb_copy_and_csum_bits` and a Potential Issue** Right, so I'm noticing something interesting about `skb_copy_and_csum_bits`. It's got that `__must_check` attribute in `include/linux/skbuff.h`, meaning the compiler *forces* me to examine its return value. And as expected, every single caller I've seen does indeed check that return value. That's good practice. I wouldn't expect anything less! But the error handling... that's where things get curious. If it fails, `skb_copy_and_csum_bits` doesn't modify `*csump`. Which makes sense, as the operation probably failed. But the *caller* doesn't even use `*csump` on error either; it bails out right away. They correctly check and then handle the error, which is the expected pattern. But hang on... I'm starting to wonder about a specific scenario in `skb_copy_and_csum_dev`. What if `csstart == skb->len`? That means we're trying to copy something that's at the end of the SKB, maybe even beyond the boundaries. I should take a closer look at the implementation of `skb_copy_and_csum_dev` in `net/core/skbuff.c` and see if my suspicion holds any water. Let's see how that function handles this potential edge case... |
| 52/3 | 2026/11/07 14:37 | tool | read-file |
0mArgs:{
"File": "net/core/skbuff.c",
"FirstLine": 4195,
"LineCount": 40
}Results: {
"Contents": "4195:\t\t\t * zeroes if we can't even copy it.\n4196:\t\t\t */\n4197:\t\t\tif (skb_copy_bits(skb, 0, to, skb-\u003elen))\n4198:\t\t\t\tmemset(to, 0, skb-\u003elen);\n4199:\t\t\treturn;\n4200:\t\t}\n4201:\t\n4202:\t\tskb_copy_from_linear_data(skb, to, csstart);\n4203:\t\n4204:\t\tcsum = 0;\n4205:\t\tif (csstart != skb-\u003elen \u0026\u0026\n4206:\t\t skb_copy_and_csum_bits(skb, csstart, to + csstart,\n4207:\t\t\t\t\t skb-\u003elen - csstart, \u0026csum)) {\n4208:\t\t\t/* Send zeroes rather than intact headers on a payload that\n4209:\t\t\t * couldn't be copied.\n4210:\t\t\t */\n4211:\t\t\tmemset(to, 0, skb-\u003elen);\n4212:\t\t\treturn;\n4213:\t\t}\n4214:\t\n4215:\t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL) {\n4216:\t\t\tlong csstuff = csstart + skb-\u003ecsum_offset;\n4217:\t\n4218:\t\t\t*((__sum16 *)(to + csstuff)) = csum_fold(csum);\n4219:\t\t}\n4220:\t}\n4221:\tEXPORT_SYMBOL(skb_copy_and_csum_dev);\n4222:\t\n4223:\t/**\n4224:\t *\tskb_dequeue - remove from the head of the queue\n4225:\t *\t@list: list to dequeue from\n4226:\t *\n4227:\t *\tRemove the head of the list. The list lock is taken so the function\n4228:\t *\tmay be used safely with other locking list functions. The head item is\n4229:\t *\treturned or %NULL if the list is empty.\n4230:\t */\n4231:\t\n4232:\tstruct sk_buff *skb_dequeue(struct sk_buff_head *list)\n4233:\t{\n4234:\t\tunsigned long flags;\n"
} |
| 53/3 | 2026/11/07 14:37 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 24601 output: 45 thoughts: 65 Thoughts: Okay, let's break this down. **Investigating a Potential Checksum Calculation Discrepancy** Right, so I'm looking at `skb_copy_and_csum_dev`. I see that the `csum` variable is *explicitly* initialized to zero right before that conditional block. This is standard, good practice really – crucial for any checksum operations. But it's this pattern I'm focusing on; it's the initialization that interests me. Hmm, but what about the broader context? I want to make sure I'm not missing something in the broader codebase, such as potentially a different implementation to this `skb_copy_and_csum_dev` function. Let me see... Where else is this relevant? Ah, that's right, `sunvnet_common.c`. I have a feeling the logic might be handled differently, or perhaps there is another implementation. Let's dig into `vnet_skb_shape`. I'm curious to see how that function interacts with checksums, and whether the same initialization pattern is followed, or if there's any deviation from the standard checksum-related procedures. That's the key to understanding the full picture here. |
| 54/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/sun/sunvnet_common.c",
"FirstLine": 1155,
"LineCount": 40
}Results: {
"Contents": "1155:\t\n1156:\t\t\tif (skb-\u003eip_summed == CHECKSUM_PARTIAL)\n1157:\t\t\t\tstart = skb_checksum_start_offset(skb);\n1158:\t\t\tif (start) {\n1159:\t\t\t\tint offset = start + nskb-\u003ecsum_offset;\n1160:\t\n1161:\t\t\t\t/* copy the headers, no csum here */\n1162:\t\t\t\tif (skb_copy_bits(skb, 0, nskb-\u003edata, start)) {\n1163:\t\t\t\t\tdev_kfree_skb(nskb);\n1164:\t\t\t\t\tdev_kfree_skb(skb);\n1165:\t\t\t\t\treturn NULL;\n1166:\t\t\t\t}\n1167:\t\n1168:\t\t\t\t/* copy the rest, with csum calculation */\n1169:\t\t\t\t*(__sum16 *)(skb-\u003edata + offset) = 0;\n1170:\t\t\t\tif (skb_copy_and_csum_bits(skb, start,\n1171:\t\t\t\t\t\t\t nskb-\u003edata + start,\n1172:\t\t\t\t\t\t\t skb-\u003elen - start, \u0026csum)) {\n1173:\t\t\t\t\tdev_kfree_skb(nskb);\n1174:\t\t\t\t\tdev_kfree_skb(skb);\n1175:\t\t\t\t\treturn NULL;\n1176:\t\t\t\t}\n1177:\t\n1178:\t\t\t\t/* add in the header checksums */\n1179:\t\t\t\tif (skb-\u003eprotocol == htons(ETH_P_IP)) {\n1180:\t\t\t\t\tstruct iphdr *iph = ip_hdr(nskb);\n1181:\t\n1182:\t\t\t\t\tif (iph-\u003eprotocol == IPPROTO_TCP ||\n1183:\t\t\t\t\t iph-\u003eprotocol == IPPROTO_UDP) {\n1184:\t\t\t\t\t\tcsum = csum_tcpudp_magic(iph-\u003esaddr,\n1185:\t\t\t\t\t\t\t\t\t iph-\u003edaddr,\n1186:\t\t\t\t\t\t\t\t\t skb-\u003elen - start,\n1187:\t\t\t\t\t\t\t\t\t iph-\u003eprotocol,\n1188:\t\t\t\t\t\t\t\t\t csum);\n1189:\t\t\t\t\t}\n1190:\t\t\t\t} else if (skb-\u003eprotocol == htons(ETH_P_IPV6)) {\n1191:\t\t\t\t\tstruct ipv6hdr *ip6h = ipv6_hdr(nskb);\n1192:\t\n1193:\t\t\t\t\tif (ip6h-\u003enexthdr == IPPROTO_TCP ||\n1194:\t\t\t\t\t ip6h-\u003enexthdr == IPPROTO_UDP) {\n"
} |
| 55/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 25631 output: 45 thoughts: 34 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm already deep in networking code and likely dealing with checksums: **Diving into the `vnet_skb_shape` Function** Alright, I'm in `vnet_skb_shape`, and I see `csum` being used. That's a key variable, especially in this context, so I need to understand exactly what it represents. I need to make sure I grasp its definition within this specific scope. I'm going to quickly jump back and check where and how `csum` is defined *earlier* in the `vnet_skb_shape` function. Knowing its scope and initialization is critical for tracing how the checksum is managed here. I can't proceed with my analysis without a precise understanding of `csum`. |
| 56/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/sun/sunvnet_common.c",
"FirstLine": 1110,
"LineCount": 40
}Results: {
"Contents": "1110:\t{\n1111:\t\tstruct sk_buff *nskb;\n1112:\t\tint i, len, pad, docopy;\n1113:\t\n1114:\t\tlen = skb-\u003elen;\n1115:\t\tpad = 0;\n1116:\t\tif (len \u003c ETH_ZLEN) {\n1117:\t\t\tpad += ETH_ZLEN - skb-\u003elen;\n1118:\t\t\tlen += pad;\n1119:\t\t}\n1120:\t\tlen += VNET_PACKET_SKIP;\n1121:\t\tpad += 8 - (len \u0026 7);\n1122:\t\n1123:\t\t/* make sure we have enough cookies and alignment in every frag */\n1124:\t\tdocopy = skb_shinfo(skb)-\u003enr_frags \u003e= ncookies;\n1125:\t\tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n1126:\t\t\tskb_frag_t *f = \u0026skb_shinfo(skb)-\u003efrags[i];\n1127:\t\n1128:\t\t\tdocopy |= skb_frag_off(f) \u0026 7;\n1129:\t\t}\n1130:\t\tif (((unsigned long)skb-\u003edata \u0026 7) != VNET_PACKET_SKIP ||\n1131:\t\t skb_tailroom(skb) \u003c pad ||\n1132:\t\t skb_headroom(skb) \u003c VNET_PACKET_SKIP || docopy) {\n1133:\t\t\tint start = 0, offset;\n1134:\t\t\t__wsum csum;\n1135:\t\n1136:\t\t\tlen = skb-\u003elen \u003e ETH_ZLEN ? skb-\u003elen : ETH_ZLEN;\n1137:\t\t\tnskb = alloc_and_align_skb(skb-\u003edev, len);\n1138:\t\t\tif (!nskb) {\n1139:\t\t\t\tdev_kfree_skb(skb);\n1140:\t\t\t\treturn NULL;\n1141:\t\t\t}\n1142:\t\t\tskb_reserve(nskb, VNET_PACKET_SKIP);\n1143:\t\n1144:\t\t\tnskb-\u003eprotocol = skb-\u003eprotocol;\n1145:\t\t\toffset = skb_mac_header(skb) - skb-\u003edata;\n1146:\t\t\tskb_set_mac_header(nskb, offset);\n1147:\t\t\toffset = skb_network_offset(skb);\n1148:\t\t\tskb_set_network_header(nskb, offset);\n1149:\t\t\toffset = skb_transport_offset(skb);\n"
} |
| 57/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 26589 output: 36 thoughts: 87 Thoughts: Okay, here's my interpretation of this logic, as though it were my own thought process, assuming I'm already well-versed in kernel networking internals: **Analyzing `skb_copy_and_csum_bits` in the Context of ICMP** Alright, so `skb_copy_and_csum_bits`. Let me break this down. If the function hands back a zero (meaning, success), then the `csum` variable *should* be populated with the checksum by the function itself. However, if `skb_copy_and_csum_bits` returns anything *other* than zero—an error code, in other words—then things get messy. In that case, the function bails out, frees the `skb`s, and returns NULL, without touching `csum` at all. So, `csum` won't contain any useful data in this error path. Got it. I need to make sure my code handles that error condition gracefully, avoiding attempts to read garbage data. Now, let me see how this is used in practice, specifically within the ICMP implementation. Let's dig into the `icmp_glue_bits` function within `net/ipv4/icmp.c` to understand the specifics of how they're handling this. |
| 58/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/ipv4/icmp.c",
"FirstLine": 360,
"LineCount": 35
}Results: {
"Contents": " 360:\t */\n 361:\tstatic int icmp_glue_bits(void *from, char *to, int offset, int len, int odd,\n 362:\t\t\t\t struct sk_buff *skb)\n 363:\t{\n 364:\t\tDEFINE_RAW_FLEX(struct icmp_bxm, icmp_param, replyopts.opt.__data,\n 365:\t\t\t\tIP_OPTIONS_DATA_FIXED_SIZE);\n 366:\t\t__wsum csum;\n 367:\t\tint err;\n 368:\t\n 369:\t\ticmp_param = from;\n 370:\t\n 371:\t\terr = skb_copy_and_csum_bits(icmp_param-\u003eskb,\n 372:\t\t\t\t\t icmp_param-\u003eoffset + offset,\n 373:\t\t\t\t\t to, len, \u0026csum);\n 374:\t\tif (err)\n 375:\t\t\treturn err;\n 376:\t\n 377:\t\tskb-\u003ecsum = csum_block_add(skb-\u003ecsum, csum, odd);\n 378:\t\tif (icmp_param-\u003edata.icmph.type \u003c= NR_ICMP_TYPES \u0026\u0026\n 379:\t\t icmp_pointers[array_index_nospec(icmp_param-\u003edata.icmph.type,\n 380:\t\t\t\t\t\t NR_ICMP_TYPES + 1)].error)\n 381:\t\t\tnf_ct_attach(skb, icmp_param-\u003eskb);\n 382:\t\treturn 0;\n 383:\t}\n 384:\t\n 385:\tstatic void icmp_push_reply(struct sock *sk,\n 386:\t\t\t\t struct icmp_bxm *icmp_param,\n 387:\t\t\t\t struct flowi4 *fl4,\n 388:\t\t\t\t struct ipcm_cookie *ipc, struct rtable **rt)\n 389:\t{\n 390:\t\tstruct sk_buff *skb;\n 391:\t\n 392:\t\tif (ip_append_data(sk, fl4, icmp_glue_bits, icmp_param,\n 393:\t\t\t\t icmp_param-\u003edata_len+icmp_param-\u003ehead_len,\n 394:\t\t\t\t icmp_param-\u003ehead_len,\n"
} |
| 59/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27599 output: 36 thoughts: 71 Thoughts: Here's my summary, as I see it: **Analyzing ICMP Checksum Handling** Okay, so I'm looking at how ICMP checksums are handled. Specifically, in the `icmp_glue_bits` function, there's a crucial conditional dependency. If an error, `err`, is returned, then the `csum` value is *not* utilized. However, if no error is present, then `skb_copy_and_csum_bits` is responsible for writing the `csum` value. So, the presence of an error, or lack thereof, directly influences how the checksum is calculated and employed, and therefore requires investigation to ensure correct functionality. Let's delve into the `icmpv6_getfrag` function within `net/ipv6/icmp.c` to look at how this logic is implemented in the IPv6 context. I suspect the checksum behavior there needs to be aligned. |
| 60/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/ipv6/icmp.c",
"FirstLine": 320,
"LineCount": 25
}Results: {
"Contents": " 320:\tstatic int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, struct sk_buff *skb)\n 321:\t{\n 322:\t\tstruct icmpv6_msg *msg = (struct icmpv6_msg *) from;\n 323:\t\tstruct sk_buff *org_skb = msg-\u003eskb;\n 324:\t\t__wsum csum;\n 325:\t\tint err;\n 326:\t\n 327:\t\terr = skb_copy_and_csum_bits(org_skb, msg-\u003eoffset + offset,\n 328:\t\t\t\t\t to, len, \u0026csum);\n 329:\t\tif (err)\n 330:\t\t\treturn err;\n 331:\t\tskb-\u003ecsum = csum_block_add(skb-\u003ecsum, csum, odd);\n 332:\t\tif (!(msg-\u003etype \u0026 ICMPV6_INFOMSG_MASK))\n 333:\t\t\tnf_ct_attach(skb, org_skb);\n 334:\t\treturn 0;\n 335:\t}\n 336:\t\n 337:\t#if IS_ENABLED(CONFIG_IPV6_MIP6)\n 338:\tstatic void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt)\n 339:\t{\n 340:\t\tstruct ipv6hdr *iph = ipv6_hdr(skb);\n 341:\t\tstruct ipv6_destopt_hao *hao;\n 342:\t\tint off;\n 343:\t\n 344:\t\tif (opt-\u003edsthao) {\n"
} |
| 61/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28356 output: 37 thoughts: 33 Thoughts: Here's my analysis of the provided snippet, tailored for an expert like myself: **Diving Deeper into Fragmentation and Segmentation** Okay, so we've established the similarity in behavior within `icmpv6_getfrag`. My immediate thought is to understand where this commonality stems from and how it translates to the underlying data structure manipulation. The next logical step is to dive into the core segmentation logic, specifically, `skb_segment` within `net/core/skbuff.c`. I need to see how the Socket Buffer (`skb`) is actually split up and how that process affects the reassembly implications we observed earlier. The architecture demands a granular understanding of how this function interacts with the fragmentation process in the IPv6 context. I'm keen to see if this method has been designed to address the nuances of IPv6 fragmentation, or if it is a general, more abstract method that is leveraged at a higher layer. |
| 62/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/core/skbuff.c",
"FirstLine": 5265,
"LineCount": 50
}Results: {
"Contents": "5265:\t\n5266:\t\t\tskb_copy_from_linear_data_offset(head_skb, -tnl_hlen,\n5267:\t\t\t\t\t\t\t nskb-\u003edata - tnl_hlen,\n5268:\t\t\t\t\t\t\t doffset + tnl_hlen);\n5269:\t\n5270:\t\t\tif (nskb-\u003elen == len + doffset)\n5271:\t\t\t\tgoto perform_csum_check;\n5272:\t\n5273:\t\t\tif (!sg) {\n5274:\t\t\t\tif (!csum) {\n5275:\t\t\t\t\tif (!nskb-\u003eremcsum_offload)\n5276:\t\t\t\t\t\tnskb-\u003eip_summed = CHECKSUM_NONE;\n5277:\t\t\t\t\tif (skb_copy_and_csum_bits(head_skb, offset,\n5278:\t\t\t\t\t\t\t\t skb_put(nskb, len),\n5279:\t\t\t\t\t\t\t\t len,\n5280:\t\t\t\t\t\t\t\t \u0026SKB_GSO_CB(nskb)-\u003ecsum)) {\n5281:\t\t\t\t\t\terr = -EFAULT;\n5282:\t\t\t\t\t\tgoto err;\n5283:\t\t\t\t\t}\n5284:\t\t\t\t\tSKB_GSO_CB(nskb)-\u003ecsum_start =\n5285:\t\t\t\t\t\tskb_headroom(nskb) + doffset;\n5286:\t\t\t\t} else {\n5287:\t\t\t\t\tif (skb_copy_bits(head_skb, offset, skb_put(nskb, len), len)) {\n5288:\t\t\t\t\t\terr = -EFAULT;\n5289:\t\t\t\t\t\tgoto err;\n5290:\t\t\t\t\t}\n5291:\t\t\t\t}\n5292:\t\t\t\tcontinue;\n5293:\t\t\t}\n5294:\t\n5295:\t\t\tnskb_frag = skb_shinfo(nskb)-\u003efrags;\n5296:\t\n5297:\t\t\tskb_copy_from_linear_data_offset(head_skb, offset,\n5298:\t\t\t\t\t\t\t skb_put(nskb, hsize), hsize);\n5299:\t\n5300:\t\t\tskb_shinfo(nskb)-\u003eflags |= (skb_shinfo(head_skb)-\u003eflags |\n5301:\t\t\t\t\t\t skb_shinfo(frag_skb)-\u003eflags) \u0026\n5302:\t\t\t\t\t\t SKBFL_SHARED_FRAG;\n5303:\t\n5304:\t\t\tif (skb_zerocopy_clone(nskb, frag_skb, GFP_ATOMIC))\n5305:\t\t\t\tgoto err;\n5306:\t\n5307:\t\t\twhile (pos \u003c offset + len) {\n5308:\t\t\t\tif (i \u003e= nfrags) {\n5309:\t\t\t\t\tif (unlikely(!list_skb)) {\n5310:\t\t\t\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n5311:\t\t\t\t\t\terr = -EINVAL;\n5312:\t\t\t\t\t\tgoto err;\n5313:\t\t\t\t\t}\n5314:\t\n"
} |
| 63/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 29402 output: 37 thoughts: 491 Thoughts: **Checksum Handling in Network Data Transfers** Okay, let's break this down. I'm looking at how checksums are handled within the network stack, specifically concerning potential error conditions and the logic behind them. First, I'm examining `skb_segment`, around line 5400, and I'm focusing on the checksum calculation process for segmented skbs. I see that `SKB_GSO_CB(nskb)->csum` is explicitly initialized to 0. Then, `skb_checksum_full` is called, and if it encounters a problem during the checksum calculation and returns an error (meaning the function's return value is not 0), we jump to the `err` label. The subsequent calculation updates the checksum start and calculates the sum of the data. The important part is that the control flow immediately goes to `err` on an error from `skb_checksum_full`. Now, I'm shifting gears and looking at `net/sunrpc/socklib.c`, specifically `xdr_skb_read_bits`. Here, I see a conditional checksum calculation performed using `skb_copy_and_csum_bits` when `desc->need_checksum` is true. If `skb_copy_and_csum_bits` fails – which is indicated by a return value of 0 – the function returns 0 (representing 0 bytes read), and critically, the local variable `csum` that would have contained the checksum is **not** used. My immediate question is, what does "failing" look like from the perspective of `skb_copy_and_csum_bits`? If it fails, what's going on underneath? I need to understand the error conditions. To get a better grasp of the potential causes of failure I'm moving on to `net/core/skbuff.c` to look at the implementation of `skb_copy_and_csum_bits`. |
| 64/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/core/skbuff.c",
"FirstLine": 3750,
"LineCount": 80
}Results: {
"Contents": "3750:\t *\tReturn: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb\n3751:\t *\thas unreadable frags or runs out before @len does. On failure *@csump\n3752:\t *\tis not set. On -EFAULT the part of @to that couldn't be filled is\n3753:\t *\tzeroed, and on -EINVAL @to is not touched.\n3754:\t */\n3755:\tint skb_copy_and_csum_bits(const struct sk_buff *skb, int offset,\n3756:\t\t\t\t u8 *to, int len, __wsum *csump)\n3757:\t{\n3758:\t\tint start = skb_headlen(skb);\n3759:\t\tint i, copy = start - offset;\n3760:\t\tint pos = 0;\n3761:\t\t__wsum csum = 0;\n3762:\t\n3763:\t\t/* Everything below clamps its copy to @len, so a negative one would\n3764:\t\t * turn into a huge copy.\n3765:\t\t */\n3766:\t\tif (unlikely(len \u003c 0)) {\n3767:\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n3768:\t\t\treturn -EINVAL;\n3769:\t\t}\n3770:\t\n3771:\t\t/* Copy header. */\n3772:\t\tif (copy \u003e 0) {\n3773:\t\t\tif (copy \u003e len)\n3774:\t\t\t\tcopy = len;\n3775:\t\t\tcsum = csum_partial_copy_nocheck(skb-\u003edata + offset, to,\n3776:\t\t\t\t\t\t\t copy);\n3777:\t\t\tif ((len -= copy) == 0)\n3778:\t\t\t\tgoto out;\n3779:\t\t\toffset += copy;\n3780:\t\t\tto += copy;\n3781:\t\t\tpos\t= copy;\n3782:\t\t}\n3783:\t\n3784:\t\tif (!skb_frags_readable(skb)) {\n3785:\t\t\t/* Don't hand the caller a buffer with stale bytes in it. */\n3786:\t\t\tmemset(to, 0, len);\n3787:\t\t\treturn -EFAULT;\n3788:\t\t}\n3789:\t\n3790:\t\tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n3791:\t\t\tint end;\n3792:\t\n3793:\t\t\tWARN_ON(start \u003e offset + len);\n3794:\t\n3795:\t\t\tend = start + skb_frag_size(\u0026skb_shinfo(skb)-\u003efrags[i]);\n3796:\t\t\tif ((copy = end - offset) \u003e 0) {\n3797:\t\t\t\tskb_frag_t *frag = \u0026skb_shinfo(skb)-\u003efrags[i];\n3798:\t\t\t\tu32 p_off, p_len, copied;\n3799:\t\t\t\tstruct page *p;\n3800:\t\t\t\t__wsum csum2;\n3801:\t\t\t\tu8 *vaddr;\n3802:\t\n3803:\t\t\t\tif (copy \u003e len)\n3804:\t\t\t\t\tcopy = len;\n3805:\t\n3806:\t\t\t\tskb_frag_foreach_page(frag,\n3807:\t\t\t\t\t\t skb_frag_off(frag) + offset - start,\n3808:\t\t\t\t\t\t copy, p, p_off, p_len, copied) {\n3809:\t\t\t\t\tvaddr = kmap_atomic(p);\n3810:\t\t\t\t\tcsum2 = csum_partial_copy_nocheck(vaddr + p_off,\n3811:\t\t\t\t\t\t\t\t\t to + copied,\n3812:\t\t\t\t\t\t\t\t\t p_len);\n3813:\t\t\t\t\tkunmap_atomic(vaddr);\n3814:\t\t\t\t\tcsum = csum_block_add(csum, csum2, pos);\n3815:\t\t\t\t\tpos += p_len;\n3816:\t\t\t\t}\n3817:\t\n3818:\t\t\t\tif (!(len -= copy))\n3819:\t\t\t\t\tgoto out;\n3820:\t\t\t\toffset += copy;\n3821:\t\t\t\tto += copy;\n3822:\t\t\t}\n3823:\t\t\tstart = end;\n3824:\t\t}\n3825:\t\n3826:\t\treturn skb_copy_and_csum_frag_list(skb, start, offset, to, len, pos,\n3827:\t\t\t\t\t\t csum, csump);\n3828:\tout:\n3829:\t\t*csump = csum;\n"
} |
| 65/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 31596 output: 37 thoughts: 19 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience, and written as if they were my own internal monologue: **Investigating `skb_copy_and_csum_frag_list`** Right, let's dive into `skb_copy_and_csum_frag_list`. I need to refresh my understanding of its role in fragment handling, particularly the checksumming aspect. I'm assuming it's used when we need to create a *copy* of an SKB (Socket Buffer) that's composed of multiple fragments, and we need to calculate the checksum on the fly during the copy. The "csum" part is key here; it's not just a copy, it's a *copy-and-compute* operation. I wonder about the exact situations where this is preferred over other approaches. Does it offer performance advantages, or is it primarily chosen for scenarios where checksum integrity is paramount, or perhaps both? We need to consider potential optimization strategies. I'm keen to examine the code path itself; where are the checksum updates actually performed? Are there any obvious bottlenecks, or areas that could be improved with more modern hardware acceleration? And what are the implications of the "frag_list" aspect? It’s probably related to network interface cards (NICs) with scatter-gather capabilities but it is also likely impacted by the underlying memory architecture. Are we utilizing DMA effectively or can we avoid costly memory copies? A deep dive is required to understand the nuances. |
| 66/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/core/skbuff.c",
"FirstLine": 3695,
"LineCount": 50
}Results: {
"Contents": "3695:\tstatic noinline int skb_copy_and_csum_frag_list(const struct sk_buff *skb,\n3696:\t\t\t\t\t\t\tint start, int offset, u8 *to,\n3697:\t\t\t\t\t\t\tint len, int pos, __wsum csum,\n3698:\t\t\t\t\t\t\t__wsum *csump)\n3699:\t{\n3700:\t\tstruct sk_buff *frag_iter;\n3701:\t\tint copy, err;\n3702:\t\n3703:\t\tskb_walk_frags(skb, frag_iter) {\n3704:\t\t\t__wsum csum2;\n3705:\t\t\tint end;\n3706:\t\n3707:\t\t\tWARN_ON(start \u003e offset + len);\n3708:\t\n3709:\t\t\tend = start + frag_iter-\u003elen;\n3710:\t\t\tcopy = end - offset;\n3711:\t\t\tif (copy \u003e 0) {\n3712:\t\t\t\tif (copy \u003e len)\n3713:\t\t\t\t\tcopy = len;\n3714:\t\t\t\terr = skb_copy_and_csum_bits(frag_iter, offset - start,\n3715:\t\t\t\t\t\t\t to, copy, \u0026csum2);\n3716:\t\t\t\tif (err) {\n3717:\t\t\t\t\t/* The child zeroed its part; zero the rest. */\n3718:\t\t\t\t\tmemset(to + copy, 0, len - copy);\n3719:\t\t\t\t\treturn err;\n3720:\t\t\t\t}\n3721:\t\t\t\tcsum = csum_block_add(csum, csum2, pos);\n3722:\t\t\t\tlen -= copy;\n3723:\t\t\t\tif (len == 0)\n3724:\t\t\t\t\tgoto out;\n3725:\t\t\t\toffset += copy;\n3726:\t\t\t\tto += copy;\n3727:\t\t\t\tpos += copy;\n3728:\t\t\t}\n3729:\t\t\tstart = end;\n3730:\t\t}\n3731:\t\tif (unlikely(len)) {\n3732:\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n3733:\t\t\t/* Don't hand the caller a buffer with stale bytes in it. */\n3734:\t\t\tmemset(to, 0, len);\n3735:\t\t\treturn -EFAULT;\n3736:\t\t}\n3737:\tout:\n3738:\t\t*csump = csum;\n3739:\t\treturn 0;\n3740:\t}\n3741:\t\n3742:\t/**\n3743:\t *\tskb_copy_and_csum_bits - copy data out of an skb and checksum it\n3744:\t *\t@skb: source buffer\n"
} |
| 67/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 32696 output: 37 thoughts: 93 Thoughts: Okay, let's break this down. **Checksum and Memory Safety Considerations in the Linux Kernel** Alright, so I'm looking at `skb_copy_and_csum_bits`, and that `memset(to, 0, len)` call when an error occurs really caught my eye. They're explicitly zeroing the destination buffer. Smart. They're ensuring the `to` buffer is clean, no leftover garbage from a failed copy operation leaking into the data stream. Good practice, especially considering we're dealing with potentially sensitive network data. The whole point is to avoid uninitialized or stale bytes. And, of course, every caller of `skb_copy_and_csum_bits` seems to either discard the packet entirely or abort further processing on an error. That's the expected approach with checksums - failure is generally catastrophic. Now, the question that comes to mind is, how does `skb_checksum_full` handle things? That's the function that immediately comes to mind. Is it doing something similar with the buffer? What does it do with the destination? I need to check how the checksum is calculated in that context. Let's see how `skb_checksum_full` implements this. |
| 68/3 | 2026/11/07 14:38 | tool | read-file |
0mArgs:{
"File": "net/core/skbuff.c",
"FirstLine": 3600,
"LineCount": 70
}Results: {
"Contents": "3600:\t *\t@offset: offset in @skb to start at\n3601:\t *\t@len: number of bytes to checksum\n3602:\t *\t@csump: the sum to add to; on success the range's sum is added to it\n3603:\t *\n3604:\t *\tReturn: 0 on success, -EINVAL if @len is negative, or -EFAULT if @skb\n3605:\t *\truns out before @len does, or if the range goes past the linear area\n3606:\t *\tof an skb, @skb or one on its frag_list, that has unreadable frags.\n3607:\t *\tOn failure *@csump is not changed.\n3608:\t */\n3609:\tint skb_checksum_full(const struct sk_buff *skb, int offset, int len,\n3610:\t\t\t __wsum *csump)\n3611:\t{\n3612:\t\tint start = skb_headlen(skb);\n3613:\t\tint i, copy = start - offset;\n3614:\t\t__wsum csum = *csump;\n3615:\t\tint pos = 0;\n3616:\t\n3617:\t\tif (unlikely(len \u003c 0)) {\n3618:\t\t\tDEBUG_NET_WARN_ON_ONCE(1);\n3619:\t\t\treturn -EINVAL;\n3620:\t\t}\n3621:\t\n3622:\t\t/* Checksum header. */\n3623:\t\tif (copy \u003e 0) {\n3624:\t\t\tif (copy \u003e len)\n3625:\t\t\t\tcopy = len;\n3626:\t\t\tcsum = csum_partial(skb-\u003edata + offset, copy, csum);\n3627:\t\t\tif ((len -= copy) == 0)\n3628:\t\t\t\tgoto out;\n3629:\t\t\toffset += copy;\n3630:\t\t\tpos\t= copy;\n3631:\t\t}\n3632:\t\n3633:\t\tif (!skb_frags_readable(skb))\n3634:\t\t\treturn -EFAULT;\n3635:\t\n3636:\t\tfor (i = 0; i \u003c skb_shinfo(skb)-\u003enr_frags; i++) {\n3637:\t\t\tint end;\n3638:\t\t\tskb_frag_t *frag = \u0026skb_shinfo(skb)-\u003efrags[i];\n3639:\t\n3640:\t\t\tWARN_ON(start \u003e offset + len);\n3641:\t\n3642:\t\t\tend = start + skb_frag_size(frag);\n3643:\t\t\tif ((copy = end - offset) \u003e 0) {\n3644:\t\t\t\tu32 p_off, p_len, copied;\n3645:\t\t\t\tstruct page *p;\n3646:\t\t\t\t__wsum csum2;\n3647:\t\t\t\tu8 *vaddr;\n3648:\t\n3649:\t\t\t\tif (copy \u003e len)\n3650:\t\t\t\t\tcopy = len;\n3651:\t\n3652:\t\t\t\tskb_frag_foreach_page(frag,\n3653:\t\t\t\t\t\t skb_frag_off(frag) + offset - start,\n3654:\t\t\t\t\t\t copy, p, p_off, p_len, copied) {\n3655:\t\t\t\t\tvaddr = kmap_atomic(p);\n3656:\t\t\t\t\tcsum2 = csum_partial(vaddr + p_off, p_len, 0);\n3657:\t\t\t\t\tkunmap_atomic(vaddr);\n3658:\t\t\t\t\tcsum = csum_block_add(csum, csum2, pos);\n3659:\t\t\t\t\tpos += p_len;\n3660:\t\t\t\t}\n3661:\t\n3662:\t\t\t\tif (!(len -= copy))\n3663:\t\t\t\t\tgoto out;\n3664:\t\t\t\toffset += copy;\n3665:\t\t\t}\n3666:\t\t\tstart = end;\n3667:\t\t}\n3668:\t\n3669:\t\treturn skb_checksum_frag_list(skb, start, offset, len, pos, csum,\n"
} |
| 69/3 | 2026/11/07 14:38 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34190 output: 411 thoughts: 3647 Thoughts: **KMSAN Evaluation for SKB and Checksum Refactoring** Alright, let's break this down systematically. I've reviewed the calls to `skb_checksum_full` and its related functions like `skb_crc32c_full`, examining how checksums (`csum`, `wsum`, `crc`) are handled and how error conditions are managed. The primary goal seems to be to strengthen error handling and make checksum calculations more robust, especially concerning potential issues with malformed SKBs during segmentation or copy operations. In every instance I observed, checksum variables are *always* initialized before being passed to `skb_checksum_full` (or related functions). Often initialized to zero (`0`), or `~0`, and frequently error is immediately handled on an error return code. Error conditions in these functions, indicated by non-zero return values, are *always* checked and handled immediately by either aborting, jumping to an error path, or zeroing a buffer before returning, ensuring that uninitialized memory isn't read. Functions like `skb_copy_and_csum_bits`, `skb_copy_and_csum_dev`, are particularly defensive, explicitly zeroing memory in failure paths to prevent information leaks or the possibility of reading stale data. Defensive coding is observed everywhere. Considering the KMSAN guidelines, the key questions are: are we introducing uninitialized memory risks? The answer is a clear *no*. The code changes don't involve sending kernel structures to userspace without initialization. No conditional logic relies on uninitialized variables, and there aren't any new allocations of complex data structures where uninitialized fields could be read later. The modifications also don't introduce or alter bounds checks or lengths in a way that allows access to uninitialized memory; on the contrary, it adds checks against negative lengths, deals with fragment exhaustion in GSO segmentation to avoid dereferencing null pointers, and specifically zero out destinations on copy error to prevent information leakage. The primary issues addressed involve the strengthening of error handling, prevention of crashes from SKB malformations, or the prevention of data leaks. These concerns are largely out-of-bounds access, potential NULL pointer dereferences, or handling of invalid SKB lengths. These categories are well-addressed by KASAN and standard kernel debug checks. Therefore, since the patch *explicitly* avoids uninitialized memory reads through careful initialization, error checking, and defensive zeroing, setting `NeedsKMSAN` to `false` is the right call here. We're effectively addressing memory safety concerns that are already covered by existing standard debug tools. The risks involved are related to out-of-bounds access, not uninitialized memory. |
| 70/3 | 2026/11/07 14:39 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch series refactors skb checksumming and copying functions (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits) to return proper error codes rather than silently returning 0 upon failure or hitting BUG_ONs. It also improves bounds checking and error handling across skb segmentation (skb_segment), coalescing (skb_try_coalesce), and zerocopy logic to handle malformed or truncated skb frag lists gracefully.\n\nRegarding uninitialized memory:\n- All checksum output variables passed by reference across callers (e.g. in dev.c, gro.c, icmp.c, ip_output.c, skbuff.c) are either explicitly initialized (e.g., `__wsum csum = 0;`, `u32 crc = ~0;`) or guarded by `__must_check` return codes that trigger immediate error returns or packet drops prior to any use of the checksum value.\n- In partial failure scenarios within `skb_copy_and_csum_bits`, `skb_copy_and_csum_frag_list`, and `skb_copy_and_csum_dev`, destination buffers are defensively zeroed via `memset` to prevent leaving stale or uninitialized bytes in copied buffers.\n- No kernel-to-user copy paths (such as netlink, ioctl, or socket options) or uninitialized struct padding are exposed.\n\nThe failure modes touched by this patch series involve buffer boundaries, length calculations, list iteration, and NULL checks—risks such as out-of-bounds reads/writes, pointer invalidation, and assertions that are directly covered by KASAN and net debugging checks. A dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch series refactors skb checksumming and copying functions (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits) to return proper error codes rather than silently returning 0 upon failure or hitting BUG_ONs. It also improves bounds checking and error handling across skb segmentation (skb_segment), coalescing (skb_try_coalesce), and zerocopy logic to handle malformed or truncated skb frag lists gracefully.\n\nRegarding uninitialized memory:\n- All checksum output variables passed by reference across callers (e.g. in dev.c, gro.c, icmp.c, ip_output.c, skbuff.c) are either explicitly initialized (e.g., `__wsum csum = 0;`, `u32 crc = ~0;`) or guarded by `__must_check` return codes that trigger immediate error returns or packet drops prior to any use of the checksum value.\n- In partial failure scenarios within `skb_copy_and_csum_bits`, `skb_copy_and_csum_frag_list`, and `skb_copy_and_csum_dev`, destination buffers are defensively zeroed via `memset` to prevent leaving stale or uninitialized bytes in copied buffers.\n- No kernel-to-user copy paths (such as netlink, ioctl, or socket options) or uninitialized struct padding are exposed.\n\nThe failure modes touched by this patch series involve buffer boundaries, length calculations, list iteration, and NULL checks—risks such as out-of-bounds reads/writes, pointer invalidation, and assertions that are directly covered by KASAN and net debugging checks. A dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|