Skip to content

Commit

Permalink
ipc/msg.c: fix percpu_counter use after free
Browse files Browse the repository at this point in the history
These percpu counters are referenced in free_ipcs->freeque, so destroy
them later.

Fixes: 72d1e61 ("ipc/msg: mitigate the lock contention with percpu counter")
Reported-by: [email protected]
Tested-by: Mark Rutland <[email protected]>
Cc: Jiebin Sun <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
akpm00 committed Oct 28, 2022
1 parent 27d676a commit 64b4c41
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ipc/msg.c
Original file line number Diff line number Diff line change
Expand Up @@ -1329,11 +1329,11 @@ int msg_init_ns(struct ipc_namespace *ns)
#ifdef CONFIG_IPC_NS
void msg_exit_ns(struct ipc_namespace *ns)
{
percpu_counter_destroy(&ns->percpu_msg_bytes);
percpu_counter_destroy(&ns->percpu_msg_hdrs);
free_ipcs(ns, &msg_ids(ns), freeque);
idr_destroy(&ns->ids[IPC_MSG_IDS].ipcs_idr);
rhashtable_destroy(&ns->ids[IPC_MSG_IDS].key_ht);
percpu_counter_destroy(&ns->percpu_msg_bytes);
percpu_counter_destroy(&ns->percpu_msg_hdrs);
}
#endif

Expand Down

0 comments on commit 64b4c41

Please sign in to comment.