aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm')
-rw-r--r--net/xfrm/xfrm_algo.c2
-rw-r--r--net/xfrm/xfrm_input.c14
-rw-r--r--net/xfrm/xfrm_policy.c4
-rw-r--r--net/xfrm/xfrm_state.c1
-rw-r--r--net/xfrm/xfrm_user.c22
5 files changed, 23 insertions, 20 deletions
diff --git a/net/xfrm/xfrm_algo.c b/net/xfrm/xfrm_algo.c
index 250e567ba3d6..44ac85fe2bc9 100644
--- a/net/xfrm/xfrm_algo.c
+++ b/net/xfrm/xfrm_algo.c
@@ -17,7 +17,7 @@
17#include <linux/crypto.h> 17#include <linux/crypto.h>
18#include <linux/scatterlist.h> 18#include <linux/scatterlist.h>
19#include <net/xfrm.h> 19#include <net/xfrm.h>
20#if defined(CONFIG_INET_ESP) || defined(CONFIG_INET_ESP_MODULE) || defined(CONFIG_INET6_ESP) || defined(CONFIG_INET6_ESP_MODULE) 20#if IS_ENABLED(CONFIG_INET_ESP) || IS_ENABLED(CONFIG_INET6_ESP)
21#include <net/esp.h> 21#include <net/esp.h>
22#endif 22#endif
23 23
diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c
index 1c4ad477ce93..6e3f0254d8a1 100644
--- a/net/xfrm/xfrm_input.c
+++ b/net/xfrm/xfrm_input.c
@@ -207,15 +207,15 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be32 spi, int encap_type)
207 family = XFRM_SPI_SKB_CB(skb)->family; 207 family = XFRM_SPI_SKB_CB(skb)->family;
208 208
209 /* if tunnel is present override skb->mark value with tunnel i_key */ 209 /* if tunnel is present override skb->mark value with tunnel i_key */
210 if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4) { 210 switch (family) {
211 switch (family) { 211 case AF_INET:
212 case AF_INET: 212 if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4)
213 mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key); 213 mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip4->parms.i_key);
214 break; 214 break;
215 case AF_INET6: 215 case AF_INET6:
216 if (XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6)
216 mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key); 217 mark = be32_to_cpu(XFRM_TUNNEL_SKB_CB(skb)->tunnel.ip6->parms.i_key);
217 break; 218 break;
218 }
219 } 219 }
220 220
221 /* Allocate new secpath or COW existing one. */ 221 /* Allocate new secpath or COW existing one. */
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index f7ce6265961a..fd6986634e6f 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -643,6 +643,10 @@ static void xfrm_hash_rebuild(struct work_struct *work)
643 643
644 /* re-insert all policies by order of creation */ 644 /* re-insert all policies by order of creation */
645 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { 645 list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
646 if (xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {
647 /* skip socket policies */
648 continue;
649 }
646 newpos = NULL; 650 newpos = NULL;
647 chain = policy_hash_bysel(net, &policy->selector, 651 chain = policy_hash_bysel(net, &policy->selector,
648 policy->family, 652 policy->family,
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index a38fdead38ea..419bf5d463bd 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -350,6 +350,7 @@ static void xfrm_state_gc_destroy(struct xfrm_state *x)
350{ 350{
351 tasklet_hrtimer_cancel(&x->mtimer); 351 tasklet_hrtimer_cancel(&x->mtimer);
352 del_timer_sync(&x->rtimer); 352 del_timer_sync(&x->rtimer);
353 kfree(x->aead);
353 kfree(x->aalg); 354 kfree(x->aalg);
354 kfree(x->ealg); 355 kfree(x->ealg);
355 kfree(x->calg); 356 kfree(x->calg);
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index d516845e16e3..08892091cfe3 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -581,9 +581,12 @@ static struct xfrm_state *xfrm_state_construct(struct net *net,
581 if (err) 581 if (err)
582 goto error; 582 goto error;
583 583
584 if (attrs[XFRMA_SEC_CTX] && 584 if (attrs[XFRMA_SEC_CTX]) {
585 security_xfrm_state_alloc(x, nla_data(attrs[XFRMA_SEC_CTX]))) 585 err = security_xfrm_state_alloc(x,
586 goto error; 586 nla_data(attrs[XFRMA_SEC_CTX]));
587 if (err)
588 goto error;
589 }
587 590
588 if ((err = xfrm_alloc_replay_state_esn(&x->replay_esn, &x->preplay_esn, 591 if ((err = xfrm_alloc_replay_state_esn(&x->replay_esn, &x->preplay_esn,
589 attrs[XFRMA_REPLAY_ESN_VAL]))) 592 attrs[XFRMA_REPLAY_ESN_VAL])))
@@ -896,7 +899,8 @@ static int xfrm_dump_sa_done(struct netlink_callback *cb)
896 struct sock *sk = cb->skb->sk; 899 struct sock *sk = cb->skb->sk;
897 struct net *net = sock_net(sk); 900 struct net *net = sock_net(sk);
898 901
899 xfrm_state_walk_done(walk, net); 902 if (cb->args[0])
903 xfrm_state_walk_done(walk, net);
900 return 0; 904 return 0;
901} 905}
902 906
@@ -921,8 +925,6 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
921 u8 proto = 0; 925 u8 proto = 0;
922 int err; 926 int err;
923 927
924 cb->args[0] = 1;
925
926 err = nlmsg_parse(cb->nlh, 0, attrs, XFRMA_MAX, 928 err = nlmsg_parse(cb->nlh, 0, attrs, XFRMA_MAX,
927 xfrma_policy); 929 xfrma_policy);
928 if (err < 0) 930 if (err < 0)
@@ -939,6 +941,7 @@ static int xfrm_dump_sa(struct sk_buff *skb, struct netlink_callback *cb)
939 proto = nla_get_u8(attrs[XFRMA_PROTO]); 941 proto = nla_get_u8(attrs[XFRMA_PROTO]);
940 942
941 xfrm_state_walk_init(walk, proto, filter); 943 xfrm_state_walk_init(walk, proto, filter);
944 cb->args[0] = 1;
942 } 945 }
943 946
944 (void) xfrm_state_walk(net, walk, dump_one_state, &info); 947 (void) xfrm_state_walk(net, walk, dump_one_state, &info);
@@ -2051,9 +2054,6 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
2051 if (up->hard) { 2054 if (up->hard) {
2052 xfrm_policy_delete(xp, p->dir); 2055 xfrm_policy_delete(xp, p->dir);
2053 xfrm_audit_policy_delete(xp, 1, true); 2056 xfrm_audit_policy_delete(xp, 1, true);
2054 } else {
2055 // reset the timers here?
2056 WARN(1, "Don't know what to do with soft policy expire\n");
2057 } 2057 }
2058 km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid); 2058 km_policy_expired(xp, p->dir, up->hard, nlh->nlmsg_pid);
2059 2059
@@ -2117,7 +2117,7 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
2117 2117
2118 err = verify_newpolicy_info(&ua->policy); 2118 err = verify_newpolicy_info(&ua->policy);
2119 if (err) 2119 if (err)
2120 goto bad_policy; 2120 goto free_state;
2121 2121
2122 /* build an XP */ 2122 /* build an XP */
2123 xp = xfrm_policy_construct(net, &ua->policy, attrs, &err); 2123 xp = xfrm_policy_construct(net, &ua->policy, attrs, &err);
@@ -2149,8 +2149,6 @@ static int xfrm_add_acquire(struct sk_buff *skb, struct nlmsghdr *nlh,
2149 2149
2150 return 0; 2150 return 0;
2151 2151
2152bad_policy:
2153 WARN(1, "BAD policy passed\n");
2154free_state: 2152free_state:
2155 kfree(x); 2153 kfree(x);
2156nomem: 2154nomem: