aboutsummaryrefslogtreecommitdiffstats
path: root/net/key
diff options
context:
space:
mode:
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 1a04c1329362..1526023f99ed 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -433,12 +433,13 @@ static inline int verify_sec_ctx_len(const void *p)
433 return 0; 433 return 0;
434} 434}
435 435
436static inline struct xfrm_user_sec_ctx *pfkey_sadb2xfrm_user_sec_ctx(const struct sadb_x_sec_ctx *sec_ctx) 436static inline struct xfrm_user_sec_ctx *pfkey_sadb2xfrm_user_sec_ctx(const struct sadb_x_sec_ctx *sec_ctx,
437 gfp_t gfp)
437{ 438{
438 struct xfrm_user_sec_ctx *uctx = NULL; 439 struct xfrm_user_sec_ctx *uctx = NULL;
439 int ctx_size = sec_ctx->sadb_x_ctx_len; 440 int ctx_size = sec_ctx->sadb_x_ctx_len;
440 441
441 uctx = kmalloc((sizeof(*uctx)+ctx_size), GFP_KERNEL); 442 uctx = kmalloc((sizeof(*uctx)+ctx_size), gfp);
442 443
443 if (!uctx) 444 if (!uctx)
444 return NULL; 445 return NULL;
@@ -1124,7 +1125,7 @@ static struct xfrm_state * pfkey_msg2xfrm_state(struct net *net,
1124 1125
1125 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1]; 1126 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1];
1126 if (sec_ctx != NULL) { 1127 if (sec_ctx != NULL) {
1127 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); 1128 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx, GFP_KERNEL);
1128 1129
1129 if (!uctx) 1130 if (!uctx)
1130 goto out; 1131 goto out;
@@ -2231,7 +2232,7 @@ static int pfkey_spdadd(struct sock *sk, struct sk_buff *skb, const struct sadb_
2231 2232
2232 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1]; 2233 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1];
2233 if (sec_ctx != NULL) { 2234 if (sec_ctx != NULL) {
2234 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); 2235 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx, GFP_KERNEL);
2235 2236
2236 if (!uctx) { 2237 if (!uctx) {
2237 err = -ENOBUFS; 2238 err = -ENOBUFS;
@@ -2335,7 +2336,7 @@ static int pfkey_spddelete(struct sock *sk, struct sk_buff *skb, const struct sa
2335 2336
2336 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1]; 2337 sec_ctx = ext_hdrs[SADB_X_EXT_SEC_CTX - 1];
2337 if (sec_ctx != NULL) { 2338 if (sec_ctx != NULL) {
2338 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); 2339 struct xfrm_user_sec_ctx *uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx, GFP_KERNEL);
2339 2340
2340 if (!uctx) 2341 if (!uctx)
2341 return -ENOMEM; 2342 return -ENOMEM;
@@ -3239,7 +3240,7 @@ static struct xfrm_policy *pfkey_compile_policy(struct sock *sk, int opt,
3239 } 3240 }
3240 if ((*dir = verify_sec_ctx_len(p))) 3241 if ((*dir = verify_sec_ctx_len(p)))
3241 goto out; 3242 goto out;
3242 uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx); 3243 uctx = pfkey_sadb2xfrm_user_sec_ctx(sec_ctx, GFP_ATOMIC);
3243 *dir = security_xfrm_policy_alloc(&xp->security, uctx); 3244 *dir = security_xfrm_policy_alloc(&xp->security, uctx);
3244 kfree(uctx); 3245 kfree(uctx);
3245 3246