mirror of
https://github.com/torvalds/linux.git
synced 2024-12-29 06:12:08 +00:00
[XFRM]: fix incorrect xfrm_state_afinfo_lock use
xfrm_state_afinfo_lock can be read-locked from bh context, so take it in a bh-safe manner in xfrm_state_register_afinfo() and xfrm_state_unregister_afinfo(). Found by the lock validator. Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
83de47cd0c
commit
f3111502c0
@ -1061,7 +1061,7 @@ int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo)
|
||||
return -EINVAL;
|
||||
if (unlikely(afinfo->family >= NPROTO))
|
||||
return -EAFNOSUPPORT;
|
||||
write_lock(&xfrm_state_afinfo_lock);
|
||||
write_lock_bh(&xfrm_state_afinfo_lock);
|
||||
if (unlikely(xfrm_state_afinfo[afinfo->family] != NULL))
|
||||
err = -ENOBUFS;
|
||||
else {
|
||||
@ -1069,7 +1069,7 @@ int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo)
|
||||
afinfo->state_byspi = xfrm_state_byspi;
|
||||
xfrm_state_afinfo[afinfo->family] = afinfo;
|
||||
}
|
||||
write_unlock(&xfrm_state_afinfo_lock);
|
||||
write_unlock_bh(&xfrm_state_afinfo_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(xfrm_state_register_afinfo);
|
||||
@ -1081,7 +1081,7 @@ int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo)
|
||||
return -EINVAL;
|
||||
if (unlikely(afinfo->family >= NPROTO))
|
||||
return -EAFNOSUPPORT;
|
||||
write_lock(&xfrm_state_afinfo_lock);
|
||||
write_lock_bh(&xfrm_state_afinfo_lock);
|
||||
if (likely(xfrm_state_afinfo[afinfo->family] != NULL)) {
|
||||
if (unlikely(xfrm_state_afinfo[afinfo->family] != afinfo))
|
||||
err = -EINVAL;
|
||||
@ -1091,7 +1091,7 @@ int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo)
|
||||
afinfo->state_bydst = NULL;
|
||||
}
|
||||
}
|
||||
write_unlock(&xfrm_state_afinfo_lock);
|
||||
write_unlock_bh(&xfrm_state_afinfo_lock);
|
||||
return err;
|
||||
}
|
||||
EXPORT_SYMBOL(xfrm_state_unregister_afinfo);
|
||||
|
Loading…
Reference in New Issue
Block a user