pull request (net): ipsec 2022-04-14
Subsystems (3)
Steffen Klassert
maintainercover pull request (net): ipsec 2022-04-14
1) Fix the output interface for VRF cases in xfrm_dst_lookup. From David Ahern.
2) Fix write out of bounds by doing COW on esp output when the packet size is larger than a page.
From Sabrina Dubroca.
Please pull or let me know if there are problems.
Thanks!
The following changes since commit 692930cc435099580a4b9e32fa781b0688c18439:
selftests: net: fix nexthop warning cleanup double ip typo (2022-04-03 13:09:05 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec.git master
for you to fetch changes up to 5bd8baab087dff657e05387aee802e70304cc813:
esp: limit skb_page_frag_refill use to a single page (2022-04-13 10:16:11 +0200)
----------------------------------------------------------------
David Ahern (1):
xfrm: Pass flowi_oif or l3mdev as oif to xfrm_dst_lookup
Sabrina Dubroca (1):
esp: limit skb_page_frag_refill use to a single page
include/net/esp.h | 2 -- net/ipv4/esp4.c | 5 ++--- net/ipv6/esp6.c | 5 ++--- net/xfrm/xfrm_policy.c | 4 +++- 4 files changed, 7 insertions(+), 9 deletions(-)
Steffen Klassert
maintainerPATCH 1/2 xfrm: Pass flowi_oif or l3mdev as oif to xfrm_dst_lookup
From: David Ahern <[email protected]>
The commit referenced in the Fixes tag no longer changes the flow oif to the l3mdev ifindex. A xfrm use case was expecting the flowi_oif to be the VRF if relevant and the change broke that test. Update xfrm_bundle_create to pass oif if set and any potential flowi_l3mdev if oif is not set.
--- net/xfrm/xfrm_policy.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/xfrm/xfrm_policy.c +3 -1
@@ -2593,12 +2593,14 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,if (xfrm[i]->props.mode !=XFRM_MODE_TRANSPORT ) {__u32 mark =0 ; +int oif;if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m) mark =xfrm_smark_get (fl->flowi_mark, xfrm[i]); family = xfrm[i]->props.family; - dst =xfrm_dst_lookup (xfrm[i], tos, fl->flowi_oif, + oif = fl->flowi_oif ? : fl->flowi_l3mdev; + dst =xfrm_dst_lookup (xfrm[i], tos, oif, &saddr, &daddr, family, mark); err =PTR_ERR (dst);if (IS_ERR (dst))
Signature · 1 line
2.25.1
Re: [PATCH 1/2] xfrm: Pass flowi_oif or l3mdev as oif to xfrm_dst_lookup
This series was applied to netdev/net.git (master) by Steffen Klassert <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Steffen Klassert <[email protected]>:
Quoted 9 lines · On Thu, 14 Apr 2022 11:19:42 +0200 you wrote:
From: David Ahern <[email protected]>
The commit referenced in the Fixes tag no longer changes the flow oif to the l3mdev ifindex. A xfrm use case was expecting the
flowi_oifto be the VRF if relevant and the change broke that test. Updatexfrm_bundle_createto pass oif if set and any potentialflowi_l3mdevif oif is not set.[...]
Here is the summary with links:
- [1/2] xfrm: Pass flowi_oif or l3mdev as oif to xfrm_dst_lookup
https://git.kernel.org/netdev/net/c/748b82c23e25 - [2/2] esp: limit skb_page_frag_refill use to a single page https://git.kernel.org/netdev/net/c/5bd8baab087d
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
Steffen Klassert
maintainerPATCH 2/2 esp: limit skb_page_frag_refill use to a single page
In reply to Steffen KlassertFrom: Sabrina Dubroca <[email protected]>
Commit ebe48d368e97 ("esp: Fix possible buffer overflow in ESP transformation") tried to fix skb_page_frag_refill usage in ESP by capping allocsize to 32k, but that doesn't completely solve the issue, as skb_page_frag_refill may return a single page. If that happens, we will write out of bounds, despite the check introduced in the previous patch.
This patch forces COW in cases where we would end up calling skb_page_frag_refill with a size larger than a page (first in esp_output_head with tailen, then in esp_output_tail with skb->data_len).
--- include/net/esp.h | 2 -- net/ipv4/esp4.c | 5 ++--- net/ipv6/esp6.c | 5 ++--- 3 files changed, 4 insertions(+), 8 deletions(-)
include/net/esp.h +0 -2
@@ -4,8 +4,6 @@#include <linux/skbuff.h> -#define ESP_SKB_FRAG_MAXSIZE (PAGE_SIZE << SKB_FRAG_PAGE_ORDER) -struct ip_esp_hdr ;static inline struct ip_esp_hdr *ip_esp_hdr (const struct sk_buff *skb)
net/ipv4/esp4.c +2 -3
@@ -446,7 +446,6 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *struct page *page;struct sk_buff *trailer;int tailen = esp->tailen; -unsigned int allocsz;/* this is non-NULL only with TCP/UDP Encapsulation */ if (x->encap) {
@@ -456,8 +455,8 @@ int esp_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *return err; } - allocsz =ALIGN (skb->data_len + tailen,L1_CACHE_BYTES ); -if (allocsz >ESP_SKB_FRAG_MAXSIZE ) +if (ALIGN (tailen,L1_CACHE_BYTES ) >PAGE_SIZE || +ALIGN (skb->data_len,L1_CACHE_BYTES ) >PAGE_SIZE ) goto cow;if (!skb_cloned (skb)) {
net/ipv6/esp6.c +2 -3
@@ -482,7 +482,6 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_infostruct page *page;struct sk_buff *trailer;int tailen = esp->tailen; -unsigned int allocsz;if (x->encap) {int err =esp6_output_encap (x, skb, esp);
@@ -491,8 +490,8 @@ int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_inforeturn err; } - allocsz =ALIGN (skb->data_len + tailen,L1_CACHE_BYTES ); -if (allocsz >ESP_SKB_FRAG_MAXSIZE ) +if (ALIGN (tailen,L1_CACHE_BYTES ) >PAGE_SIZE || +ALIGN (skb->data_len,L1_CACHE_BYTES ) >PAGE_SIZE ) goto cow;if (!skb_cloned (skb)) {
Signature · 1 line
2.25.1