hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/security/selinux/xfrm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * NSA Security-Enhanced Linux (SELinux) security module
34 *
....@@ -12,10 +13,6 @@
1213 *
1314 * Copyright (C) 2005 International Business Machines Corporation
1415 * Copyright (C) 2006 Trusted Computer Solutions, Inc.
15
- *
16
- * This program is free software; you can redistribute it and/or modify
17
- * it under the terms of the GNU General Public License version 2,
18
- * as published by the Free Software Foundation.
1916 */
2017
2118 /*
....@@ -79,7 +76,7 @@
7976 gfp_t gfp)
8077 {
8178 int rc;
82
- const struct task_security_struct *tsec = current_security();
79
+ const struct task_security_struct *tsec = selinux_cred(current_cred());
8380 struct xfrm_sec_ctx *ctx = NULL;
8481 u32 str_len;
8582
....@@ -138,7 +135,7 @@
138135 */
139136 static int selinux_xfrm_delete(struct xfrm_sec_ctx *ctx)
140137 {
141
- const struct task_security_struct *tsec = current_security();
138
+ const struct task_security_struct *tsec = selinux_cred(current_cred());
142139
143140 if (!ctx)
144141 return 0;
....@@ -178,9 +175,10 @@
178175 */
179176 int selinux_xfrm_state_pol_flow_match(struct xfrm_state *x,
180177 struct xfrm_policy *xp,
181
- const struct flowi *fl)
178
+ const struct flowi_common *flic)
182179 {
183180 u32 state_sid;
181
+ u32 flic_sid;
184182
185183 if (!xp->security)
186184 if (x->security)
....@@ -199,17 +197,17 @@
199197 return 0;
200198
201199 state_sid = x->security->ctx_sid;
200
+ flic_sid = flic->flowic_secid;
202201
203
- if (fl->flowi_secid != state_sid)
202
+ if (flic_sid != state_sid)
204203 return 0;
205204
206205 /* We don't need a separate SA Vs. policy polmatch check since the SA
207206 * is now of the same label as the flow and a flow Vs. policy polmatch
208207 * check had already happened in selinux_xfrm_policy_lookup() above. */
209
- return (avc_has_perm(&selinux_state,
210
- fl->flowi_secid, state_sid,
211
- SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO,
212
- NULL) ? 0 : 1);
208
+ return (avc_has_perm(&selinux_state, flic_sid, state_sid,
209
+ SECCLASS_ASSOCIATION, ASSOCIATION__SENDTO,
210
+ NULL) ? 0 : 1);
213211 }
214212
215213 static u32 selinux_xfrm_skb_sid_egress(struct sk_buff *skb)
....@@ -230,7 +228,7 @@
230228 u32 *sid, int ckall)
231229 {
232230 u32 sid_session = SECSID_NULL;
233
- struct sec_path *sp = skb->sp;
231
+ struct sec_path *sp = skb_sec_path(skb);
234232
235233 if (sp) {
236234 int i;
....@@ -349,7 +347,7 @@
349347 int rc;
350348 struct xfrm_sec_ctx *ctx;
351349 char *ctx_str = NULL;
352
- int str_len;
350
+ u32 str_len;
353351
354352 if (!polsec)
355353 return 0;
....@@ -408,7 +406,7 @@
408406 struct common_audit_data *ad)
409407 {
410408 int i;
411
- struct sec_path *sp = skb->sp;
409
+ struct sec_path *sp = skb_sec_path(skb);
412410 u32 peer_sid = SECINITSID_UNLABELED;
413411
414412 if (sp) {