[Deepin-Kernel-SIG] [linux 6.6-y] [Upstream] Update kernel base to 6.6.138#1673
Conversation
commit f4c50a4034e62ab75f1d5cdd191dd5f9c77fdff4 upstream. MSG_SPLICE_PAGES can attach pages from a pipe directly to an skb. TCP marks such skbs with SKBFL_SHARED_FRAG after skb_splice_from_iter(), so later paths that may modify packet data can first make a private copy. The IPv4/IPv6 datagram append paths did not set this flag when splicing pages into UDP skbs. That leaves an ESP-in-UDP packet made from shared pipe pages looking like an ordinary uncloned nonlinear skb. ESP input then takes the no-COW fast path for uncloned skbs without a frag_list and decrypts in place over data that is not owned privately by the skb. Mark IPv4/IPv6 datagram splice frags with SKBFL_SHARED_FRAG, matching TCP. Also make ESP input fall back to skb_cow_data() when the flag is present, so ESP does not decrypt externally backed frags in place. Private nonlinear skb frags still use the existing fast path. This intentionally does not change ESP output. In esp_output_head(), the path that appends the ESP trailer to existing skb tailroom without calling skb_cow_data() is not reachable for nonlinear skbs: skb_tailroom() returns zero when skb->data_len is nonzero, while ESP tailen is positive. Thus ESP output will either use the separate destination-frag path or fall back to skb_cow_data(). Fixes: cac2661 ("esp4: Avoid skb_cow_data whenever possible") Fixes: 03e2a30 ("esp6: Avoid skb_cow_data whenever possible") Fixes: 7da0dde ("ip, udp: Support MSG_SPLICE_PAGES") Fixes: 6d8192b ("ip6, udp6: Support MSG_SPLICE_PAGES") Reported-by: Hyunwoo Kim <imv4bel@gmail.com> Reported-by: Kuan-Ting Chen <h3xrabbit@gmail.com> Tested-by: Hyunwoo Kim <imv4bel@gmail.com> Cc: stable@vger.kernel.org Signed-off-by: Kuan-Ting Chen <h3xrabbit@gmail.com> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 50ed1e7873100f77abad20fd31c51029bc49cd03) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 3b9f64db049687c0d38b4b3ef2f297f0642179af) Signed-off-by: Wentao Guan <guanwentao@uniontech.com>
Reviewer's guide (collapsed on small PRs)Reviewer's GuideBumps the kernel base from 6.6.137 to 6.6.138 and backports the associated networking fixes to correctly mark and handle shared skb frags in IPv4/IPv6 output and ESP input paths. Sequence diagram for IPv4/IPv6 append data with shared skb fragssequenceDiagram
participant App as Application
participant Sock as sock
participant IP4 as __ip_append_data
participant IP6 as __ip6_append_data
participant SKB as sk_buff
participant Info as skb_shared_info
App->>Sock: sendmsg(data, flags)
Sock->>IP4: __ip_append_data(sk, data, flags, skb)
IP4->>SKB: allocate_or_get_skb()
SKB-->>IP4: skb
IP4->>IP4: copy = skb_zerocopy_iter_stream()
alt copy_succeeds_ipv4
IP4->>Info: skb_shinfo(skb)
alt allow_shared_frags
IP4->>Info: set flags |= SKBFL_SHARED_FRAG
else disallow_shared_frags
IP4->>IP4: flags has MSG_NO_SHARED_FRAGS
IP4->>Info: flags unchanged
end
IP4->>IP4: wmem_alloc_delta += copy
end
App->>Sock: sendmsg_v6(data, flags)
Sock->>IP6: __ip6_append_data(sk, data, flags, skb)
IP6->>SKB: allocate_or_get_skb()
SKB-->>IP6: skb
IP6->>IP6: copy = skb_zerocopy_iter_stream()
alt copy_succeeds_ipv6
IP6->>Info: skb_shinfo(skb)
alt allow_shared_frags_v6
IP6->>Info: set flags |= SKBFL_SHARED_FRAG
else disallow_shared_frags_v6
IP6->>IP6: flags has MSG_NO_SHARED_FRAGS
IP6->>Info: flags unchanged
end
IP6->>IP6: wmem_alloc_delta += copy
end
Sequence diagram for ESP input handling of shared skb fragssequenceDiagram
participant NetDev as net_device
participant Stack as IP_stack
participant ESP4 as esp_input
participant ESP6 as esp6_input
participant SKB as sk_buff
participant Info as skb_shared_info
NetDev-->>Stack: receive IPv4 packet
Stack->>ESP4: esp_input(x, skb)
ESP4->>Info: skb_shinfo(skb)
alt cloned_skb
ESP4->>ESP4: nfrags = 1
ESP4->>ESP4: goto skip_cow
else non_cloned_skb
ESP4->>ESP4: check !skb_has_frag_list(skb) && !skb_has_shared_frag(skb)
alt no_frag_list_and_not_shared
ESP4->>ESP4: nfrags = Info.nr_frags + 1
else has_frag_list_or_shared
ESP4->>ESP4: follow existing COW path
end
end
NetDev-->>Stack: receive IPv6 packet
Stack->>ESP6: esp6_input(x, skb)
ESP6->>Info: skb_shinfo(skb)
alt cloned_skb_v6
ESP6->>ESP6: nfrags = 1
ESP6->>ESP6: goto skip_cow
else non_cloned_skb_v6
ESP6->>ESP6: check !skb_has_frag_list(skb) && !skb_has_shared_frag(skb)
alt no_frag_list_and_not_shared_v6
ESP6->>ESP6: nfrags = Info.nr_frags + 1
else has_frag_list_or_shared_v6
ESP6->>ESP6: follow existing COW path
end
end
Class diagram for sk_buff and skb_shared_info with shared frag flag handlingclassDiagram
class sk_buff {
+unsigned int len
+unsigned int data_len
+unsigned int truesize
+unsigned int queue_mapping
+unsigned short protocol
+unsigned int priority
+void* head
+unsigned char* data
+unsigned char* tail
+unsigned char* end
+sk_buff* frag_list
+skb_shared_info* shinfo
+bool cloned
+bool nohdr
+bool destructor
}
class skb_shared_info {
+unsigned short nr_frags
+unsigned short gso_size
+unsigned short gso_segs
+unsigned int gso_type
+unsigned int ip6_frag_id
+unsigned int flags
+const skb_frag_t frags[]
+bool has_shared_frag()
+bool has_frag_list()
}
class ip_output {
+int __ip_append_data(sock* sk, void* data, int flags, sk_buff* skb)
}
class ip6_output {
+int __ip6_append_data(sock* sk, void* data, int flags, sk_buff* skb)
}
class esp4 {
+int esp_input(xfrm_state* x, sk_buff* skb)
}
class esp6 {
+int esp6_input(xfrm_state* x, sk_buff* skb)
}
class skb_flags_constants {
<<enumeration>>
+unsigned int SKBFL_SHARED_FRAG
+int MSG_NO_SHARED_FRAGS
}
sk_buff --> skb_shared_info : has
sk_buff --> sk_buff : frag_list
ip_output --> sk_buff : manipulates
ip_output --> skb_shared_info : sets SKBFL_SHARED_FRAG
ip6_output --> sk_buff : manipulates
ip6_output --> skb_shared_info : sets SKBFL_SHARED_FRAG
esp4 --> sk_buff : reads
esp4 --> skb_shared_info : reads nr_frags and flags
esp6 --> sk_buff : reads
esp6 --> skb_shared_info : reads nr_frags and flags
skb_shared_info --> skb_flags_constants : uses
ip_output --> skb_flags_constants : uses
ip6_output --> skb_flags_constants : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The new
skb_has_shared_frag()checks in bothesp_inputandesp6_inputduplicate the same conditional pattern as the frag list check; consider factoring this into a small helper or macro to keep the IPv4/IPv6 ESP paths in lockstep and reduce chances of future divergence. - In
__ip_append_dataand__ip6_append_data, it may be helpful to add a short comment near theSKBFL_SHARED_FRAGflag assignment to explain the interaction withMSG_NO_SHARED_FRAGSand why the linearized copy path implies shared fragments, to aid future maintainers debugging SKB lifetime issues.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The new `skb_has_shared_frag()` checks in both `esp_input` and `esp6_input` duplicate the same conditional pattern as the frag list check; consider factoring this into a small helper or macro to keep the IPv4/IPv6 ESP paths in lockstep and reduce chances of future divergence.
- In `__ip_append_data` and `__ip6_append_data`, it may be helpful to add a short comment near the `SKBFL_SHARED_FRAG` flag assignment to explain the interaction with `MSG_NO_SHARED_FRAGS` and why the linearized copy path implies shared fragments, to aid future maintainers debugging SKB lifetime issues.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Updates the Deepin kernel base to Linux 6.6.138, incorporating upstream networking fixes related to ESP (IPv4/IPv6) input handling and marking SKBs with potentially shared fragments during output construction.
Changes:
- Bump kernel sublevel from 6.6.137 → 6.6.138.
- Mark SKBs built via
MSG_SPLICE_PAGESasSKBFL_SHARED_FRAGunlessMSG_NO_SHARED_FRAGSis set (IPv4/IPv6 output paths). - Prevent ESP IPv4/IPv6 input from taking the “no COW needed” fast path when the skb has
SKBFL_SHARED_FRAG.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| net/ipv6/ip6_output.c | Marks spliced-page output SKBs as having shared frags unless explicitly disabled. |
| net/ipv6/esp6.c | Avoids fast-path fragment assumptions when skb contains shared frags. |
| net/ipv4/ip_output.c | Marks spliced-page output SKBs as having shared frags unless explicitly disabled. |
| net/ipv4/esp4.c | Avoids fast-path fragment assumptions when skb contains shared frags. |
| Makefile | Bumps kernel SUBLEVEL to 138. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update kernel base to 6.6.138.
git log --oneline v6.6.137..v6.6.138 |wc
2 13 96
Summary by Sourcery
Update the kernel base to 6.6.138 and adjust IPv4/IPv6 ESP and output handling for shared SKB fragments.
Bug Fixes:
Enhancements: