diff options
author | Eric Paris <eparis@redhat.com> | 2007-03-07 18:37:58 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-03-07 19:08:09 -0500 |
commit | ef41aaa0b755f479012341ac11db9ca5b8928d98 (patch) | |
tree | f5cd83b9117d0092f40006fbf4fd1f39652ad925 /include | |
parent | 05e52dd7396514648fba6c275eb7b49eca333c6d (diff) |
[IPSEC]: xfrm_policy delete security check misplaced
The security hooks to check permissions to remove an xfrm_policy were
actually done after the policy was removed. Since the unlinking and
deletion are done in xfrm_policy_by* functions this moves the hooks
inside those 2 functions. There we have all the information needed to
do the security check and it can be done before the deletion. Since
auditing requires the result of that security check err has to be passed
back and forth from the xfrm_policy_by* functions.
This patch also fixes a bug where a deletion that failed the security
check could cause improper accounting on the xfrm_policy
(xfrm_get_policy didn't have a put on the exit path for the hold taken
by xfrm_policy_by*)
It also fixes the return code when no policy is found in
xfrm_add_pol_expire. In old code (at least back in the 2.6.18 days) err
wasn't used before the return when no policy is found and so the
initialization would cause err to be ENOENT. But since err has since
been used above when we don't get a policy back from the xfrm_policy_by*
function we would always return 0 instead of the intended ENOENT. Also
fixed some white space damage in the same area.
Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Venkat Yekkirala <vyekkirala@trustedcs.com>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/net/xfrm.h | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 92a1fc46ea59..5a00aa85b756 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -988,8 +988,9 @@ extern int xfrm_policy_walk(u8 type, int (*func)(struct xfrm_policy *, int, int, | |||
988 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); | 988 | int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl); |
989 | struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, | 989 | struct xfrm_policy *xfrm_policy_bysel_ctx(u8 type, int dir, |
990 | struct xfrm_selector *sel, | 990 | struct xfrm_selector *sel, |
991 | struct xfrm_sec_ctx *ctx, int delete); | 991 | struct xfrm_sec_ctx *ctx, int delete, |
992 | struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete); | 992 | int *err); |
993 | struct xfrm_policy *xfrm_policy_byid(u8, int dir, u32 id, int delete, int *err); | ||
993 | void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info); | 994 | void xfrm_policy_flush(u8 type, struct xfrm_audit *audit_info); |
994 | u32 xfrm_get_acqseq(void); | 995 | u32 xfrm_get_acqseq(void); |
995 | void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi); | 996 | void xfrm_alloc_spi(struct xfrm_state *x, __be32 minspi, __be32 maxspi); |