aboutsummaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_user.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/xfrm/xfrm_user.c')
-rw-r--r--net/xfrm/xfrm_user.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 956cfe0ff7f8..96789952f6a3 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -530,9 +530,6 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
530 530
531 err = xfrm_state_delete(x); 531 err = xfrm_state_delete(x);
532 532
533 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
534 AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
535
536 if (err < 0) 533 if (err < 0)
537 goto out; 534 goto out;
538 535
@@ -542,6 +539,8 @@ static int xfrm_del_sa(struct sk_buff *skb, struct nlmsghdr *nlh,
542 km_state_notify(x, &c); 539 km_state_notify(x, &c);
543 540
544out: 541out:
542 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
543 AUDIT_MAC_IPSEC_DELSA, err ? 0 : 1, NULL, x);
545 xfrm_state_put(x); 544 xfrm_state_put(x);
546 return err; 545 return err;
547} 546}
@@ -1254,7 +1253,7 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
1254 return err; 1253 return err;
1255 1254
1256 if (p->index) 1255 if (p->index)
1257 xp = xfrm_policy_byid(type, p->dir, p->index, delete); 1256 xp = xfrm_policy_byid(type, p->dir, p->index, delete, &err);
1258 else { 1257 else {
1259 struct rtattr *rt = xfrma[XFRMA_SEC_CTX-1]; 1258 struct rtattr *rt = xfrma[XFRMA_SEC_CTX-1];
1260 struct xfrm_policy tmp; 1259 struct xfrm_policy tmp;
@@ -1270,7 +1269,8 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
1270 if ((err = security_xfrm_policy_alloc(&tmp, uctx))) 1269 if ((err = security_xfrm_policy_alloc(&tmp, uctx)))
1271 return err; 1270 return err;
1272 } 1271 }
1273 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, delete); 1272 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security,
1273 delete, &err);
1274 security_xfrm_policy_free(&tmp); 1274 security_xfrm_policy_free(&tmp);
1275 } 1275 }
1276 if (xp == NULL) 1276 if (xp == NULL)
@@ -1288,8 +1288,6 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
1288 MSG_DONTWAIT); 1288 MSG_DONTWAIT);
1289 } 1289 }
1290 } else { 1290 } else {
1291 err = security_xfrm_policy_delete(xp);
1292
1293 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid, 1291 xfrm_audit_log(NETLINK_CB(skb).loginuid, NETLINK_CB(skb).sid,
1294 AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL); 1292 AUDIT_MAC_IPSEC_DELSPD, err ? 0 : 1, xp, NULL);
1295 1293
@@ -1303,9 +1301,8 @@ static int xfrm_get_policy(struct sk_buff *skb, struct nlmsghdr *nlh,
1303 km_policy_notify(xp, p->dir, &c); 1301 km_policy_notify(xp, p->dir, &c);
1304 } 1302 }
1305 1303
1306 xfrm_pol_put(xp);
1307
1308out: 1304out:
1305 xfrm_pol_put(xp);
1309 return err; 1306 return err;
1310} 1307}
1311 1308
@@ -1502,7 +1499,7 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
1502 return err; 1499 return err;
1503 1500
1504 if (p->index) 1501 if (p->index)
1505 xp = xfrm_policy_byid(type, p->dir, p->index, 0); 1502 xp = xfrm_policy_byid(type, p->dir, p->index, 0, &err);
1506 else { 1503 else {
1507 struct rtattr *rt = xfrma[XFRMA_SEC_CTX-1]; 1504 struct rtattr *rt = xfrma[XFRMA_SEC_CTX-1];
1508 struct xfrm_policy tmp; 1505 struct xfrm_policy tmp;
@@ -1518,13 +1515,14 @@ static int xfrm_add_pol_expire(struct sk_buff *skb, struct nlmsghdr *nlh,
1518 if ((err = security_xfrm_policy_alloc(&tmp, uctx))) 1515 if ((err = security_xfrm_policy_alloc(&tmp, uctx)))
1519 return err; 1516 return err;
1520 } 1517 }
1521 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security, 0); 1518 xp = xfrm_policy_bysel_ctx(type, p->dir, &p->sel, tmp.security,
1519 0, &err);
1522 security_xfrm_policy_free(&tmp); 1520 security_xfrm_policy_free(&tmp);
1523 } 1521 }
1524 1522
1525 if (xp == NULL) 1523 if (xp == NULL)
1526 return err; 1524 return -ENOENT;
1527 read_lock(&xp->lock); 1525 read_lock(&xp->lock);
1528 if (xp->dead) { 1526 if (xp->dead) {
1529 read_unlock(&xp->lock); 1527 read_unlock(&xp->lock);
1530 goto out; 1528 goto out;