| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/11/04 01:11 | flow | patch-triage |
24mArgs:null Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"IP_SCTP",
"TLS",
"INET",
"IPV6"
],
"FocusSymbols": [
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_segment",
"skb_try_coalesce",
"skb_checksum_help",
"skb_crc32c_csum_help",
"__skb_gro_checksum_complete",
"skb_zerocopy",
"skb_copy_and_csum_dev"
],
"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 report errors via return codes rather than returning ambiguous 0 checksum values, adds length and bounds checks, and replaces BUG_ON assertions with proper error handling and packet drops.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Analysis: All callers of skb_checksum_full, skb_crc32c_full, and skb_copy_and_csum_bits properly initialize accumulator variables prior to invocation (e.g., initializing `csum = 0` or `crc = ~0`). In skb_copy_and_csum_bits, `csump` is an out-parameter that is populated on success; on error paths, all callers inspect the return value and cleanly abort or drop the packet without reading the checksum. Furthermore, when unreadable fragments or truncated lengths are encountered during copying, destination buffers are explicitly zeroed via memset to prevent handing callers uninitialized or stale data.\n- KASAN / Standard Debuggers: The risks touched by these changes involve bounds verification (clamping length, validating negative offsets/lengths, underflow prevention when skb-\u003edata_len \u003e skb-\u003elen), fragment list iteration, and NULL dereference prevention (such as validating list_skb). Any potential regressions (e.g., out-of-bounds reads/writes or NULL pointer dereferences) are caught by KASAN and standard kernel debug facilities.\n\nSince no uninitialized memory usage, uninitialized branching, or kernel-to-user info-leak risks are introduced or exposed, a dedicated KMSAN fuzzing session is not justified.",
"NeedsKMSAN": false,
"Reasoning": "The patch series alters core skbuff checksum calculation, data copying, GSO segmentation, and buffer coalescing logic (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits, skb_segment, skb_try_coalesce, skb_checksum_help, etc.). It replaces several BUG_ON checks with DEBUG_NET_WARN_ON_ONCE assertions and error propagation. These core networking paths are fully reachable via socket operations, packet injection, and virtual interfaces, making fuzzing worthwhile to uncover potential invariant violations or edge-case handling regressions.",
"WorthFuzzing": true
} |
| 1/1 | 2026/11/04 01:11 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 80798764e5ee7c0367bb836f53d24a9e3076e6b6\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Wed Nov 4 01:11:49 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..7bfafc826b14b2 100644\n--- a/net/core/net_test.c\n+++ b/net/core/net_test.c\n@@ -41,6 +41,12 @@ 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 };\n \n struct gso_test_case {\n@@ -58,11 +64,16 @@ 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 \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 +252,61 @@ 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 };\n \n static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)\n@@ -337,21 +403,47 @@ 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\tskb_shinfo(skb)-\u003egso_size = GSO_BY_FRAGS;\n+\n+\t\tif (tcase-\u003eid == GSO_TEST_FRAG_LIST_NESTED) {\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 \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 +1466,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..bca69e8b35822f 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,11 +5274,13 @@ 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@@ -5085,6 +5304,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 +5400,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 +5639,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 +6511,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 +6557,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 +6565,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 +6573,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/04 01:11 | agent | patch-evaluator |
12mModel:core Args: null Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"IP_SCTP",
"TLS",
"INET",
"IPV6"
],
"FocusSymbols": [
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_segment",
"skb_try_coalesce",
"skb_checksum_help",
"skb_crc32c_csum_help",
"__skb_gro_checksum_complete",
"skb_zerocopy",
"skb_copy_and_csum_dev"
],
"Reasoning": "The patch series alters core skbuff checksum calculation, data copying, GSO segmentation, and buffer coalescing logic (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits, skb_segment, skb_try_coalesce, skb_checksum_help, etc.). It replaces several BUG_ON checks with DEBUG_NET_WARN_ON_ONCE assertions and error propagation. These core networking paths are fully reachable via socket operations, packet injection, and virtual interfaces, making fuzzing worthwhile to uncover potential invariant violations or edge-case handling regressions.",
"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 80798764e5ee7c0367bb836f53d24a9e3076e6b6
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Nov 4 01:11:49 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..7bfafc826b14b2 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -41,6 +41,12 @@ 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,
};
struct gso_test_case {
@@ -58,11 +64,16 @@ 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;
/* 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 +252,61 @@ 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,
+ },
};
static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)
@@ -337,21 +403,47 @@ 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)
skb_shinfo(skb)->gso_size = GSO_BY_FRAGS;
+
+ if (tcase->id == GSO_TEST_FRAG_LIST_NESTED) {
+ 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)
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 +1466,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..bca69e8b35822f 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,11 +5274,13 @@ 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 {
@@ -5085,6 +5304,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 +5400,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 +5639,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 +6511,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 +6557,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 +6565,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 +6573,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/04 01:11 | llm | patch-evaluator |
2mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18875 output: 42 thoughts: 891 Thoughts: **WorthFuzzing Analysis: Network Core Patch** Okay, let's dive into this patch and follow the triage instructions meticulously. First, the architecture is amd64, that's straightforward. Now, the key question: is this worth fuzzing with syzkaller? The triage philosophy is clear. Reachability is paramount. Can the modified code *execute* in standard environments? This isn't some esoteric hardware path, it's touching core networking. We need to be critical of NFCI or refactoring claims. And, critically, new or modified assertions in reachable code *demand* fuzzing. I'll only say "no" if it's non-kernel, unreachable hardware, or genuinely unreachable code paths. Otherwise, it's "yes". We need to find focus symbols and enable necessary configs. Looking at the file list, my expert eye immediately spots the danger zones: `net/core/skbuff.c`, `net/core/dev.c`, `net/core/gro.c`, the IPv4 and IPv6 ICMP and output code, and `net/tls/tls_sw.c`. This is deeply embedded in the network stack, absolutely reachable. And lo and behold, I'm seeing `DEBUG_NET_WARN_ON_ONCE(1)` statements popping up like red flags! That's a huge tell. Beyond that, the code touches are like a symphony of fuzzing opportunities: `skb_checksum_full`, `skb_copy_and_csum_bits` signature changes and error checks, `skb_segment` error handling, and `skb_crc32c_full`, plus changes to `skb_try_coalesce` and several others. Error handling, assertions, and critical network functions. This is a gold mine. The patch seems to implement some new check and also implement a change to the checksums. Therefore, WorthFuzzing = `true`, without a doubt. Now, I need to get into the commit itself and extract the nitty-gritty details. I need to grep for specifics in the code and use the provided tools to locate all the relevant configurations, symbols, and dependencies. I may not have the `git log` tool, but I can inspect the code directly. |
| 4/2 | 2026/11/04 01:14 | tool | grepper |
0mArgs:{
"Expression": "skb_checksum_full",
"PathPrefixes": [
"net/core/",
"include/linux/skbuff.h"
]
}Results: {
"Output": "include/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);\ninclude/linux/skbuff.h:4285:int __must_check skb_checksum_full(const struct sk_buff *skb, int offset,\ninclude/linux/skbuff.h-4286-\t\t\t\t int len, __wsum *csump);\n--\nnet/core/dev.c=3666=int skb_checksum_help(struct sk_buff *skb)\n--\nnet/core/dev.c-3699-\t}\nnet/core/dev.c:3700:\tret = skb_checksum_full(skb, offset, skb-\u003elen - offset, \u0026csum);\nnet/core/dev.c-3701-\tif (ret)\n--\nnet/core/gro.c=799=__sum16 __skb_gro_checksum_complete(struct sk_buff *skb)\n--\nnet/core/gro.c-806-\t */\nnet/core/gro.c:807:\tif (skb_checksum_full(skb, skb_gro_offset(skb), skb_gro_len(skb),\nnet/core/gro.c-808-\t\t\t \u0026wsum)) {\n--\nnet/core/skbuff.c=2819=static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)\n--\nnet/core/skbuff.c-2826-\nnet/core/skbuff.c:2827:\t\tif (!skb_checksum_full(skb, len, delta, \u0026csum)) {\nnet/core/skbuff.c-2828-\t\t\tskb-\u003ecsum = csum_block_sub(skb-\u003ecsum, csum, len);\n--\nnet/core/skbuff.c-2836-\t\tcsum = 0;\nnet/core/skbuff.c:2837:\t\terr = skb_checksum_full(skb, 0, len, \u0026csum);\nnet/core/skbuff.c-2838-\t\tif (err)\n--\nnet/core/skbuff.c=3551=EXPORT_SYMBOL(skb_store_bits);\nnet/core/skbuff.c-3552-\nnet/core/skbuff.c:3553:/* The frag_list part of skb_checksum_full(). It's out of line so that taking\nnet/core/skbuff.c-3554- * the address of csum2 doesn't cost every caller a stack protector.\n--\nnet/core/skbuff.c=3556=static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,\n--\nnet/core/skbuff.c-3574-\t\t\t\tcopy = len;\nnet/core/skbuff.c:3575:\t\t\terr = skb_checksum_full(frag_iter, offset - start, copy,\nnet/core/skbuff.c-3576-\t\t\t\t\t\t\u0026csum2);\n--\nnet/core/skbuff.c-3597-/**\nnet/core/skbuff.c:3598: *\tskb_checksum_full - checksum a range of an skb\nnet/core/skbuff.c-3599- *\t@skb: buffer to checksum\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--\nnet/core/skbuff.c-3674-}\nnet/core/skbuff.c:3675:EXPORT_SYMBOL(skb_checksum_full);\nnet/core/skbuff.c-3676-\nnet/core/skbuff.c-3677-/* skb_checksum() has no way to report failure, so it returns 0, which is a\nnet/core/skbuff.c:3678: * valid checksum. Use skb_checksum_full() in new code.\nnet/core/skbuff.c-3679- */\nnet/core/skbuff.c=3680=__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)\nnet/core/skbuff.c-3681-{\nnet/core/skbuff.c:3682:\tint err = skb_checksum_full(skb, offset, len, \u0026csum);\nnet/core/skbuff.c-3683-\n--\nnet/core/skbuff.c=3974=__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)\n--\nnet/core/skbuff.c-3978-\nnet/core/skbuff.c:3979:\tif (skb_checksum_full(skb, 0, len, \u0026csum))\nnet/core/skbuff.c-3980-\t\treturn skb_checksum_complete_failed(skb);\n--\nnet/core/skbuff.c=4005=__sum16 __skb_checksum_complete(struct sk_buff *skb)\n--\nnet/core/skbuff.c-4009-\nnet/core/skbuff.c:4010:\tif (skb_checksum_full(skb, 0, skb-\u003elen, \u0026csum))\nnet/core/skbuff.c-4011-\t\treturn skb_checksum_complete_failed(skb);\n--\nnet/core/skbuff.c=5052=struct sk_buff *skb_segment(struct sk_buff *head_skb,\n--\nnet/core/skbuff.c-5403-\t\t\tSKB_GSO_CB(nskb)-\u003ecsum = 0;\nnet/core/skbuff.c:5404:\t\t\tif (skb_checksum_full(nskb, doffset,\nnet/core/skbuff.c-5405-\t\t\t\t\t nskb-\u003elen - doffset,\n"
} |
| 5/2 | 2026/11/04 01:14 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21913 output: 30 thoughts: 126 Thoughts: **Analyzing Kconfig Dependencies** Okay, let's break down the Kconfig situation here. I need to understand which configuration flags are influencing the compilation of these specific files and features. So, first things first, I'm going to determine which Kconfig options are directly guarding the parts I'm concerned with. I see that `net/core/skbuff.c` and `net/core/dev.c` are always compiled as long as `CONFIG_NET` is defined. That's straightforward enough. The interesting part is `skb_crc32c_full`, which is conditionally compiled based on `#ifdef CONFIG_NET_CRC32C` within `net/core/skbuff.c`. Now I need to track down the Kconfig definition of `CONFIG_NET_CRC32C` to fully grasp its implications. That's the key to understanding the conditional compilation here. I'll search the Kconfig files for where `CONFIG_NET_CRC32C` is defined and see how it fits in. |
| 6/2 | 2026/11/04 01:15 | 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/04 01:15 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 22354 output: 21 thoughts: 24 Thoughts: Here's my thought process, as requested: **Investigating the NET_CRC32C Dependency** Okay, so I need to figure out the connections around `NET_CRC32C`. I want to understand what's *choosing* it. Is it being directly enabled by a specific configuration option? Or is it a dependency of something larger, another module or setting? Perhaps something's implicitly selecting it based on other configured features. Gotta trace back those dependencies to see the root cause. This could be crucial for optimizing or troubleshooting related network functionality, or understanding why it's present in the build in the first place. Time to dig into the Kconfig files and see where this module fits in. |
| 8/2 | 2026/11/04 01:17 | 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"
} |
| 9/2 | 2026/11/04 01:17 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 23333 output: 33 thoughts: 85 Thoughts: Here's my summary, as I see it: **Digging into Network CRC32C and Debugging Flags** Okay, so I'm seeing that `CONFIG_NET_CRC32C` gets pulled in by a bunch of key network subsystems: `IP_SCTP`, `NF_TABLES`, `OPENVSWITCH`, and the like. That's good to know, confirming its broad applicability. But I need to explore further... I'm also wondering about `DEBUG_NET`. Is that potentially related or something else entirely? I've just spotted `DEBUG_NET_WARN_ON_ONCE` – that catches my eye. Time to dive deeper. I need to understand its definition. Where is it defined in the kernel? What configuration options activate it? Understanding its role and dependencies will allow me to ensure my debugging strategies are optimized. I need the full context. |
| 10/2 | 2026/11/04 01:17 | tool | grepper |
0mArgs:{
"Expression": "DEBUG_NET_WARN_ON_ONCE",
"PathPrefixes": [
"include/"
]
}Results: {
"Output": "include/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--\ninclude/net/netmem.h-184-\ninclude/net/netmem.h:185:\tDEBUG_NET_WARN_ON_ONCE(true);\ninclude/net/netmem.h-186-\treturn NULL;\n--\ninclude/net/netmem.h=220=static inline unsigned long netmem_pfn_trace(netmem_ref netmem)\n--\ninclude/net/netmem.h-240-({\t\t\t\t\t\t\t\t\t\\\ninclude/net/netmem.h:241:\tDEBUG_NET_WARN_ON_ONCE(!page_pool_page_is_pp(p));\t\t\\\ninclude/net/netmem.h-242-\t__pp_page_to_nmdesc(p);\t\t\t\t\t\t\\\n--\ninclude/net/request_sock.h=128=static inline void reqsk_free(struct request_sock *req)\ninclude/net/request_sock.h-129-{\ninclude/net/request_sock.h:130:\tDEBUG_NET_WARN_ON_ONCE(refcount_read(\u0026req-\u003ersk_refcnt) != 0);\ninclude/net/request_sock.h-131-\t__reqsk_free(req);\n--\ninclude/net/sch_generic.h=918=static inline unsigned int qdisc_pkt_segs(const struct sk_buff *skb)\n--\ninclude/net/sch_generic.h-921-\ninclude/net/sch_generic.h:922:\tDEBUG_NET_WARN_ON_ONCE(pkt_segs !=\ninclude/net/sch_generic.h-923-\t\t\t(skb_is_gso(skb) ? skb_shinfo(skb)-\u003egso_segs : 1));\n--\ninclude/net/sch_generic.h=1236=static inline void qdisc_dequeue_drop(struct Qdisc *q, struct sk_buff *skb,\n--\ninclude/net/sch_generic.h-1240-\ninclude/net/sch_generic.h:1241:\tDEBUG_NET_WARN_ON_ONCE(!(q-\u003eflags \u0026 TCQ_F_DEQUEUE_DROPS));\ninclude/net/sch_generic.h:1242:\tDEBUG_NET_WARN_ON_ONCE(q-\u003eflags \u0026 TCQ_F_NOLOCK);\ninclude/net/sch_generic.h-1243-\n--\ninclude/net/sock.h=1825=static inline void sock_release_ownership(struct sock *sk)\ninclude/net/sock.h-1826-{\ninclude/net/sock.h:1827:\tDEBUG_NET_WARN_ON_ONCE(!sock_owned_by_user_nocheck(sk));\ninclude/net/sock.h-1828-\tsk-\u003esk_lock.owned = 0;\n--\ninclude/net/sock.h=2802=static inline int sk_drops_read(const struct sock *sk)\n--\ninclude/net/sock.h-2806-\tif (ndc) {\ninclude/net/sock.h:2807:\t\tDEBUG_NET_WARN_ON_ONCE(atomic_read(\u0026sk-\u003esk_drops));\ninclude/net/sock.h-2808-\t\treturn numa_drop_read(ndc);\n--\ninclude/net/tcp.h=831=static inline void tcp_add_receive_queue(struct sock *sk, struct sk_buff *skb)\ninclude/net/tcp.h-832-{\ninclude/net/tcp.h:833:\tDEBUG_NET_WARN_ON_ONCE(skb_dst(skb));\ninclude/net/tcp.h:834:\tDEBUG_NET_WARN_ON_ONCE(secpath_exists(skb));\ninclude/net/tcp.h-835-\t__skb_queue_tail(\u0026sk-\u003esk_receive_queue, skb);\n"
} |
| 11/2 | 2026/11/04 01:17 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27992 output: 27 thoughts: 38 Thoughts: Here's my thought process, as requested: **Debugging the Network Stack: A Quick Deduction** Alright, so `CONFIG_DEBUG_NET` is flipped on. That *immediately* tells me we've also enabled `DEBUG_NET_WARN_ON_ONCE`. Now, given my experience with the kernel, I know that one often depends on the other. But it's always wise to double-check these assumptions. I should really confirm the exact Kconfig definition to ensure there aren't any hidden implications or dependencies I'm missing. Time to dive into the `Kconfig` files and make sure I'm not overlooking anything related to those two configs. This will help inform any next steps I might take to debug whatever issue brought these configs to my attention. |
| 12/2 | 2026/11/04 01:19 | tool | grepper |
0mArgs:{
"Expression": "config DEBUG_NET",
"PathPrefixes": [
"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"
} |
| 13/2 | 2026/11/04 01:19 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28358 output: 33 thoughts: 12 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into Debugging Configuration** Alright, so the first thing on the agenda is a deep dive into the debugging configuration, specifically within `net/Kconfig.debug`. Given the nature of this project, my instinct is to start there. It's the logical starting point to examine the available debugging options, and how they relate to the network subsystems. The `Kconfig` files are the blueprints. I need to understand what knobs we can tweak, what level of verbosity we can enable, and any relevant trade-offs they might involve. Knowing which debug features are baked-in, disabled by default, or available as compile-time options is critical to formulating an effective debugging strategy. I anticipate this file will give insight into logging levels, tracepoints, debugging macros, and perhaps some instrumentation for capturing network events. Knowing the scope and the features I am able to configure will make my work much easier later on. |
| 14/2 | 2026/11/04 01:20 | tool | read-file |
0mArgs:{
"File": "net/Kconfig.debug",
"FirstLine": 15,
"LineCount": 20
}Results: {
"Contents": " 15:\t\tselect REF_TRACKER\n 16:\t\tdefault n\n 17:\t\thelp\n 18:\t\t Enable debugging feature to track netns references.\n 19:\t\t This adds memory and cpu costs.\n 20:\t\n 21:\tconfig DEBUG_NET\n 22:\t\tbool \"Add generic networking debug\"\n 23:\t\tdepends on DEBUG_KERNEL \u0026\u0026 NET\n 24:\t\thelp\n 25:\t\t Enable extra sanity checks in networking.\n 26:\t\t This is mostly used by fuzzers, but is safe to select.\n 27:\t\n 28:\tconfig DEBUG_NET_SMALL_RTNL\n 29:\t\tbool \"Add extra per-netns mutex inside RTNL\"\n 30:\t\tdepends on DEBUG_KERNEL \u0026\u0026 NET \u0026\u0026 LOCK_DEBUGGING_SUPPORT\n 31:\t\tselect PROVE_LOCKING\n 32:\t\tdefault n\n 33:\t\thelp\n 34:\t\t rtnl_lock() is being replaced with rtnl_net_lock() that\n"
} |
| 15/2 | 2026/11/04 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28872 output: 34 thoughts: 3617 Thoughts: **Analysis of a Network Stack Patch for Fuzzing Focus** Okay, so I've got this patch in front of me, and my initial thought is, "This looks like it could be a goldmine for fuzzing!" The presence of `CONFIG_DEBUG_NET` is the first clue. The documentation is clear: these sanity checks are for fuzzers. That means the developers *want* this to be fuzzed. The new `DEBUG_NET_WARN_ON_ONCE` additions scream, "Trigger me!". The changes span quite a few network subsystems: IPv4, IPv6, TLS, and even CRC32C checksumming, and now `SUNVNET`, `XEN_NETDEV_FRONTEND`, and `SUNRPC` have all shown up as possibly relevant. My first instinct is to pore over the git diff very carefully. The focus seems to be around improvements and safety net additions for SKB (Socket Buffer) operations, especially checksumming, copying, and segmentation. Key functions are being touched, and critical checks are being added or refined. Functions like `skb_copy_and_csum_bits`, `skb_checksum_full`, `skb_crc32c_full`, `skb_segment`, and `skb_try_coalesce` have caught my attention. It looks like they have all been modified with improved error handling, including return codes and added checks. These are core operations. It is the sort of thing that gets called quite often. This patch aims to prevent or detect certain corner cases related to offload checksumming, and errors during fragment processing, or buffer copies. It also seems to have fixed or improved a lot of error returns. The next critical step is defining the scope of this for fuzzing. I need to avoid the "ubiquitous lifecycle hot-paths" trap. Functions like memory allocators are called everywhere, but don't focus the fuzzer. I need to identify the specific feature-specific logic. Here is where the diff shines. The primary focus is on these SKB functions: `skb_checksum_full`, `skb_copy_and_csum_bits`, `skb_crc32c_full`. Their new prototypes are quite interesting. Then we have `skb_segment` which is the GSO function. `skb_try_coalesce` which handles packet coalescing. `skb_checksum_help` and `skb_crc32c_csum_help` are called from `net/core/dev.c`. I have to also keep in mind `__skb_gro_checksum_complete` that calls `skb_checksum_full`. I'm thinking about the call chains. `skb_copy_and_csum_bits` is used by a few different drivers and subsystems. `skb_segment` is obviously a GSO entrypoint, so it gets special emphasis. `skb_try_coalesce` is probably triggered during GRO or packet reassembly in TCP or elsewhere. These are important. The functions in `net/core/dev.c` are probably offload fallback. `DEBUG_NET_WARN_ON_ONCE` is key. Any function with that should be prioritized. What could trigger it? Malformed packets, packets with incorrect lengths, edge cases in checksumming or fragmentation or GSO/GRO. So, in summary: This patch is definitely WorthFuzzing. It is adding specific, testable error-handling logic around core network SKB operations, making the network stack more robust. The focus will be on the added checks and their triggering conditions! |
| 16/2 | 2026/11/04 01:20 | tool | grepper |
0mArgs:{
"Expression": "pskb_trim_rcsum_complete",
"PathPrefixes": [
"net/core/"
]
}Results: {
"Output": "net/core/skbuff.c=2817=EXPORT_SYMBOL(___pskb_trim);\nnet/core/skbuff.c-2818-\nnet/core/skbuff.c:2819:static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)\nnet/core/skbuff.c-2820-{\n--\nnet/core/skbuff.c=2856=int pskb_trim_rcsum_slow(struct sk_buff *skb, unsigned int len)\n--\nnet/core/skbuff.c-2860-\nnet/core/skbuff.c:2861:\t\terr = pskb_trim_rcsum_complete(skb, len);\nnet/core/skbuff.c-2862-\t\tif (err)\n"
} |
| 17/2 | 2026/11/04 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 33541 output: 30 thoughts: 48 Thoughts: Okay, here's my interpretation of that thought process, assuming I'm deep in the weeds of network stack debugging: **Digging into the RCsum Trim Functions** Right, so `pskb_trim_rcsum_slow` is calling `pskb_trim_rcsum_complete`. Hmm, interesting. That tells me the slow path for RCsum trimming is offloading to a completion function. I need to understand how this relationship works. I'm seeing a possible area where the checksum calculation is being handled. I know I saw a problem related to this in the past with TLS, so let's start by looking at `__skb_nsg` in `net/tls/tls_sw.c`. I need to see how the software TLS offload mechanisms interact with the checksum calculations. It's a key piece of the puzzle, and a good place to start my investigation. This area is very performance critical, and I want to rule out issues here as quickly as possible. |
| 18/2 | 2026/11/04 01:20 | tool | grepper |
0mArgs:{
"Expression": "skb_nsg",
"PathPrefixes": [
"net/tls/"
]
}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"
} |
| 19/2 | 2026/11/04 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34278 output: 21 thoughts: 64 Thoughts: Here's my thought process, as requested: **Deconstructing the TLS Decryption Path** Okay, so I'm looking at `tls_decrypt_sg` and immediately that `skb_nsg` call pops out. That's usually the sign of some data manipulation within a network socket buffer (`skb`). I need to understand the data flow, and the most logical next step is to figure out what function calls `tls_decrypt_sg`. A quick code dive, or even just `grep`, should point me to `tls_sw_recvmsg`. Now, the connection between `tls_decrypt_sg` and `tls_sw_recvmsg` is established. Given that connection, I want to understand more. Given that `tls_decrypt_sg` manipulates the buffer, I want to see the details of where this manipulation may occur, and how. That makes me think to look at `skb_zerocopy`. Where is that function invoked? That should shed some light on the overall zero-copy behavior of this TLS decryption process. Knowing this, I should be able to get a better handle on the potential bottlenecks and performance characteristics. |
| 20/2 | 2026/11/04 01:20 | tool | grepper |
0mArgs:{
"Expression": "skb_zerocopy\\("
}Results: {
"Output": "include/linux/skbuff.h=4296=unsigned int skb_zerocopy_headlen(const struct sk_buff *from);\ninclude/linux/skbuff.h:4297:int skb_zerocopy(struct sk_buff *to, struct sk_buff *from,\ninclude/linux/skbuff.h-4298-\t\t int len, int hlen);\n--\nnet/core/net_test.c=672=static void netmem_ref_test_pp_page(struct kunit *test)\n--\nnet/core/net_test.c-760-\tskb-\u003ehead_frag = 1;\nnet/core/net_test.c:761:\tKUNIT_ASSERT_EQ(test, skb_zerocopy(copy, skb, skb-\u003elen, 0), 0);\nnet/core/net_test.c-762-\tskb-\u003ehead_frag = 0;\n--\nnet/core/net_test.c-910-\tskb_put(copy, skb_tailroom(copy));\nnet/core/net_test.c:911:\tKUNIT_ASSERT_EQ(test, skb_zerocopy(copy, skb, skb-\u003elen, 0), 0);\nnet/core/net_test.c-912-\tKUNIT_EXPECT_TRUE(test, copy-\u003epp_recycle);\n--\nnet/core/net_test.c=933=static void netmem_ref_test_net_iov(struct kunit *test)\n--\nnet/core/net_test.c-1028-\tskb-\u003eunreadable = 1;\nnet/core/net_test.c:1029:\tKUNIT_ASSERT_EQ(test, skb_zerocopy(copy, skb, skb-\u003elen, 0), 0);\nnet/core/net_test.c-1030-\tskb-\u003ehead_frag = 0;\n--\nnet/core/net_test.c=1269=static void netmem_ref_test_skb_segment(struct kunit *test)\n--\nnet/core/net_test.c-1525-\tskb_put(seg, skb_tailroom(seg));\nnet/core/net_test.c:1526:\tKUNIT_EXPECT_EQ(test, skb_zerocopy(seg, head, head-\u003elen, 0), -EFAULT);\nnet/core/net_test.c-1527-\tKUNIT_EXPECT_EQ(test, atomic_long_read(\u0026pp_page-\u003epp_ref_count),\n--\nnet/core/net_test.c-1549-\tskb_put(seg, skb_tailroom(seg));\nnet/core/net_test.c:1550:\tKUNIT_EXPECT_EQ(test, skb_zerocopy(seg, head, head-\u003elen, 0), -ENOMEM);\nnet/core/net_test.c-1551-\tKUNIT_EXPECT_EQ(test, atomic_long_read(\u0026pp_page-\u003epp_ref_count),\n--\nnet/core/skbuff.c=4037=EXPORT_SYMBOL(__skb_checksum_complete);\n--\nnet/core/skbuff.c-4039- /**\nnet/core/skbuff.c:4040: *\tskb_zerocopy_headlen - Calculate headroom needed for skb_zerocopy()\nnet/core/skbuff.c-4041- *\t@from: source buffer\n--\nnet/core/skbuff.c-4043- *\tCalculates the amount of linear headroom needed in the 'to' skb passed\nnet/core/skbuff.c:4044: *\tinto skb_zerocopy().\nnet/core/skbuff.c-4045- */\n--\nnet/core/skbuff.c=4087=int\nnet/core/skbuff.c:4088:skb_zerocopy(struct sk_buff *to, struct sk_buff *from, int len, int hlen)\nnet/core/skbuff.c-4089-{\n--\nnet/netfilter/nfnetlink_queue.c=719=nfqnl_build_packet_message(struct net *net, struct nfqnl_instance *queue,\n--\nnet/netfilter/nfnetlink_queue.c-967-\nnet/netfilter/nfnetlink_queue.c:968:\t\tif (skb_zerocopy(skb, entskb, data_len, hlen))\nnet/netfilter/nfnetlink_queue.c-969-\t\t\tgoto nla_put_failure;\n--\nnet/openvswitch/datapath.c=452=static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,\n--\nnet/openvswitch/datapath.c-588-\t/* Only reserve room for attribute header, packet data is added\nnet/openvswitch/datapath.c:589:\t * in skb_zerocopy() */\nnet/openvswitch/datapath.c-590-\tif (!(nla = nla_reserve(user_skb, OVS_PACKET_ATTR_PACKET, 0))) {\n--\nnet/openvswitch/datapath.c-595-\nnet/openvswitch/datapath.c:596:\terr = skb_zerocopy(user_skb, skb, skb_len, hlen);\nnet/openvswitch/datapath.c-597-\tif (err)\n--\nnet/xdp/xsk.c=988=static int xsk_skb_metadata(struct sk_buff *skb, void *buffer,\n--\nnet/xdp/xsk.c-1032-\nnet/xdp/xsk.c:1033:static struct sk_buff *xsk_build_skb_zerocopy(struct xdp_sock *xs,\nnet/xdp/xsk.c-1034-\t\t\t\t\t struct xdp_desc *desc)\n--\nnet/xdp/xsk.c=1109=static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,\n--\nnet/xdp/xsk.c-1116-\tif (dev-\u003epriv_flags \u0026 IFF_TX_SKB_NO_LINEAR) {\nnet/xdp/xsk.c:1117:\t\tskb = xsk_build_skb_zerocopy(xs, desc);\nnet/xdp/xsk.c-1118-\t\tif (IS_ERR(skb)) {\n"
} |
| 21/2 | 2026/11/04 01:20 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 36277 output: 25 thoughts: 60 Thoughts: **Investigating the Data Flow of Network Packets** Okay, so I'm looking into how network packets are handled, specifically focusing on how they're passed to userspace. I've noticed that `skb_zerocopy` is involved, and I see it's called by `nfqnl_build_packet_message` and within Open vSwitch's `queue_userspace_packet` function. This suggests a zero-copy mechanism is employed at some point. Now, to get a clearer understanding of the complete path and any potential performance bottlenecks, I need to trace the data flow further. My next step is to examine calls to `skb_copy_and_csum_dev`. I want to identify where *that* function is being called, as this is related to checksumming and copying and I know this process could be critical in terms of efficiency. Understanding the call chain involving these functions should give me a more complete picture. |
| 22/2 | 2026/11/04 01:21 | tool | grepper |
0mArgs:{
"Expression": "skb_copy_and_csum_dev"
}Results: {
"Output": "drivers/net/ethernet/cirrus/ep93xx_eth.c=329=static netdev_tx_t ep93xx_xmit(struct sk_buff *skb, struct net_device *dev)\n--\ndrivers/net/ethernet/cirrus/ep93xx_eth.c-348-\t\t\t\tDMA_TO_DEVICE);\ndrivers/net/ethernet/cirrus/ep93xx_eth.c:349:\tskb_copy_and_csum_dev(skb, ep-\u003etx_buf[entry]);\ndrivers/net/ethernet/cirrus/ep93xx_eth.c-350-\tdma_sync_single_for_device(dev-\u003edev.parent, txd-\u003ebuf_addr, skb-\u003elen,\n--\ndrivers/net/ethernet/ec_bhf.c=282=static netdev_tx_t ec_bhf_start_xmit(struct sk_buff *skb,\n--\ndrivers/net/ethernet/ec_bhf.c-290-\ndrivers/net/ethernet/ec_bhf.c:291:\tskb_copy_and_csum_dev(skb, desc-\u003edata);\ndrivers/net/ethernet/ec_bhf.c-292-\tlen = skb-\u003elen;\n--\ndrivers/net/ethernet/micrel/ksz884x.c=4453=static netdev_tx_t netdev_tx(struct sk_buff *skb, struct net_device *dev)\n--\ndrivers/net/ethernet/micrel/ksz884x.c-4496-\t\t\t}\ndrivers/net/ethernet/micrel/ksz884x.c:4497:\t\t\tskb_copy_and_csum_dev(org_skb, skb-\u003edata);\ndrivers/net/ethernet/micrel/ksz884x.c-4498-\t\t\torg_skb-\u003eip_summed = CHECKSUM_NONE;\n--\ndrivers/net/ethernet/realtek/8139too.c=938=static int rtl8139_init_one(struct pci_dev *pdev,\n--\ndrivers/net/ethernet/realtek/8139too.c-991-\t/* note: the hardware is not capable of sg/csum/highdma, however\ndrivers/net/ethernet/realtek/8139too.c:992:\t * through the use of skb_copy_and_csum_dev we enable these\ndrivers/net/ethernet/realtek/8139too.c-993-\t * features\n--\ndrivers/net/ethernet/realtek/8139too.c=1701=static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,\n--\ndrivers/net/ethernet/realtek/8139too.c-1716-\t\t\tmemset(tp-\u003etx_buf[entry], 0, ETH_ZLEN);\ndrivers/net/ethernet/realtek/8139too.c:1717:\t\tskb_copy_and_csum_dev(skb, tp-\u003etx_buf[entry]);\ndrivers/net/ethernet/realtek/8139too.c-1718-\t\tdev_kfree_skb_any(skb);\n--\ndrivers/net/ethernet/silan/sc92031.c=932=static netdev_tx_t sc92031_start_xmit(struct sk_buff *skb,\n--\ndrivers/net/ethernet/silan/sc92031.c-956-\ndrivers/net/ethernet/silan/sc92031.c:957:\tskb_copy_and_csum_dev(skb, priv-\u003etx_bufs + entry * TX_BUF_SIZE);\ndrivers/net/ethernet/silan/sc92031.c-958-\n--\ndrivers/net/ethernet/silan/sc92031.c=1397=static int sc92031_probe(struct pci_dev *pdev, const struct pci_device_id *id)\n--\ndrivers/net/ethernet/silan/sc92031.c-1438-\ndrivers/net/ethernet/silan/sc92031.c:1439:\t/* faked with skb_copy_and_csum_dev */\ndrivers/net/ethernet/silan/sc92031.c-1440-\tdev-\u003efeatures = NETIF_F_SG | NETIF_F_HIGHDMA |\n--\ndrivers/net/ethernet/via/via-rhine.c=1775=static netdev_tx_t rhine_start_tx(struct sk_buff *skb,\n--\ndrivers/net/ethernet/via/via-rhine.c-1805-\t\t/* Padding is not copied and so must be redone. */\ndrivers/net/ethernet/via/via-rhine.c:1806:\t\tskb_copy_and_csum_dev(skb, rp-\u003etx_buf[entry]);\ndrivers/net/ethernet/via/via-rhine.c-1807-\t\tif (skb-\u003elen \u003c ETH_ZLEN)\n--\ninclude/linux/skbuff.h=4294=int skb_send_sock(struct sock *sk, struct sk_buff *skb, int offset, int len);\ninclude/linux/skbuff.h:4295:void skb_copy_and_csum_dev(const struct sk_buff *skb, u8 *to);\ninclude/linux/skbuff.h-4296-unsigned int skb_zerocopy_headlen(const struct sk_buff *from);\n--\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)\nnet/core/skbuff.c-4171-{\n--\nnet/core/skbuff.c-4220-}\nnet/core/skbuff.c:4221:EXPORT_SYMBOL(skb_copy_and_csum_dev);\nnet/core/skbuff.c-4222-\n"
} |
| 23/2 | 2026/11/04 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 38192 output: 19 thoughts: 23 Thoughts: Here's my thought process, as requested: **Investigating the `skb_segment` Function** Okay, time to dig into `skb_segment`. I need to figure out how this function is being used within the kernel. My first step is to identify all the places where `skb_segment` is actually *called*. That's where I need to start. From there, I can begin to understand the purpose of this call and how it fits into the broader picture. |
| 24/2 | 2026/11/04 01:21 | 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=52=struct gso_test_case {\n--\nnet/core/net_test.c-74-\nnet/core/net_test.c:75:\t/* skb_segment() is expected to fail with this error */\nnet/core/net_test.c-76-\tint err;\n--\nnet/core/net_test.c=319=static void gso_test_func(struct kunit *test)\n--\nnet/core/net_test.c-427-\t/* TODO: this should also work with SG, rather than fail the\nnet/core/net_test.c:428:\t * i \u003e= nfrags check in skb_segment()\nnet/core/net_test.c-429-\t */\n--\nnet/core/net_test.c-438-\t\tkunit_warning_suppress(test) {\nnet/core/net_test.c:439:\t\t\tsegs = skb_segment(skb, features);\nnet/core/net_test.c-440-\t\t}\n--\nnet/core/net_test.c-446-\nnet/core/net_test.c:447:\tsegs = skb_segment(skb, features);\nnet/core/net_test.c-448-\tif (IS_ERR(segs)) {\n--\nnet/core/net_test.c=672=static void netmem_ref_test_pp_page(struct kunit *test)\n--\nnet/core/net_test.c-826-\tskb_shinfo(skb)-\u003egso_size = 16;\nnet/core/net_test.c:827:\tsplit = skb_segment(skb, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-828-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(split));\n--\nnet/core/net_test.c=1082=static void netmem_ref_test_release_data(struct kunit *test)\n--\nnet/core/net_test.c-1268-\nnet/core/net_test.c:1269:static void netmem_ref_test_skb_segment(struct kunit *test)\nnet/core/net_test.c-1270-{\n--\nnet/core/net_test.c-1323-\nnet/core/net_test.c:1324:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1325-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1362-\nnet/core/net_test.c:1363:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1364-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1405-\nnet/core/net_test.c:1406:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1407-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1449-\nnet/core/net_test.c:1450:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1451-\tKUNIT_ASSERT_FALSE(test, IS_ERR_OR_NULL(segs));\n--\nnet/core/net_test.c-1495-\nnet/core/net_test.c:1496:\tsegs = skb_segment(head, NETIF_F_SG | NETIF_F_HW_CSUM);\nnet/core/net_test.c-1497-\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"
} |
| 25/2 | 2026/11/04 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40810 output: 18 thoughts: 541 Thoughts: **Analyzing GSO Segmentation in Network Stack** Okay, so I'm digging into `skb_segment`, which, of course, is the heart of Generic Segmentation Offload (GSO) for TCP, UDP, and SCTP offload. I'm focusing on a couple of spots where things seem...interesting. First, within `skb_segment`, there's this `gso_by_frags` path. I see a check for `list_skb` within an `unlikely` block. If `list_skb` is NULL, it looks like there's a debug warning and an error return (`-EINVAL`). I need to understand when and why `list_skb` *wouldn't* be valid in this context. It's definitely worth investigating the conditions that lead to that specific warning, especially in terms of memory or state management during segmentation. Then, there's a loop processing fragments, and again, another check for `list_skb` inside another `unlikely` block. The same debug warning and error return are present. This suggests some fundamental assumption about the structure of the data during segmentation might be failing. Perhaps an edge case or a race condition where some part of the data isn't properly initialized? I'll need to trace the code flow, especially when handling frag lists, to see where things might be going wrong. The second part I'm looking at involves the checksum calculations. Previously, the code was directly assigning the checksum. Now, there are calls to `skb_copy_and_csum_bits` and `skb_checksum_full` with checks for error returns (`-EFAULT`). These new implementations seem to be more robust, potentially to protect against memory issues during the checksum computation. I need to understand if these new calls are a bug fix, part of a refactor, or an optimisation of sorts and what specific conditions trigger these error returns. Are they related to potential memory corruption or checksum calculation errors, or something else entirely? Finally, I'm going to branch out to `sunvnet_common.c` and `xen-netfront.c` to see if there are architecture or hardware-specific interactions that might be relevant here. I'm thinking I'll start by checking the Kconfig to see how `sunvnet` is configured and enabled in the build. Perhaps something related to these drivers is interacting with the segmentation code in a way that's triggering these checks. Understanding the hardware or driver context is always crucial when debugging network performance issues! |
| 26/2 | 2026/11/04 01:21 | tool | grepper |
0mArgs:{
"Expression": "config SUNVNET"
}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"
} |
| 27/2 | 2026/11/04 01:21 | llm | patch-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42075 output: 38 thoughts: 26 Thoughts: Here's a summary of my thought process, as requested: **Kconfig Dive** Okay, let's zero in on a potential area. My instinct tells me the issue might be lurking in the `drivers/net/ethernet/sun/Kconfig` file. I'm specifically interested in the region around lines 70 to 85. That section's probably where the relevant hardware or configuration options for this sun ethernet driver are defined. I need to see what's conditional, what's enabled by default, and how the various features are linked together to see if anything jumps out. That's my starting point, anyway; let's see what's there. |
| 28/2 | 2026/11/04 01:21 | 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"
} |
| 29/2 | 2026/11/04 01:21 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 42652 output: 27 thoughts: 809 Thoughts: **Analyzing the Patch's Dependencies** Okay, so this patch seems to touch a wide array of networking code, even beyond the SPARC-specific bits in `SUN_LDOMS`. I need to figure out the dependencies to ensure the relevant code compiles and functions correctly. Let's break this down. First, I need to check `xen-netfront.c`. That's for the Xen virtual network frontend, nothing too crazy there. Then, let's see what `net/tls/tls_sw.c` requires - Ah, `CONFIG_TLS` is needed, that's straightforward. Moving on to `net/core/skbuff.c`, it depends on `CONFIG_NET`, which is pretty fundamental for network functionality. Now, `DEBUG_NET_WARN_ON_ONCE` caught my eye. That requires `CONFIG_DEBUG_NET`. I should check that. Okay, now for the tricky one: `NET_CRC32C`. The code uses `skb_crc32c_full`, which is only compiled if `CONFIG_NET_CRC32C` is enabled. Let's see what config options enable that. It looks like `IP_SCTP`, `NF_TABLES`, `OPENVSWITCH`, and others select it. Wait a second. Can I directly enable `NET_CRC32C` in the `.config`? Let me check `net/Kconfig`. Ah, it's a bool, and it doesn't have a prompt. That means a user can't explicitly set it, unless it's selected by another configuration item. It's set by a config that depends on it. So, the Syzkaller config generator *could* select it if a config that selects it is enabled, like `IP_SCTP` or `NF_TABLES`. This is where it gets interesting. Can I specify `NET_CRC32C` directly in the `EnableConfigs` list, or should I just use `IP_SCTP` (or `NF_TABLES`)? Section 5 emphasizes inspecting the `Kconfig` files and `ifdef` guards, not making assumptions, and stripping the `CONFIG_` prefix. Since `NET_CRC32C` has no prompt, providing `IP_SCTP` (or `NF_TABLES`) *and/or* `NET_CRC32C` directly would ensure it's enabled. I should look at `net/Kconfig` again to make sure of this. Yep, `IP_SCTP` selects `NET_CRC32C`. So, now I know which configs enable `CONFIG_NET_CRC32C`. These include `IP_SCTP`, `NF_TABLES`, `OPENVSWITCH`, `RDMA_SIW`, `NVME_TCP`, `BATMAN_ADV_BLA`, etc. What about `CONFIG_DEBUG_NET`? I need to check that as well. Ah, `DEBUG_NET` depends on `DEBUG_KERNEL && NET`. And `DEBUG_NET` *does* have a prompt, so that one is straightforward to enable. Finally, what about `CONFIG_TLS`? Let's check `net/tls/Kconfig`. |
| 30/2 | 2026/11/04 01:23 | tool | grepper |
0mArgs:{
"Expression": "config TLS",
"PathPrefixes": [
"net/tls/"
]
}Results: {
"Output": "net/tls/Kconfig-4-#\nnet/tls/Kconfig:5:config TLS\nnet/tls/Kconfig-6-\ttristate \"Transport Layer Security support\"\n--\nnet/tls/Kconfig-18-\nnet/tls/Kconfig:19:config TLS_DEVICE\nnet/tls/Kconfig-20-\tbool \"Transport Layer Security HW offload\"\n"
} |
| 31/2 | 2026/11/04 01:23 | llm | patch-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 44294 output: 312 thoughts: 3089 Thoughts: **Fuzzing Configuration for Core Networking Changes** Okay, so the `CONFIG_TLS` option enables `net/tls/tls_sw.c`, and we'll need `CONFIG_INET` for `net/ipv4/` and `CONFIG_IPV6` for `net/ipv6/` as well. Crucially, we need `CONFIG_DEBUG_NET` to activate the `DEBUG_NET_WARN_ON_ONCE` checks. I see a `WARN_ON_ONCE` in `skb_try_coalesce` that is already enabled. But a bunch of other functions (`skb_checksum_frag_list`, `skb_checksum_full`, etc. ) are peppered with `DEBUG_NET_WARN_ON_ONCE` calls; these warnings are super important to catch any regressions or invariant violations during fuzzing! Now, according to the focus symbol guidelines, we need to pick functions that are feature specific and not generic. So we need to consider some FocusSymbols. `skb_checksum_full` looks like a prime target because it's new, it contains new validation logic and it's called by the modified checksum code. `skb_checksum_frag_list` is static, so it should not be targeted. Then, `skb_copy_and_csum_bits` is good because it's been updated. `skb_crc32c_full` is another new function, and `skb_segment` is core GSO logic where new checks were added. I also see `skb_try_coalesce` was modified, as well as `skb_checksum_help`, `skb_crc32c_csum_help`, `__skb_gro_checksum_complete`, `skb_zerocopy`, and `skb_copy_and_csum_dev`. All are exported and were modified with checksum-related changes and error handling. Are any of these too ubiquitous? No, because these functions are not called by everything. They only exist in specific paths in networking code. So, the focus symbols are: - `skb_checksum_full` - `skb_copy_and_csum_bits` - `skb_crc32c_full` - `skb_segment` - `skb_try_coalesce` - `skb_checksum_help` - `skb_crc32c_csum_help` - `__skb_gro_checksum_complete` - `skb_zerocopy` - `skb_copy_and_csum_dev` The essential configurations are: - `DEBUG_NET` (essential for enabling the debugging warnings) - `NET_CRC32C` - `IP_SCTP` - `TLS` - `INET` - `IPV6` I've made sure to disregard any unrelated configs. The changes involve substantial modifications to core `skb` routines (checksumming, copying, slicing, and coalescing). The new `DEBUG_NET_WARN_ON_ONCE` assertions and error handling make fuzzing particularly valuable for discovering invalid `skb` geometries, regressions, or previously unreachable warning paths. Time to call `set-results`. |
| 32/2 | 2026/11/04 01:24 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"IP_SCTP",
"TLS",
"INET",
"IPV6"
],
"FocusSymbols": [
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_segment",
"skb_try_coalesce",
"skb_checksum_help",
"skb_crc32c_csum_help",
"__skb_gro_checksum_complete",
"skb_zerocopy",
"skb_copy_and_csum_dev"
],
"Reasoning": "The patch series alters core skbuff checksum calculation, data copying, GSO segmentation, and buffer coalescing logic (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits, skb_segment, skb_try_coalesce, skb_checksum_help, etc.). It replaces several BUG_ON checks with DEBUG_NET_WARN_ON_ONCE assertions and error propagation. These core networking paths are fully reachable via socket operations, packet injection, and virtual interfaces, making fuzzing worthwhile to uncover potential invariant violations or edge-case handling regressions.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"DEBUG_NET",
"NET_CRC32C",
"IP_SCTP",
"TLS",
"INET",
"IPV6"
],
"FocusSymbols": [
"skb_checksum_full",
"skb_copy_and_csum_bits",
"skb_crc32c_full",
"skb_segment",
"skb_try_coalesce",
"skb_checksum_help",
"skb_crc32c_csum_help",
"__skb_gro_checksum_complete",
"skb_zerocopy",
"skb_copy_and_csum_dev"
],
"Reasoning": "The patch series alters core skbuff checksum calculation, data copying, GSO segmentation, and buffer coalescing logic (introducing skb_checksum_full, skb_crc32c_full, and updating skb_copy_and_csum_bits, skb_segment, skb_try_coalesce, skb_checksum_help, etc.). It replaces several BUG_ON checks with DEBUG_NET_WARN_ON_ONCE assertions and error propagation. These core networking paths are fully reachable via socket operations, packet injection, and virtual interfaces, making fuzzing worthwhile to uncover potential invariant violations or edge-case handling regressions.",
"WorthFuzzing": true
} |
| 33/1 | 2026/11/04 01:24 | action | If |
11mArgs:{
"WorthFuzzing": true
}Results: null |
| 34/2 | 2026/11/04 01:24 | agent | kmsan-evaluator |
11mModel: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 report errors via return codes rather than returning ambiguous 0 checksum values, adds length and bounds checks, and replaces BUG_ON assertions with proper error handling and packet drops.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Analysis: All callers of skb_checksum_full, skb_crc32c_full, and skb_copy_and_csum_bits properly initialize accumulator variables prior to invocation (e.g., initializing `csum = 0` or `crc = ~0`). In skb_copy_and_csum_bits, `csump` is an out-parameter that is populated on success; on error paths, all callers inspect the return value and cleanly abort or drop the packet without reading the checksum. Furthermore, when unreadable fragments or truncated lengths are encountered during copying, destination buffers are explicitly zeroed via memset to prevent handing callers uninitialized or stale data.\n- KASAN / Standard Debuggers: The risks touched by these changes involve bounds verification (clamping length, validating negative offsets/lengths, underflow prevention when skb-\u003edata_len \u003e skb-\u003elen), fragment list iteration, and NULL dereference prevention (such as validating list_skb). Any potential regressions (e.g., out-of-bounds reads/writes or NULL pointer dereferences) are caught by KASAN and standard kernel debug facilities.\n\nSince no uninitialized memory usage, uninitialized branching, or kernel-to-user info-leak risks are introduced or exposed, 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 80798764e5ee7c0367bb836f53d24a9e3076e6b6
Author: syz-cluster <triage@syzkaller.com>
Date: Wed Nov 4 01:11:49 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..7bfafc826b14b2 100644
--- a/net/core/net_test.c
+++ b/net/core/net_test.c
@@ -41,6 +41,12 @@ 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,
};
struct gso_test_case {
@@ -58,11 +64,16 @@ 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;
/* 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 +252,61 @@ 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,
+ },
};
static void gso_test_case_to_desc(struct gso_test_case *t, char *desc)
@@ -337,21 +403,47 @@ 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)
skb_shinfo(skb)->gso_size = GSO_BY_FRAGS;
+
+ if (tcase->id == GSO_TEST_FRAG_LIST_NESTED) {
+ 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)
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 +1466,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..bca69e8b35822f 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,11 +5274,13 @@ 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 {
@@ -5085,6 +5304,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 +5400,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 +5639,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 +6511,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 +6557,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 +6565,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 +6573,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)
{
|
| 35/3 | 2026/11/04 01:24 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 18087 output: 44 thoughts: 1338 Thoughts: **KMSAN Evaluation: Patch Series Analysis** Alright, let's break this down. The task is to determine if this Linux kernel patch series warrants a dedicated KMSAN fuzzing session. The guidelines are clear: KMSAN is for uninitialized memory reads and kernel-to-user info leaks; KASAN, LOCKDEP, and other bug detectors handle the usual suspects. If a bug can be caught by standard detectors, KMSAN is a no-go – it's resource-intensive. We set `NeedsKMSAN=true` only if the changes introduce or expose *specifically* uninitialized memory risks. So, let's scrutinize this patch. It's touching a wide range of network code: `drivers/net/ethernet/sun/sunvnet_common.c`, `drivers/net/xen-netfront.c`, `include/linux/skbuff.h`, plus a bunch of core networking files like `dev.c`, `filter.c`, `gro.c`, `skbuff.c`, `icmp.c`, `ip_output.c`, `ipv6/icmp.c`, `ipv6/ip6_output.c`, `sunrpc/socklib.c`, and `tls/tls_sw.c`. This suggests a potential area of concern due to the broad scope of changes. The core of the patch revolves around modifications to checksum and copy/checksum functions within the `skbuff` framework: `skb_checksum`, `skb_copy_and_csum_bits`, and `skb_crc32c`. The new versions introduce return values for error handling, with `skb_checksum_full`, `skb_copy_and_csum_bits` now returning `int`, and `skb_crc32c_full`. Crucially, the new `skb_copy_and_csum_bits` includes an explicit error-handling mechanism. If an error occurs (like `-EFAULT` or `-EINVAL`), the function *explicitly* zeros parts of the buffer (`to`). This is a huge shift in how errors are handled. The original version returned 0 on failure which could have led to uninitialized memory being copied. Looking at the code within `skb_copy_and_csum_bits`, the code explicitly zeros the remaining part of the destination buffer on error: `memset(to + copy, 0, len - copy);`. Moreover, it also explicitly zero the output buffer on failure when unreadable fragments are encountered. This is significant because it is a measure to prevent uninitialized memory being passed up the call chain. Now, let's examine the callers. I see a `sunvnet_common.c` call to `skb_copy_and_csum_bits`. There is a `__wsum csum` local variable. Here is where the patch might introduce a risk. I'll need to use `grepper` or `read-file` to check `sunvnet_common.c` to understand precisely how this change interacts with existing code at around line 1167. I need to ensure the `csum` variable is properly initialized/used. In conclusion, I need to do further investigation. I am leaning towards "NeedsKMSAN=false" because the changes *seem* to be moving towards more robust error-handling, with explicit zeroing. However, I can only make a definitive determination after I have reviewed the calling context of the modified functions, particularly the `sunvnet_common.c` call. Let's see what the grep reveals! |
| 36/3 | 2026/11/04 01:25 | tool | grepper |
0mArgs:{
"Expression": "vnet_skb_shape",
"PathPrefixes": [
"drivers/net/ethernet/sun/sunvnet_common.c"
]
}Results: {
"Output": "drivers/net/ethernet/sun/sunvnet_common.c=1065=static inline int vnet_skb_map(struct ldc_channel *lp, struct sk_buff *skb,\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-1108-\ndrivers/net/ethernet/sun/sunvnet_common.c:1109:static inline struct sk_buff *vnet_skb_shape(struct sk_buff *skb, int ncookies)\ndrivers/net/ethernet/sun/sunvnet_common.c-1110-{\n--\ndrivers/net/ethernet/sun/sunvnet_common.c=1328=sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev,\n--\ndrivers/net/ethernet/sun/sunvnet_common.c-1367-\ndrivers/net/ethernet/sun/sunvnet_common.c:1368:\tskb = vnet_skb_shape(skb, 2);\ndrivers/net/ethernet/sun/sunvnet_common.c-1369-\n"
} |
| 37/3 | 2026/11/04 01:25 | llm | kmsan-evaluator |
0mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 20544 output: 45 thoughts: 34 Thoughts: Here's a summary of my mental process: **Diving into the SunVNET Driver** Okay, time to get to the heart of this. I need to understand what's happening within the `sunvnet_common.c` file, specifically between lines 1140 and 1200. I'm assuming this section likely involves some core network interaction or configuration based on the file and module names. My goal is to grasp the logic being implemented within this section of the driver, so I'll be looking for specific function calls, data structures involved, conditional statements, and any error handling or flow control. I'll be paying close attention to any register accesses or interrupt handling, as those are often critical within device drivers. Based on my existing knowledge, I expect to see operations related to: * Packet processing: Maybe it handles receive or transmit queue management. * Hardware interaction: It is a network driver, so interactions with the network card are to be expected. * Error checking: Any potential issues could be very pertinent. I'm prepared to backtrack and trace function calls if necessary to fully comprehend the context. I'm hoping I'll quickly spot the core of what's happening here, so I can continue with the broader objective. |
| 38/3 | 2026/11/04 01:25 | tool | read-file |
0mArgs:{
"File": "drivers/net/ethernet/sun/sunvnet_common.c",
"FirstLine": 1140,
"LineCount": 60
}Results: {
"Contents": "1140:\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);\n1150:\t\t\tskb_set_transport_header(nskb, offset);\n1151:\t\n1152:\t\t\toffset = 0;\n1153:\t\t\tnskb-\u003ecsum_offset = skb-\u003ecsum_offset;\n1154:\t\t\tnskb-\u003eip_summed = skb-\u003eip_summed;\n1155:\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) {\n1195:\t\t\t\t\t\tcsum = csum_ipv6_magic(\u0026ip6h-\u003esaddr,\n1196:\t\t\t\t\t\t\t\t \u0026ip6h-\u003edaddr,\n1197:\t\t\t\t\t\t\t\t skb-\u003elen - start,\n1198:\t\t\t\t\t\t\t\t ip6h-\u003enexthdr,\n1199:\t\t\t\t\t\t\t\t csum);\n"
} |
| 39/3 | 2026/11/04 01:25 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 21891 output: 20 thoughts: 3152 Thoughts: **Checksum Initialization and `skb_checksum_full` Analysis** Okay, so I was looking into the checksumming logic, specifically around `skb_copy_and_csum_bits` and how it interacts with `skb_checksum_full`. I initially noticed that `skb_copy_and_csum_bits` returns and frees the buffer if it fails, which is expected. The crucial point I was focusing on was how `csum` is handled when the copy is successful. I dove into the implementation of `skb_copy_and_csum_bits`, particularly the `out` label where the checksum `csum` is returned, and started questioning the edge cases. I realized I needed to carefully consider the situation where the length of the requested copy is zero. If `len == 0`, is it handled? And how does this interact with `csump`, the checksum pointer? I went through the logic flow within `skb_copy_and_csum_bits`, particularly the fragmentation loop and the call to `skb_copy_and_csum_frag_list`, to verify that even when `len == 0`, `csump` is always properly initialized. Then I realized something: `skb_checksum_full` takes a `__wsum *csump` argument, and initializes its local `csum` variable by dereferencing this pointer: `__wsum csum = *csump;`. This sparked a deeper question: what is the *initial* value of `csump` when `skb_checksum_full` is called? The answer to this is crucial, because this could potentially lead to bugs, where the checksum isn't properly handled at the start of checksum calculations. Therefore, I needed to check every caller of `skb_checksum_full` to understand this. I went through all of them: `skb_checksum_help`, `skb_crc32c_csum_help`, `__skb_gro_checksum_complete`, `pskb_trim_rcsum_complete`, `skb_checksum_frag_list`, `skb_checksum`, `__skb_checksum_complete_head`, `__skb_checksum_complete` and `skb_segment`. Based on my review, I am very pleased to find that in all the listed cases, `*csump` is explicitly initialized *before* `skb_checksum_full` is called. In most cases, it is initialized to 0, or is used to store previously calculated `csum`. I even checked the relevant GSO path, to confirm there are no initial issues there. This shows good defensive programming, because any other initial value of `csump`, if not cleared beforehand, would have led to inconsistent checksum calculations. Still, I'm going to run a grep through the entire repository to be sure that I've found every single caller, and that there are no remaining potential issues. |
| 40/3 | 2026/11/04 01:27 | tool | grepper |
0mArgs:{
"Expression": "skb_checksum_full"
}Results: {
"Output": "include/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);\ninclude/linux/skbuff.h:4285:int __must_check skb_checksum_full(const struct sk_buff *skb, int offset,\ninclude/linux/skbuff.h-4286-\t\t\t\t int len, __wsum *csump);\n--\nnet/core/dev.c=3666=int skb_checksum_help(struct sk_buff *skb)\n--\nnet/core/dev.c-3699-\t}\nnet/core/dev.c:3700:\tret = skb_checksum_full(skb, offset, skb-\u003elen - offset, \u0026csum);\nnet/core/dev.c-3701-\tif (ret)\n--\nnet/core/gro.c=799=__sum16 __skb_gro_checksum_complete(struct sk_buff *skb)\n--\nnet/core/gro.c-806-\t */\nnet/core/gro.c:807:\tif (skb_checksum_full(skb, skb_gro_offset(skb), skb_gro_len(skb),\nnet/core/gro.c-808-\t\t\t \u0026wsum)) {\n--\nnet/core/skbuff.c=2819=static int pskb_trim_rcsum_complete(struct sk_buff *skb, unsigned int len)\n--\nnet/core/skbuff.c-2826-\nnet/core/skbuff.c:2827:\t\tif (!skb_checksum_full(skb, len, delta, \u0026csum)) {\nnet/core/skbuff.c-2828-\t\t\tskb-\u003ecsum = csum_block_sub(skb-\u003ecsum, csum, len);\n--\nnet/core/skbuff.c-2836-\t\tcsum = 0;\nnet/core/skbuff.c:2837:\t\terr = skb_checksum_full(skb, 0, len, \u0026csum);\nnet/core/skbuff.c-2838-\t\tif (err)\n--\nnet/core/skbuff.c=3551=EXPORT_SYMBOL(skb_store_bits);\nnet/core/skbuff.c-3552-\nnet/core/skbuff.c:3553:/* The frag_list part of skb_checksum_full(). It's out of line so that taking\nnet/core/skbuff.c-3554- * the address of csum2 doesn't cost every caller a stack protector.\n--\nnet/core/skbuff.c=3556=static noinline int skb_checksum_frag_list(const struct sk_buff *skb, int start,\n--\nnet/core/skbuff.c-3574-\t\t\t\tcopy = len;\nnet/core/skbuff.c:3575:\t\t\terr = skb_checksum_full(frag_iter, offset - start, copy,\nnet/core/skbuff.c-3576-\t\t\t\t\t\t\u0026csum2);\n--\nnet/core/skbuff.c-3597-/**\nnet/core/skbuff.c:3598: *\tskb_checksum_full - checksum a range of an skb\nnet/core/skbuff.c-3599- *\t@skb: buffer to checksum\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--\nnet/core/skbuff.c-3674-}\nnet/core/skbuff.c:3675:EXPORT_SYMBOL(skb_checksum_full);\nnet/core/skbuff.c-3676-\nnet/core/skbuff.c-3677-/* skb_checksum() has no way to report failure, so it returns 0, which is a\nnet/core/skbuff.c:3678: * valid checksum. Use skb_checksum_full() in new code.\nnet/core/skbuff.c-3679- */\nnet/core/skbuff.c=3680=__wsum skb_checksum(const struct sk_buff *skb, int offset, int len, __wsum csum)\nnet/core/skbuff.c-3681-{\nnet/core/skbuff.c:3682:\tint err = skb_checksum_full(skb, offset, len, \u0026csum);\nnet/core/skbuff.c-3683-\n--\nnet/core/skbuff.c=3974=__sum16 __skb_checksum_complete_head(struct sk_buff *skb, int len)\n--\nnet/core/skbuff.c-3978-\nnet/core/skbuff.c:3979:\tif (skb_checksum_full(skb, 0, len, \u0026csum))\nnet/core/skbuff.c-3980-\t\treturn skb_checksum_complete_failed(skb);\n--\nnet/core/skbuff.c=4005=__sum16 __skb_checksum_complete(struct sk_buff *skb)\n--\nnet/core/skbuff.c-4009-\nnet/core/skbuff.c:4010:\tif (skb_checksum_full(skb, 0, skb-\u003elen, \u0026csum))\nnet/core/skbuff.c-4011-\t\treturn skb_checksum_complete_failed(skb);\n--\nnet/core/skbuff.c=5052=struct sk_buff *skb_segment(struct sk_buff *head_skb,\n--\nnet/core/skbuff.c-5403-\t\t\tSKB_GSO_CB(nskb)-\u003ecsum = 0;\nnet/core/skbuff.c:5404:\t\t\tif (skb_checksum_full(nskb, doffset,\nnet/core/skbuff.c-5405-\t\t\t\t\t nskb-\u003elen - doffset,\n"
} |
| 41/3 | 2026/11/04 01:27 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 27328 output: 23 thoughts: 38 Thoughts: Okay, here's my take on those thoughts, framed as a first-person expert summary: **Checksum Optimization Analysis** Alright, let's see, the code's got some interesting checksumming routines. My initial observation is that every single call to `skb_checksum_full` *explicitly* initializes the `__wsum` variable before invoking the function. That's a key detail to keep in mind, and suggests they're likely doing this for a specific reason – probably performance or to avoid undefined behavior. Now, let's shift gears and dig into `skb_crc32c_full`. I'll want to see if the same initialization pattern holds true there, and, if not, why the design decisions differ between the two checksum methods. Are there inherent differences in the algorithms that necessitate different handling of the checksum accumulator variable, or is it more of a coding convention issue? I need to understand whether this is a consistent design principle or an inconsistent implementation. My hunch is that they probably have related functionalities, so perhaps there is something the `crc32c` is doing that the other one isn't and vice versa. I am going to see if I can find the differences and see how it works into their design. |
| 42/3 | 2026/11/04 01:28 | tool | grepper |
0mArgs:{
"Expression": "skb_crc32c_full"
}Results: {
"Output": "include/linux/skbuff.h=4333=__wsum skb_checksum(const struct sk_buff *skb, int offset, int len,\ninclude/linux/skbuff.h-4334-\t\t __wsum csum);\ninclude/linux/skbuff.h:4335:int __must_check skb_crc32c_full(const struct sk_buff *skb, int offset,\ninclude/linux/skbuff.h-4336-\t\t\t\t int len, u32 *crcp);\n--\nnet/core/dev.c=3725=int skb_crc32c_csum_help(struct sk_buff *skb)\n--\nnet/core/dev.c-3755-\tcrc = ~0;\nnet/core/dev.c:3756:\tret = skb_crc32c_full(skb, start, skb-\u003elen - start, \u0026crc);\nnet/core/dev.c-3757-\tif (ret)\n--\nnet/core/skbuff.c=3832=EXPORT_SYMBOL(skb_copy_and_csum_bits);\n--\nnet/core/skbuff.c-3834-#ifdef CONFIG_NET_CRC32C\nnet/core/skbuff.c:3835:/* The frag_list part of skb_crc32c_full(). It's out of line so that taking\nnet/core/skbuff.c-3836- * the address of crc doesn't cost every caller a stack protector.\n--\nnet/core/skbuff.c=3838=static noinline int skb_crc32c_frag_list(const struct sk_buff *skb, int start,\n--\nnet/core/skbuff.c-3853-\t\t\tcopy = min(copy, len);\nnet/core/skbuff.c:3854:\t\t\terr = skb_crc32c_full(frag_iter, offset - start, copy,\nnet/core/skbuff.c-3855-\t\t\t\t\t \u0026crc);\n--\nnet/core/skbuff.c-3874-/**\nnet/core/skbuff.c:3875: *\tskb_crc32c_full - CRC32C a range of an skb\nnet/core/skbuff.c-3876- *\t@skb: buffer to read\n--\nnet/core/skbuff.c-3885- */\nnet/core/skbuff.c:3886:int skb_crc32c_full(const struct sk_buff *skb, int offset, int len, u32 *crcp)\nnet/core/skbuff.c-3887-{\n--\nnet/core/skbuff.c-3942-}\nnet/core/skbuff.c:3943:EXPORT_SYMBOL(skb_crc32c_full);\nnet/core/skbuff.c-3944-\nnet/core/skbuff.c-3945-/* skb_crc32c() has no way to report failure, so it returns 0, which is a\nnet/core/skbuff.c:3946: * valid CRC. Use skb_crc32c_full() in new code.\nnet/core/skbuff.c-3947- */\nnet/core/skbuff.c=3948=u32 skb_crc32c(const struct sk_buff *skb, int offset, int len, u32 crc)\nnet/core/skbuff.c-3949-{\nnet/core/skbuff.c:3950:\tint err = skb_crc32c_full(skb, offset, len, \u0026crc);\nnet/core/skbuff.c-3951-\n"
} |
| 43/3 | 2026/11/04 01:28 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 28601 output: 25 thoughts: 40 Thoughts: Here's my analysis of the provided snippet, framed as my own thought process: **CRC Calculation Deep Dive** Okay, so I'm looking at how CRC calculations are handled, specifically within the kernel. The crucial point here is that every single call to `skb_crc32c_full` begins by initializing the `crc` variable. This is important. It immediately suggests that the function is designed to work in a completely self-contained manner, not relying on a pre-existing CRC value passed in from a previous calculation. This implies a fresh start for each checksum computation, which has ramifications for how we might optimize it, or if it has external dependencies. Now, let's switch gears and investigate `skb_copy_and_csum_bits`. Understanding its relationship with this CRC function is key. I'll need to dig into how it uses, or potentially *doesn't* use, this CRC function to see how the checksum is actually calculated and potentially where optimization should take place. My main focus is on how the data is handled. Is data copied or the checksum added to the data copy? |
| 44/3 | 2026/11/04 01:30 | 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"
} |
| 45/3 | 2026/11/04 01:30 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 30590 output: 41 thoughts: 3362 Thoughts: **Analysis of `skb_copy_and_csum_bits` Callers and Associated Issues** Okay, let's break this down systematically. My initial goal is to understand how `skb_copy_and_csum_bits` is used and if there are any potential issues in its usage across the kernel, specifically concerning the checksum (`csump`) argument. First, I examined each call site of `skb_copy_and_csum_bits`. I began with `drivers/net/ethernet/sun/sunvnet_common.c`. I noticed that `csum` isn't initialized before the call, which raises a flag. However, the code *does* check the return value, and if the function *fails*, it cleans up and returns. So, it's not immediately problematic in this specific instance. I then verified that a zero return value from `skb_copy_and_csum_bits` *always* updates `*csump` based on the internal workings of the function's definition. I then dug into the `skb_copy_and_csum_bits` function itself. I observed the critical path, where on success, `*csump` *is* unconditionally updated with the calculated checksum. I was particularly interested in what happens if `len` is zero or if `copy <= 0` in the header or frag loops; in these cases, the function correctly calculates checksums even with zero-length copies and guarantees that the `*csump` is always written. This behavior gives me confidence in the core function's logic. Next, I examined the other call sites methodically. I checked `net/core/skbuff.c: skb_copy_and_csum_dev` and verified that the `csum` is initialized to 0. Also, there's explicit handling to prevent copying garbage from underflowing or overflowing buffers, ensuring data integrity. I checked `skb_segment`, and verified error handling (if error, nskb is dropped). I looked at `net/ipv4/icmp.c`, `net/ipv4/ip_output.c`, `net/ipv6/icmp.c`, and `net/ipv6/ip6_output.c`, each time confirming that errors from `skb_copy_and_csum_bits` are handled immediately by returning from the calling function. The same pattern is there for `net/sunrpc/socklib.c`. I looked at `drivers/net/xen-netfront.c` and found that the initial `BUG_ON` call has been replaced with an explicit error check. Then I verified error handling for `skb_zerocopy`, where they added a check for negative values of length and head length. Then in `skb_try_coalesce`, an explicit check for delta is less than 0 is added and in `tls_sw.c`, the initial `BUG_ON` call is replaced with explicit return from the function in case of error. Lastly, I identified a potential regression in `net/sunrpc/socklib.c: csum_partial_copy_to_xdr`, where checksum calculations after the initial copy appear to have been removed. This requires *further investigation*. |
| 46/3 | 2026/11/04 01:31 | tool | grepper |
0mArgs:{
"Expression": "csum_partial_copy_to_xdr",
"PathPrefixes": [
"net/sunrpc/socklib.c"
]
}Results: {
"Output": "net/sunrpc/socklib.c=67=xdr_partial_copy_from_skb(struct xdr_buf *xdr, struct xdr_skb_reader *desc)\n--\nnet/sunrpc/socklib.c-120-/**\nnet/sunrpc/socklib.c:121: * csum_partial_copy_to_xdr - checksum and copy data\nnet/sunrpc/socklib.c-122- * @xdr: target XDR buffer\n--\nnet/sunrpc/socklib.c-127- */\nnet/sunrpc/socklib.c:128:int csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)\nnet/sunrpc/socklib.c-129-{\n"
} |
| 47/3 | 2026/11/04 01:31 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 34906 output: 37 thoughts: 22 Thoughts: Here's a summary of my thought process, assuming I'm an expert: **Diving into `socklib.c`** Okay, time to get to the heart of the matter. I need to understand how the RPC socket library handles things. I'm going to jump straight into `net/sunrpc/socklib.c`, specifically around line 128. I have a hunch that something related to socket management or error handling might be there, based on the problem I'm trying to solve. Let's see what's what. |
| 48/3 | 2026/11/04 01:32 | tool | read-file |
0mArgs:{
"File": "net/sunrpc/socklib.c",
"FirstLine": 120,
"LineCount": 40
}Results: {
"Contents": " 120:\t/**\n 121:\t * csum_partial_copy_to_xdr - checksum and copy data\n 122:\t * @xdr: target XDR buffer\n 123:\t * @skb: source skb\n 124:\t *\n 125:\t * We have set things up such that we perform the checksum of the UDP\n 126:\t * packet in parallel with the copies into the RPC client iovec. -DaveM\n 127:\t */\n 128:\tint csum_partial_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)\n 129:\t{\n 130:\t\tstruct xdr_skb_reader desc = {\n 131:\t\t\t.skb\t\t= skb,\n 132:\t\t\t.count\t\t= skb-\u003elen - desc.offset,\n 133:\t\t};\n 134:\t\n 135:\t\tif (skb_csum_unnecessary(skb)) {\n 136:\t\t\tif (xdr_partial_copy_from_skb(xdr, \u0026desc) \u003c 0)\n 137:\t\t\t\treturn -1;\n 138:\t\t\tif (desc.count)\n 139:\t\t\t\treturn -1;\n 140:\t\t\treturn 0;\n 141:\t\t}\n 142:\t\n 143:\t\tdesc.need_checksum = true;\n 144:\t\tdesc.csum = csum_partial(skb-\u003edata, desc.offset, skb-\u003ecsum);\n 145:\t\tif (xdr_partial_copy_from_skb(xdr, \u0026desc) \u003c 0)\n 146:\t\t\treturn -1;\n 147:\t\tif (desc.count)\n 148:\t\t\treturn -1;\n 149:\t\tif (csum_fold(desc.csum))\n 150:\t\t\treturn -1;\n 151:\t\tif (unlikely(skb-\u003eip_summed == CHECKSUM_COMPLETE) \u0026\u0026\n 152:\t\t !skb-\u003ecsum_complete_sw)\n 153:\t\t\tnetdev_rx_csum_fault(skb-\u003edev, skb);\n 154:\t\treturn 0;\n 155:\t}\n 156:\t\n 157:\tstatic inline int xprt_sendmsg(struct socket *sock, struct msghdr *msg,\n 158:\t\t\t\t size_t seek)\n 159:\t{\n"
} |
| 49/3 | 2026/11/04 01:32 | llm | kmsan-evaluator |
1mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 35741 output: 39 thoughts: 2706 Thoughts: **Analysis of `skb_copy_and_csum_bits` Error Handling and Impact** Okay, so I've been digging into this change and its implications for how we handle checksums and data copies within the kernel, specifically focusing on `skb_copy_and_csum_bits` and its related functions. The initial point was looking at `desc.count = skb->len - desc.offset;` in relation to `xdr_partial_copy_from_skb`, where `desc.offset` becomes `skb->len` when `desc.count == 0` because of how `xdr_partial_copy_from_skb` uses `desc.count`. The dead code removal made sense. Now, let's look at `net/core/dev.c`. I noticed that a check was added in `skb_checksum_help` to ensure `offset + sizeof(__sum16)` doesn't exceed `skb_headlen(skb)`. Previously, if this condition wasn't met, the function simply returned 0. Now a `-EINVAL` is returned, which is a subtle, but critical, change. This means that if the checksum calculation goes awry due to buffer overflow, we now return `-EINVAL` instead of continuing with potentially incorrect checksum data. I've confirmed that `csum` is calculated via `skb_checksum_full`. Next, I looked at how GRO (Generic Receive Offload) handles checksums in `net/core/gro.c`. In `__skb_gro_checksum_complete`, if `skb_checksum_full` fails, it sets `NAPI_GRO_CB(skb)->csum_valid` to 0 and returns 1. This is in the spirit of the change. It indicates that the GRO checksum has failed and therefore is not to be trusted. Then I examined the "complete" checksum functions, `__skb_checksum_complete_head`, and `__skb_checksum_complete`, where if the checksum fails, the `skb_checksum_complete_failed` is called, which will unset the checksum data. And the comments in `include/linux/skbuff.h` for `__skb_checksum_validate_complete` and `__skb_checksum_validate` have been updated to reflect the new state. This looks fine. The core of my concern here is how `skb_copy_and_csum_bits` behaves. I meticulously reviewed the doc comment and the code. The critical change is the addition of `memset(to, 0, len);` when `skb_frags_readable(skb)` is false or on `unlikely(len)`. It now sets the destination buffer `to` to zero, and returns `-EFAULT` (previously 0). This *is* a significant behavior change, because `skb_copy_and_csum_bits` will not leave the destination buffer in a partially-filled, uninitialized state. The consequences of having uninitialized data in buffers are security concerns. This change seems aimed at preventing that. I checked `skb_copy_and_csum_frag_list` to see how the change is handled, and it seems to correctly propagate the error and, if an error happens in a sub-fragment copy, zeros the remainder of the destination buffer. Now the million-dollar question: what happens *after* `skb_copy_and_csum_bits` returns an error? I've systematically checked every single caller of this function. 1. `sunvnet_common.c` : Both `skb` and `nskb` are freed, and NULL is returned on error. 2. `skb_copy_and_csum_dev`: The entire `to` buffer is zeroed, and then returns. 3. `skb_segment`: An error is set, and the code jumps to an error handling path, freeing resources. 4. `icmp_glue_bits`: the function returns an error. 5. `ip_output.c`: The `skb` is freed and an error path is taken. 6. `icmpv6_getfrag`: The function simply returns the error. 7. `ip6_output.c`: The skb is freed and an error path is taken. 8. `xdr_skb_read_bits`: on error, this one returns 0. However, in the context of `xdr_skb_read_bits`, this isn't very alarming. We're potentially returning a partial read, which the caller needs to handle. It's a bit odd, though, because callers of |
| 50/3 | 2026/11/04 01:33 | tool | grepper |
0mArgs:{
"Expression": "xdr_skb_read_bits",
"PathPrefixes": [
"net/sunrpc/socklib.c"
]
}Results: {
"Output": "net/sunrpc/socklib.c=27=struct xdr_skb_reader {\n--\nnet/sunrpc/socklib.c-35-/**\nnet/sunrpc/socklib.c:36: * xdr_skb_read_bits - copy some data bits from skb to internal buffer\nnet/sunrpc/socklib.c-37- * @desc: sk_buff copy helper\n--\nnet/sunrpc/socklib.c=44=static size_t\nnet/sunrpc/socklib.c:45:xdr_skb_read_bits(struct xdr_skb_reader *desc, void *to, size_t len)\nnet/sunrpc/socklib.c-46-{\n--\nnet/sunrpc/socklib.c=67=xdr_partial_copy_from_skb(struct xdr_buf *xdr, struct xdr_skb_reader *desc)\n--\nnet/sunrpc/socklib.c-77-\nnet/sunrpc/socklib.c:78:\tret = xdr_skb_read_bits(desc, xdr-\u003ehead[0].iov_base,\nnet/sunrpc/socklib.c-79-\t\t\t\txdr-\u003ehead[0].iov_len);\n--\nnet/sunrpc/socklib.c-99-\t\tkaddr = kmap_atomic(*ppage);\nnet/sunrpc/socklib.c:100:\t\tret = xdr_skb_read_bits(desc, kaddr + poff, len);\nnet/sunrpc/socklib.c-101-\t\tflush_dcache_page(*ppage);\n--\nnet/sunrpc/socklib.c-112-\tif (xdr-\u003etail[0].iov_len) {\nnet/sunrpc/socklib.c:113:\t\tcopied += xdr_skb_read_bits(desc, xdr-\u003etail[0].iov_base,\nnet/sunrpc/socklib.c-114-\t\t\t\t\txdr-\u003etail[0].iov_len);\n"
} |
| 51/3 | 2026/11/04 01:33 | llm | kmsan-evaluator |
2mModel:gemini-3.8-flash Args: null Results: null Tokens: input: 40019 output: 402 thoughts: 4655 Thoughts: **KMSAN Reasoning for Network SKB Patch Series** Okay, so I've meticulously reviewed this patch series, and here's my assessment. The primary focus of these changes is to enhance error handling and safety within the network SKB (Socket Buffer) infrastructure, particularly concerning checksum calculations, data copying, and segmentation. I've taken a deep dive, focusing on potential uninitialized memory risks. First off, the core of the changes involves modifying checksum functions (like `skb_checksum`, `skb_copy_and_csum_bits`, `skb_crc32c`) to utilize explicit error codes rather than returning ambiguous values, introducing robust bounds and length validations, and replacing problematic `BUG_ON` calls with more graceful error handling that propagates the error code, usually leading to a return from the function. Now, let's address the critical issue of uninitialized memory. The code uses several variables passed by reference, most notably checksum accumulators like `csump` and `crcp`. I've verified that all callers of functions like `skb_checksum_full` and `skb_crc32c_full` *explicitly* initialize these accumulators *before* passing them to the checksum calculation functions. For example, `csum` is usually initialized to zero (like `__wsum csum = 0;`), or in cases such as CRC, to a known initial state (e.g. `crc = ~0;`). The `skb_copy_and_csum_bits` function, in particular, treats the `csump` argument as strictly an *out* parameter; it never reads the value of `csump` but only sets it. The callers *always* check the return code of `skb_copy_and_csum_bits` and if an error is returned, the value of `csum` is not used. Also, I've checked that destination buffers are explicitly zeroed when data is unreadable or an error occurs, explicitly preventing stale data from ending up in the destination memory. Given this rigorous review, I've concluded that this patch series *does not* introduce any new risks of uninitialized memory reads. All potential risks stemming from this patch series are related to bounds checking, skb fragment walking, and error returns. These potential problems might manifest as out-of-bounds accesses, NULL pointer dereferences, or memory leaks. However, these issues are very well covered by KASAN and standard debugging mechanisms. No risks of uninitialized memory *reads* or information leak are introduced. This patch series focuses on *improving* robustness and error handling, rather than introducing new memory safety concerns. Therefore, a specialized KMSAN fuzzing session is not required. So, in short: *NeedsKMSAN = false*. |
| 52/3 | 2026/11/04 01:36 | 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 report errors via return codes rather than returning ambiguous 0 checksum values, adds length and bounds checks, and replaces BUG_ON assertions with proper error handling and packet drops.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Analysis: All callers of skb_checksum_full, skb_crc32c_full, and skb_copy_and_csum_bits properly initialize accumulator variables prior to invocation (e.g., initializing `csum = 0` or `crc = ~0`). In skb_copy_and_csum_bits, `csump` is an out-parameter that is populated on success; on error paths, all callers inspect the return value and cleanly abort or drop the packet without reading the checksum. Furthermore, when unreadable fragments or truncated lengths are encountered during copying, destination buffers are explicitly zeroed via memset to prevent handing callers uninitialized or stale data.\n- KASAN / Standard Debuggers: The risks touched by these changes involve bounds verification (clamping length, validating negative offsets/lengths, underflow prevention when skb-\u003edata_len \u003e skb-\u003elen), fragment list iteration, and NULL dereference prevention (such as validating list_skb). Any potential regressions (e.g., out-of-bounds reads/writes or NULL pointer dereferences) are caught by KASAN and standard kernel debug facilities.\n\nSince no uninitialized memory usage, uninitialized branching, or kernel-to-user info-leak risks are introduced or exposed, 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 report errors via return codes rather than returning ambiguous 0 checksum values, adds length and bounds checks, and replaces BUG_ON assertions with proper error handling and packet drops.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Analysis: All callers of skb_checksum_full, skb_crc32c_full, and skb_copy_and_csum_bits properly initialize accumulator variables prior to invocation (e.g., initializing `csum = 0` or `crc = ~0`). In skb_copy_and_csum_bits, `csump` is an out-parameter that is populated on success; on error paths, all callers inspect the return value and cleanly abort or drop the packet without reading the checksum. Furthermore, when unreadable fragments or truncated lengths are encountered during copying, destination buffers are explicitly zeroed via memset to prevent handing callers uninitialized or stale data.\n- KASAN / Standard Debuggers: The risks touched by these changes involve bounds verification (clamping length, validating negative offsets/lengths, underflow prevention when skb-\u003edata_len \u003e skb-\u003elen), fragment list iteration, and NULL dereference prevention (such as validating list_skb). Any potential regressions (e.g., out-of-bounds reads/writes or NULL pointer dereferences) are caught by KASAN and standard kernel debug facilities.\n\nSince no uninitialized memory usage, uninitialized branching, or kernel-to-user info-leak risks are introduced or exposed, 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) |
|---|