Commit 29fe3a6
xfrm: prevent policy_hthresh.work from racing with netns teardown
A XFRM_MSG_NEWSPDINFO request can queue the per-net work item
policy_hthresh.work onto the system workqueue.
The queued callback, xfrm_hash_rebuild(), retrieves the enclosing
struct net via container_of(). If the net namespace is torn down
before that work runs, the associated struct net may already have
been freed, and xfrm_hash_rebuild() may then dereference stale memory.
xfrm_policy_fini() already flushes policy_hash_work during teardown,
but it does not synchronize policy_hthresh.work.
Synchronize policy_hthresh.work in xfrm_policy_fini() as well, so the
queued work cannot outlive the net namespace teardown and access a
freed struct net.
Fixes: 880a6fa ("xfrm: configure policy hash table thresholds by netlink")
Signed-off-by: Minwoo Ra <[email protected]>
Signed-off-by: Steffen Klassert <[email protected]>1 parent daf8e3b commit 29fe3a6
1 file changed
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4282 | 4282 | | |
4283 | 4283 | | |
4284 | 4284 | | |
| 4285 | + | |
| 4286 | + | |
4285 | 4287 | | |
4286 | 4288 | | |
4287 | 4289 | | |
| |||
0 commit comments