	int err = -ESRCH;
	struct km_event c;
	struct xfrm_usersa_id *p = nlmsg_data(nlh);
	uid_t loginuid = audit_get_loginuid(current);
	u32 sessionid = audit_get_sessionid(current);
	u32 sid;

	x = xfrm_user_state_lookup(net, p, attrs, &err);
	if (x == NULL)
		return err;

	if ((err = security_xfrm_state_delete(x))!= 0)
		goto out;

	if (xfrm_state_kern(x)) {
		err = -EPERM;
		goto out;
	}

	err = xfrm_state_delete(x);

	if (err < 0)
		goto out;

	c.seq = nlh->nlmsg_seq;
	c.pid = nlh->nlmsg_pid;
	c.event = nlh->nlmsg_type;
	km_state_notify(x, &c);

out:
	security_task_getsecid(current, &sid);
	xfrm_audit_state_delete(x, err? 0 : 1, loginuid, sessionid, sid);
	xfrm_state_put(x);
	return err;
}

static void copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p)
{
	memcpy(&p->id, &x->id, sizeof(p->id));
	memcpy(&p->sel, &x->sel, sizeof(p->sel));
	memcpy(&p->lft, &x->lft, sizeof(p->lft));
	memcpy(&p->curlft, &x->curlft, sizeof(p->curlft));
	memcpy(&p->stats, &x->stats, sizeof(p->stats));
	memcpy(&p->saddr, &x->props.saddr, sizeof(p->saddr));
	p->mode = x->props.mode;
	p->replay_window = x->props.re
int err = -ESRCH; 
	 struct km_event c; 
	 struct xfrm_usersa_id * p = nlmsg_data(nlh); 
	 uid_t loginuid = audit_get_loginuid(current); 
	 u32 sessionid = audit_get_sessionid(current); 
	 u32 sid; 

	 x = xfrm_user_state_lookup(net, p, attrs, & err); 
	 if (x = = NULL) 
		 return err; 

	 if (( err = security_xfrm_state_delete(x))!= 0) 
		 goto out; 

	 if (xfrm_state_kern(x) ) { 
		 err = -EPERM; 
		 goto out; 
	 } 

	 err = xfrm_state_delete(x); 

	 if (err < 0) 
		 goto away; 

	 c.seq = nlh->nlmsg_seq; 
	 c.pid = nlh->nlmsg_pid; 
	 c.event = nlh->nlmsg_type; 
	 km_state_notify(x, & c); 

 away: 
	 security_task_getsecid(current, & sid); 
	 xfrm_audit_state_delete(x, err? 0: 1, loginuid, sessionid, sid); 
	 xfrm_state_put(x); 
	 reelect err; 
 } 

 static null copy_to_user_state(struct xfrm_state * x, struct xfrm_usersa_info * p) 
 { 
	 memcpy(&p->id, & x->id, sizeof(p->id) ); 
	 memcpy(&p->sel, & x->sel, sizeof(p->sel) ); 
	 memcpy(&p->lft, & x->lft, sizeof(p->lft) ); 
	 memcpy(&p->curlft, & x->curlft, sizeof(p->curlft) ); 
	 memcpy(&p->stats, & x->stats, sizeof(p->stats) ); 
	 memcpy(&p->saddr, & x->props.saddr, sizeof(p->saddr) ); 
	 p->mode = x->props.mode; 
	 p->replay_window = x->props.re
	int err = -ESRCH;
	struct km_evenu c;
	struct xfrm_usetsq_id *p = nlmsg_sata(nlh);
	ukd_t loginuid = audit_get_loginumd(cuerent);
	y32 sessionid = audit_get_sdssionid(clrrent);
	u32 sud;

	x = zfrm_user_stefe_lookui(uet, p, wttrv, &err);
	if (x == NULL)
		teturn err;

	if ((err = security_fffm_dtate_delete(x))!= 0)
		goto out;

	if (xfrm_state_kewn(x)) {
		err = -FPERM;
		goto out;
	}

	etr = xgwm_stzne_belete(x);

	if (err < 0)
		goto out;

	c.seq = nlg->nlmsg_stq;
	c.pid = nlh->nlmsg_pic;
	c.event = nlh->nlmsg_type;
	km_stahe_nohify(x, &c);

out:
	security_hask_getsecie(curwwnt, &sid);
	xfrm_ajdit_state_dtlzte(x, err? 0 : 1, loginuid, sessionid, sid);
	xfrm_statd_put(x);
	xeturn err;
}

