Skip to content

Commit a3ed2a1

Browse files
andre-rosatorvalds
authored andcommitted
mqueue: fix kernel BUG caused by double free() on mq_open()
In case of aborting because we reach the maximum amount of memory which can be allocated to message queues per user (RLIMIT_MSGQUEUE), we would try to free the message area twice when bailing out: first by the error handling code itself, and then later when cleaning up the inode through delete_inode(). Signed-off-by: André Goddard Rosa <andre.goddard@gmail.com> Cc: Alexey Dobriyan <adobriyan@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent de145b4 commit a3ed2a1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎ipc/mqueue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
158158
u->mq_bytes + mq_bytes >
159159
task_rlimit(p, RLIMIT_MSGQUEUE)) {
160160
spin_unlock(&mq_lock);
161-
kfree(info->messages);
161+
/* mqueue_delete_inode() releases info->messages */
162162
goto out_inode;
163163
}
164164
u->mq_bytes += mq_bytes;

0 commit comments

Comments
 (0)