path: root/ipc/msg.c
diff options
authorManfred Spraul <>2018-08-21 22:01:29 -0700
committerLinus Torvalds <>2018-08-22 10:52:51 -0700
commit39cfffd774a2e8818250360a3e028b5eac9d5392 (patch)
tree6965eb7bc09fc8c58a900d0641d9ccde8752065c /ipc/msg.c
parente2652ae6bd7492cdc0436817cbcd09282eb0bb03 (diff)
ipc/util.c: use ipc_rcu_putref() for failues in ipc_addid()
ipc_addid() is impossible to use: - for certain failures, the caller must not use ipc_rcu_putref(), because the reference counter is not yet initialized. - for other failures, the caller must use ipc_rcu_putref(), because parallel operations could be ongoing already. The patch cleans that up, by initializing the refcount early, and by modifying all callers. The issues is related to the finding of syzbot found an issue with reading kern_ipc_perm.seq, here both read and write to already released memory could happen. Link: Signed-off-by: Manfred Spraul <> Cc: Dmitry Vyukov <> Cc: Kees Cook <> Cc: Davidlohr Bueso <> Cc: Davidlohr Bueso <> Cc: Herbert Xu <> Cc: Michael Kerrisk <> Cc: Michal Hocko <> Signed-off-by: Andrew Morton <> Signed-off-by: Linus Torvalds <>
Diffstat (limited to 'ipc/msg.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/ipc/msg.c b/ipc/msg.c
index 7cb89a9b24e2..3132aa27ff88 100644
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -163,7 +163,7 @@ static int newque(struct ipc_namespace *ns, struct ipc_params *params)
/* ipc_addid() locks msq upon success. */
retval = ipc_addid(&msg_ids(ns), &msq->q_perm, ns->msg_ctlmni);
if (retval < 0) {
- call_rcu(&msq->q_perm.rcu, msg_rcu_free);
+ ipc_rcu_putref(&msq->q_perm, msg_rcu_free);
return retval;