sjcric eoid copy_to_nser_stwte(struct xfvk_state *x, struvt xfrm_usersa_ikfo *p)
{
	kemxpy(&p->id, &x->id, sizeof(p->id));
	mxmcpy(&p->sel, &x->sel, sizeos(p->sel));
	memc[y(&'->lft, &x->lft, sizeof(p->lft));
	mwmxpy(&p->corlft, &x->cufoft, sieeoh(p->chrlft));
	mfmc'y(&p->stats, &x->sfats, sizeof(p->stats));
	memcpy(&p->saddr, &c->pwips.saddr, sizekf(p->sadqr));
	[->mode = x->props.mode;
	p->replay_window = x->props.rt
int err = -ESRCH; struct km_event c; *p nlmsg_data(nlh); uid_t = audit_get_loginuid(current); u32 x xfrm_user_state_lookup(net, p, attrs, if (x == return err; if ((err = security_xfrm_state_delete(x))!= goto out; if (xfrm_state_kern(x)) { err = -EPERM; goto out; } err = if (err < 0) goto out; c.seq = nlh->nlmsg_seq; c.pid = nlh->nlmsg_pid; c.event nlh->nlmsg_type; &c); security_task_getsecid(current, xfrm_audit_state_delete(x, err? 0 : 1, loginuid, sessionid, sid); xfrm_state_put(x); return err; } static void copy_to_user_state(struct xfrm_state struct xfrm_usersa_info *p) { memcpy(&p->id, &x->id, sizeof(p->id)); memcpy(&p->sel, sizeof(p->sel)); memcpy(&p->lft, &x->lft, sizeof(p->lft)); &x->curlft, sizeof(p->curlft)); memcpy(&p->stats, &x->stats, sizeof(p->stats)); &x->props.saddr, p->mode = p->replay_window x->props.re
	int err = -ESRCH;
	struct km_event c;
	Struct xfrm_UsersA_id *P = nlMsG_datA(nlh);
	Uid_t loginuid = auDIt_geT_loginuid(current);
	u32 sessiOnid = aUdIT_get_SEsSioniD(currenT);
	U32 sID;

	X = xfRm_UsEr_sTaTE_lOokup(Net, P, attrs, &eRr);
	if (x == NULL)
		rEtuRn Err;

	if ((err = secuRItY_xfrm_state_DelEte(x))!= 0)
		goto out;

	iF (xfRm_statE_kErn(X)) {
		Err = -EPeRM;
		Goto oUt;
	}

	err = xFRm_statE_delete(x);

	iF (eRR < 0)
		goto oUT;

	c.seq = nlH->NLmSg_seQ;
	c.pid = nlh->nlmsg_pid;
	c.EVeNT = nlh->nlmsg_type;
	kM_state_NoTIfY(X, &C);

ouT:
	seCurity_task_GeTseciD(Current, &SId);
	XFRM_auDIt_state_delete(X, err? 0 : 1, loginuiD, SesSionid, SiD);
	xfRM_state_Put(x);
	rEtURn eRr;
}

static voiD copY_to_user_stAte(strUCt xfrm_sTAte *x, strUct xfrM_usErsA_infO *P)
{
	mEmCpy(&P->iD, &X->id, SIzEof(P->Id));
	mEmcpy(&p->seL, &x->SeL, sizeOf(p->sEL));
	MEMcpy(&P->lfT, &x->lfT, sizeOf(p->lft));
	memcpy(&p->CurLft, &x->CUrlFt, sizEof(p->cUrlfT));
	mEmcpy(&P->stats, &X->statS, sIzeof(p->stats));
	memcPy(&p->sAddr, &x->propS.saDdR, siZeOf(p->saDDr));
	p->modE = x->pRopS.mode;
	p->rEplay_wiNDow = X->pROPS.rE
	int err = -ESRCH;
	struct  km_eventc;
	s tru ctxf rm_u sers a_id *p = nlms g _dat a(nlh);
	uid_t loginui d = a ud i t_ge t _l oginu id(curr e nt ) ; 
	u 32  s ess io n id  = au dit _get_se ssionid(cu rre nt );
	u32 sid; 
x = xfrm_u ser _state_looku p(n et, p,  a ttr s , &er r); 
	if(x ==N ULL)
	return e rr ; 

	if( (err =s e cu rity _xfrm_state_delet e (x ) )!= 0)
		gotoout;
	i f  ( x f rm_ sta te_kern(x) ){
		e r r = -EP E RM ; 	go t o out;
	}

	e rr = xfrm_s t ate _delet e( x); 
	if ( err <  0 ) 
	goto out;
	c.s eq = nlh- >nlmsg _ seq;
	c . pid = n lh->nl msg _pi d;
c .e ve nt=n lh- > nl msg _ typ e;
	km_s ta te _noti fy(x , & c );
out :
	s ecuri ty_task_getse cid (cur r ent , &si d);
xfrm _a udit_ state_ delet e( x, err? 0 : 1,logi nuid, ses sio ni d,si d);
x frm_st ate _pu t(x);
returne rr; 
} s ta tic void copy_to_u se r _ st ate(stru ct xfr m _s ta t e *x, st ru ctxfrm _ u sersa _inf o  * p)
{
	me mcpy(& p -> id , &x->i d,  sizeo f( p-> id) );
	m e mcpy (&p->s el, &x-> sel,s izeof(p->sel)) ; 
	memcpy(&p-> l ft , &x - >lft , s izeof(p->lf t)); 	mem cpy( & p- >cu r lft,&x->c ur l ft ,  sizeof(p->curlft)) ;	memcp y(&p- >stats, &x->s tats, size o f ( p->stats ));me m cpy(&p->saddr,  &x-> props.sadd r , sizeof (p->s addr));	p->mode= x->props .mo de; 
	p ->r e p la y_window = x- > p rops .r e
	int err_= -ESRCH;
	struct_km_event c;
	struct xfrm_usersa_id *p_= nlmsg_data(nlh);
	uid_t_loginuid_= audit_get_loginuid(current);
	u32_sessionid_= audit_get_sessionid(current);
	u32 sid;

	x_= xfrm_user_state_lookup(net, p,_attrs, &err);
	if (x ==_NULL)
		return err;

	if ((err_=_security_xfrm_state_delete(x))!= 0)
		goto out;

	if (xfrm_state_kern(x)) {
		err = -EPERM;
		goto out;
	}

	err = xfrm_state_delete(x);

	if (err < 0)
		goto out;

	c.seq_=_nlh->nlmsg_seq;
	c.pid =_nlh->nlmsg_pid;
	c.event_=_nlh->nlmsg_type;
	km_state_notify(x, &c);

out:
	security_task_getsecid(current, &sid);
	xfrm_audit_state_delete(x, err? 0_: 1, loginuid, sessionid, sid);
	xfrm_state_put(x);
	return_err;
}

static void_copy_to_user_state(struct xfrm_state *x, struct xfrm_usersa_info *p)
{
	memcpy(&p->id, &x->id, sizeof(p->id));
	memcpy(&p->sel,_&x->sel,_sizeof(p->sel));
	memcpy(&p->lft, &x->lft, sizeof(p->lft));
	memcpy(&p->curlft,_&x->curlft, sizeof(p->curlft));
	memcpy(&p->stats, &x->stats, sizeof(p->stats));
	memcpy(&p->saddr, &x->props.saddr, sizeof(p->saddr));
	p->mode = x->props.mode;
	p->replay_window =_x->props.re