@@ -4269,6 +4269,17 @@ EXPORT_SYMBOL(security_ib_free_security);
42694269
42704270#ifdef CONFIG_SECURITY_NETWORK_XFRM
42714271
4272+ /**
4273+ * security_xfrm_policy_alloc() - Allocate a xfrm policy LSM blob
4274+ * @ctxp: xfrm security context being added to the SPD
4275+ * @sec_ctx: security label provided by userspace
4276+ * @gfp: gfp flags
4277+ *
4278+ * Allocate a security structure to the xp->security field; the security field
4279+ * is initialized to NULL when the xfrm_policy is allocated.
4280+ *
4281+ * Return: Return 0 if operation was successful.
4282+ */
42724283int security_xfrm_policy_alloc (struct xfrm_sec_ctx * * ctxp ,
42734284 struct xfrm_user_sec_ctx * sec_ctx ,
42744285 gfp_t gfp )
@@ -4277,52 +4288,135 @@ int security_xfrm_policy_alloc(struct xfrm_sec_ctx **ctxp,
42774288}
42784289EXPORT_SYMBOL (security_xfrm_policy_alloc );
42794290
4291+ /**
4292+ * security_xfrm_policy_clone() - Clone xfrm policy LSM state
4293+ * @old_ctx: xfrm security context
4294+ * @new_ctxp: target xfrm security context
4295+ *
4296+ * Allocate a security structure in new_ctxp that contains the information from
4297+ * the old_ctx structure.
4298+ *
4299+ * Return: Return 0 if operation was successful.
4300+ */
42804301int security_xfrm_policy_clone (struct xfrm_sec_ctx * old_ctx ,
42814302 struct xfrm_sec_ctx * * new_ctxp )
42824303{
42834304 return call_int_hook (xfrm_policy_clone_security , 0 , old_ctx , new_ctxp );
42844305}
42854306
4307+ /**
4308+ * security_xfrm_policy_free() - Free a xfrm security context
4309+ * @ctx: xfrm security context
4310+ *
4311+ * Free LSM resources associated with @ctx.
4312+ */
42864313void security_xfrm_policy_free (struct xfrm_sec_ctx * ctx )
42874314{
42884315 call_void_hook (xfrm_policy_free_security , ctx );
42894316}
42904317EXPORT_SYMBOL (security_xfrm_policy_free );
42914318
4319+ /**
4320+ * security_xfrm_policy_delete() - Check if deleting a xfrm policy is allowed
4321+ * @ctx: xfrm security context
4322+ *
4323+ * Authorize deletion of a SPD entry.
4324+ *
4325+ * Return: Returns 0 if permission is granted.
4326+ */
42924327int security_xfrm_policy_delete (struct xfrm_sec_ctx * ctx )
42934328{
42944329 return call_int_hook (xfrm_policy_delete_security , 0 , ctx );
42954330}
42964331
4332+ /**
4333+ * security_xfrm_state_alloc() - Allocate a xfrm state LSM blob
4334+ * @x: xfrm state being added to the SAD
4335+ * @sec_ctx: security label provided by userspace
4336+ *
4337+ * Allocate a security structure to the @x->security field; the security field
4338+ * is initialized to NULL when the xfrm_state is allocated. Set the context to
4339+ * correspond to @sec_ctx.
4340+ *
4341+ * Return: Return 0 if operation was successful.
4342+ */
42974343int security_xfrm_state_alloc (struct xfrm_state * x ,
42984344 struct xfrm_user_sec_ctx * sec_ctx )
42994345{
43004346 return call_int_hook (xfrm_state_alloc , 0 , x , sec_ctx );
43014347}
43024348EXPORT_SYMBOL (security_xfrm_state_alloc );
43034349
4350+ /**
4351+ * security_xfrm_state_alloc_acquire() - Allocate a xfrm state LSM blob
4352+ * @x: xfrm state being added to the SAD
4353+ * @polsec: associated policy's security context
4354+ * @secid: secid from the flow
4355+ *
4356+ * Allocate a security structure to the x->security field; the security field
4357+ * is initialized to NULL when the xfrm_state is allocated. Set the context to
4358+ * correspond to secid.
4359+ *
4360+ * Return: Returns 0 if operation was successful.
4361+ */
43044362int security_xfrm_state_alloc_acquire (struct xfrm_state * x ,
43054363 struct xfrm_sec_ctx * polsec , u32 secid )
43064364{
43074365 return call_int_hook (xfrm_state_alloc_acquire , 0 , x , polsec , secid );
43084366}
43094367
4368+ /**
4369+ * security_xfrm_state_delete() - Check if deleting a xfrm state is allowed
4370+ * @x: xfrm state
4371+ *
4372+ * Authorize deletion of x->security.
4373+ *
4374+ * Return: Returns 0 if permission is granted.
4375+ */
43104376int security_xfrm_state_delete (struct xfrm_state * x )
43114377{
43124378 return call_int_hook (xfrm_state_delete_security , 0 , x );
43134379}
43144380EXPORT_SYMBOL (security_xfrm_state_delete );
43154381
4382+ /**
4383+ * security_xfrm_state_free() - Free a xfrm state
4384+ * @x: xfrm state
4385+ *
4386+ * Deallocate x->security.
4387+ */
43164388void security_xfrm_state_free (struct xfrm_state * x )
43174389{
43184390 call_void_hook (xfrm_state_free_security , x );
43194391}
43204392
4393+ /**
4394+ * security_xfrm_policy_lookup() - Check if using a xfrm policy is allowed
4395+ * @ctx: target xfrm security context
4396+ * @fl_secid: flow secid used to authorize access
4397+ *
4398+ * Check permission when a flow selects a xfrm_policy for processing XFRMs on a
4399+ * packet. The hook is called when selecting either a per-socket policy or a
4400+ * generic xfrm policy.
4401+ *
4402+ * Return: Return 0 if permission is granted, -ESRCH otherwise, or -errno on
4403+ * other errors.
4404+ */
43214405int security_xfrm_policy_lookup (struct xfrm_sec_ctx * ctx , u32 fl_secid )
43224406{
43234407 return call_int_hook (xfrm_policy_lookup , 0 , ctx , fl_secid );
43244408}
43254409
4410+ /**
4411+ * security_xfrm_state_pol_flow_match() - Check for a xfrm match
4412+ * @x: xfrm state to match
4413+ * @xp xfrm policy to check for a match
4414+ * @flic: flow to check for a match.
4415+ *
4416+ * Check @xp and @flic for a match with @x.
4417+ *
4418+ * Return: Returns 1 if there is a match.
4419+ */
43264420int security_xfrm_state_pol_flow_match (struct xfrm_state * x ,
43274421 struct xfrm_policy * xp ,
43284422 const struct flowi_common * flic )
@@ -4347,6 +4441,15 @@ int security_xfrm_state_pol_flow_match(struct xfrm_state *x,
43474441 return rc ;
43484442}
43494443
4444+ /**
4445+ * security_xfrm_decode_session() - Determine the xfrm secid for a packet
4446+ * @skb: xfrm packet
4447+ * @secid: secid
4448+ *
4449+ * Decode the packet in @skb and return the security label in @secid.
4450+ *
4451+ * Return: Return 0 if all xfrms used have the same secid.
4452+ */
43504453int security_xfrm_decode_session (struct sk_buff * skb , u32 * secid )
43514454{
43524455 return call_int_hook (xfrm_decode_session , 0 , skb , secid , 1 );
0 commit comments