Initialize state id prior to attaching state to key hash. Otherwise a
race can happen, when pf_find_state() finds state via key hash, and locks id hash slot 0 instead of appropriate to state id slot.
This commit is contained in:
parent
b1ec2940af
commit
feaa4dd2d0
@ -1080,9 +1080,6 @@ pf_state_insert(struct pfi_kif *kif, struct pf_state_key *skw,
|
||||
|
||||
s->kif = kif;
|
||||
|
||||
if (pf_state_key_attach(skw, sks, s))
|
||||
return (-1);
|
||||
|
||||
if (s->id == 0 && s->creatorid == 0) {
|
||||
/* XXX: should be atomic, but probability of collision low */
|
||||
if ((s->id = V_pf_stateid[curcpu]++) == PFID_MAXID)
|
||||
@ -1092,6 +1089,9 @@ pf_state_insert(struct pfi_kif *kif, struct pf_state_key *skw,
|
||||
s->creatorid = V_pf_status.hostid;
|
||||
}
|
||||
|
||||
if (pf_state_key_attach(skw, sks, s))
|
||||
return (-1);
|
||||
|
||||
ih = &V_pf_idhash[PF_IDHASH(s)];
|
||||
PF_HASHROW_LOCK(ih);
|
||||
LIST_FOREACH(cur, &ih->states, entry)
|
||||
|
Loading…
Reference in New Issue
Block a user