diff options
author | Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> | 2014-04-18 03:23:46 -0400 |
---|---|---|
committer | Steffen Klassert <steffen.klassert@secunet.com> | 2014-04-22 04:47:53 -0400 |
commit | f1370cc4a01e61007ab3020c761cef6b88ae3729 (patch) | |
tree | bee103f4c6398b978b47b1b6bba8e097c1e332aa /net/xfrm/xfrm_policy.c | |
parent | 5a9d19ab76f98b7cdc97ba9724be01deba791bc0 (diff) |
xfrm: Remove useless secid field from xfrm_audit.
It seems to me that commit ab5f5e8b "[XFRM]: xfrm audit calls" is doing
something strange at xfrm_audit_helper_usrinfo().
If secid != 0 && security_secid_to_secctx(secid) != 0, the caller calls
audit_log_task_context() which basically does
secid != 0 && security_secid_to_secctx(secid) == 0 case
except that secid is obtained from current thread's context.
Oh, what happens if secid passed to xfrm_audit_helper_usrinfo() was
obtained from other thread's context? It might audit current thread's
context rather than other thread's context if security_secid_to_secctx()
in xfrm_audit_helper_usrinfo() failed for some reason.
Then, are all the caller of xfrm_audit_helper_usrinfo() passing either
secid obtained from current thread's context or secid == 0?
It seems to me that they are.
If I didn't miss something, we don't need to pass secid to
xfrm_audit_helper_usrinfo() because audit_log_task_context() will
obtain secid from current thread's context.
Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
Diffstat (limited to 'net/xfrm/xfrm_policy.c')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index c08fbd11ceff..bd001b7062c0 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -785,8 +785,7 @@ xfrm_policy_flush_secctx_check(struct net *net, u8 type, struct xfrm_audit *audi | |||
785 | if (err) { | 785 | if (err) { |
786 | xfrm_audit_policy_delete(pol, 0, | 786 | xfrm_audit_policy_delete(pol, 0, |
787 | audit_info->loginuid, | 787 | audit_info->loginuid, |
788 | audit_info->sessionid, | 788 | audit_info->sessionid); |
789 | audit_info->secid); | ||
790 | return err; | 789 | return err; |
791 | } | 790 | } |
792 | } | 791 | } |
@@ -801,8 +800,7 @@ xfrm_policy_flush_secctx_check(struct net *net, u8 type, struct xfrm_audit *audi | |||
801 | if (err) { | 800 | if (err) { |
802 | xfrm_audit_policy_delete(pol, 0, | 801 | xfrm_audit_policy_delete(pol, 0, |
803 | audit_info->loginuid, | 802 | audit_info->loginuid, |
804 | audit_info->sessionid, | 803 | audit_info->sessionid); |
805 | audit_info->secid); | ||
806 | return err; | 804 | return err; |
807 | } | 805 | } |
808 | } | 806 | } |
@@ -842,8 +840,7 @@ int xfrm_policy_flush(struct net *net, u8 type, struct xfrm_audit *audit_info) | |||
842 | cnt++; | 840 | cnt++; |
843 | 841 | ||
844 | xfrm_audit_policy_delete(pol, 1, audit_info->loginuid, | 842 | xfrm_audit_policy_delete(pol, 1, audit_info->loginuid, |
845 | audit_info->sessionid, | 843 | audit_info->sessionid); |
846 | audit_info->secid); | ||
847 | 844 | ||
848 | xfrm_policy_kill(pol); | 845 | xfrm_policy_kill(pol); |
849 | 846 | ||
@@ -864,8 +861,7 @@ int xfrm_policy_flush(struct net *net, u8 type, struct xfrm_audit *audit_info) | |||
864 | 861 | ||
865 | xfrm_audit_policy_delete(pol, 1, | 862 | xfrm_audit_policy_delete(pol, 1, |
866 | audit_info->loginuid, | 863 | audit_info->loginuid, |
867 | audit_info->sessionid, | 864 | audit_info->sessionid); |
868 | audit_info->secid); | ||
869 | xfrm_policy_kill(pol); | 865 | xfrm_policy_kill(pol); |
870 | 866 | ||
871 | write_lock_bh(&net->xfrm.xfrm_policy_lock); | 867 | write_lock_bh(&net->xfrm.xfrm_policy_lock); |
@@ -2870,12 +2866,10 @@ static void xfrm_policy_fini(struct net *net) | |||
2870 | #ifdef CONFIG_XFRM_SUB_POLICY | 2866 | #ifdef CONFIG_XFRM_SUB_POLICY |
2871 | audit_info.loginuid = INVALID_UID; | 2867 | audit_info.loginuid = INVALID_UID; |
2872 | audit_info.sessionid = (unsigned int)-1; | 2868 | audit_info.sessionid = (unsigned int)-1; |
2873 | audit_info.secid = 0; | ||
2874 | xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, &audit_info); | 2869 | xfrm_policy_flush(net, XFRM_POLICY_TYPE_SUB, &audit_info); |
2875 | #endif | 2870 | #endif |
2876 | audit_info.loginuid = INVALID_UID; | 2871 | audit_info.loginuid = INVALID_UID; |
2877 | audit_info.sessionid = (unsigned int)-1; | 2872 | audit_info.sessionid = (unsigned int)-1; |
2878 | audit_info.secid = 0; | ||
2879 | xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, &audit_info); | 2873 | xfrm_policy_flush(net, XFRM_POLICY_TYPE_MAIN, &audit_info); |
2880 | 2874 | ||
2881 | WARN_ON(!list_empty(&net->xfrm.policy_all)); | 2875 | WARN_ON(!list_empty(&net->xfrm.policy_all)); |
@@ -2992,14 +2986,14 @@ static void xfrm_audit_common_policyinfo(struct xfrm_policy *xp, | |||
2992 | } | 2986 | } |
2993 | 2987 | ||
2994 | void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | 2988 | void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, |
2995 | kuid_t auid, unsigned int sessionid, u32 secid) | 2989 | kuid_t auid, unsigned int sessionid) |
2996 | { | 2990 | { |
2997 | struct audit_buffer *audit_buf; | 2991 | struct audit_buffer *audit_buf; |
2998 | 2992 | ||
2999 | audit_buf = xfrm_audit_start("SPD-add"); | 2993 | audit_buf = xfrm_audit_start("SPD-add"); |
3000 | if (audit_buf == NULL) | 2994 | if (audit_buf == NULL) |
3001 | return; | 2995 | return; |
3002 | xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); | 2996 | xfrm_audit_helper_usrinfo(auid, sessionid, audit_buf); |
3003 | audit_log_format(audit_buf, " res=%u", result); | 2997 | audit_log_format(audit_buf, " res=%u", result); |
3004 | xfrm_audit_common_policyinfo(xp, audit_buf); | 2998 | xfrm_audit_common_policyinfo(xp, audit_buf); |
3005 | audit_log_end(audit_buf); | 2999 | audit_log_end(audit_buf); |
@@ -3007,14 +3001,14 @@ void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, | |||
3007 | EXPORT_SYMBOL_GPL(xfrm_audit_policy_add); | 3001 | EXPORT_SYMBOL_GPL(xfrm_audit_policy_add); |
3008 | 3002 | ||
3009 | void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, | 3003 | void xfrm_audit_policy_delete(struct xfrm_policy *xp, int result, |
3010 | kuid_t auid, unsigned int sessionid, u32 secid) | 3004 | kuid_t auid, unsigned int sessionid) |
3011 | { | 3005 | { |
3012 | struct audit_buffer *audit_buf; | 3006 | struct audit_buffer *audit_buf; |
3013 | 3007 | ||
3014 | audit_buf = xfrm_audit_start("SPD-delete"); | 3008 | audit_buf = xfrm_audit_start("SPD-delete"); |
3015 | if (audit_buf == NULL) | 3009 | if (audit_buf == NULL) |
3016 | return; | 3010 | return; |
3017 | xfrm_audit_helper_usrinfo(auid, sessionid, secid, audit_buf); | 3011 | xfrm_audit_helper_usrinfo(auid, sessionid, audit_buf); |
3018 | audit_log_format(audit_buf, " res=%u", result); | 3012 | audit_log_format(audit_buf, " res=%u", result); |
3019 | xfrm_audit_common_policyinfo(xp, audit_buf); | 3013 | xfrm_audit_common_policyinfo(xp, audit_buf); |
3020 | audit_log_end(audit_buf); | 3014 | audit_log_end(audit_buf); |