Skip to content

Commit 811b3f9

Browse files
committed
Merge tag 'ipsec-2024-03-06' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec
Steffen Klassert says: ==================== pull request (net): ipsec 2024-03-06 1) Clear the ECN bits flowi4_tos in decode_session4(). This was already fixed but the bug was reintroduced when decode_session4() switched to us the flow dissector. From Guillaume Nault. 2) Fix UDP encapsulation in the TX path with packet offload mode. From Leon Romanovsky, 3) Avoid clang fortify warning in copy_to_user_tmpl(). From Nathan Chancellor. 4) Fix inter address family tunnel in packet offload mode. From Mike Yu. * tag 'ipsec-2024-03-06' of git://git.kernel.org/pub/scm/linux/kernel/git/klassert/ipsec: xfrm: set skb control buffer based on packet offload as well xfrm: fix xfrm child route lookup for packet offload xfrm: Avoid clang fortify warning in copy_to_user_tmpl() xfrm: Pass UDP encapsulation in TX packet offload xfrm: Clear low order bits of ->flowi4_tos in decode_session4(). ==================== Link: https://lore.kernel.org/r/20240306100438.3953516-1-steffen.klassert@secunet.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents d3eee81 + 2ce0eae commit 811b3f9

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

net/xfrm/xfrm_device.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x)
407407
struct xfrm_dst *xdst = (struct xfrm_dst *)dst;
408408
struct net_device *dev = x->xso.dev;
409409

410-
if (!x->type_offload || x->encap)
410+
if (!x->type_offload)
411411
return false;
412412

413413
if (x->xso.type == XFRM_DEV_OFFLOAD_PACKET ||

net/xfrm/xfrm_output.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,13 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
704704
{
705705
struct net *net = dev_net(skb_dst(skb)->dev);
706706
struct xfrm_state *x = skb_dst(skb)->xfrm;
707+
int family;
707708
int err;
708709

709-
switch (x->outer_mode.family) {
710+
family = (x->xso.type != XFRM_DEV_OFFLOAD_PACKET) ? x->outer_mode.family
711+
: skb_dst(skb)->ops->family;
712+
713+
switch (family) {
710714
case AF_INET:
711715
memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
712716
IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED;

net/xfrm/xfrm_policy.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,9 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
26942694
if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m)
26952695
mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);
26962696

2697-
family = xfrm[i]->props.family;
2697+
if (xfrm[i]->xso.type != XFRM_DEV_OFFLOAD_PACKET)
2698+
family = xfrm[i]->props.family;
2699+
26982700
oif = fl->flowi_oif ? : fl->flowi_l3mdev;
26992701
dst = xfrm_dst_lookup(xfrm[i], tos, oif,
27002702
&saddr, &daddr, family, mark);
@@ -3416,7 +3418,7 @@ decode_session4(const struct xfrm_flow_keys *flkeys, struct flowi *fl, bool reve
34163418
}
34173419

34183420
fl4->flowi4_proto = flkeys->basic.ip_proto;
3419-
fl4->flowi4_tos = flkeys->ip.tos;
3421+
fl4->flowi4_tos = flkeys->ip.tos & ~INET_ECN_MASK;
34203422
}
34213423

34223424
#if IS_ENABLED(CONFIG_IPV6)

net/xfrm/xfrm_user.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2017,6 +2017,9 @@ static int copy_to_user_tmpl(struct xfrm_policy *xp, struct sk_buff *skb)
20172017
if (xp->xfrm_nr == 0)
20182018
return 0;
20192019

2020+
if (xp->xfrm_nr > XFRM_MAX_DEPTH)
2021+
return -ENOBUFS;
2022+
20202023
for (i = 0; i < xp->xfrm_nr; i++) {
20212024
struct xfrm_user_tmpl *up = &vec[i];
20222025
struct xfrm_tmpl *kp = &xp->xfrm_vec[i];

0 commit comments

Comments
 (0)