linux-imx/ipc
Cong Wang 3557f62ec9 mqueue: fix a use-after-free in sys_mq_notify()
commit f991af3daa upstream.

The retry logic for netlink_attachskb() inside sys_mq_notify()
is nasty and vulnerable:

1) The sock refcnt is already released when retry is needed
2) The fd is controllable by user-space because we already
   release the file refcnt

so we when retry but the fd has been just closed by user-space
during this small window, we end up calling netlink_detachskb()
on the error path which releases the sock again, later when
the user-space closes this socket a use-after-free could be
triggered.

Setting 'sock' to NULL here should be sufficient to fix it.

Reported-by: GeneBlue <geneblue.mail@gmail.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Manfred Spraul <manfred@colorfullife.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
2017-08-26 02:14:06 +01:00
..
compat_mq.c ipc: initialize structure memory to zero for compat functions 2010-10-27 18:03:13 -07:00
compat.c ipc: initialize structure memory to zero for compat functions 2010-10-27 18:03:13 -07:00
ipc_sysctl.c ipc: introduce shm_rmid_forced sysctl 2011-07-26 16:49:44 -07:00
ipcns_notifier.c ipc: do not use a negative value to re-enable msgmni automatic recomputing 2008-07-25 10:53:42 -07:00
Makefile Add generic sys_ipc wrapper 2010-03-12 15:52:32 -08:00
mq_sysctl.c sysctl ipc: Remove dead binary sysctl support code. 2009-11-12 02:04:54 -08:00
mqueue.c mqueue: fix a use-after-free in sys_mq_notify() 2017-08-26 02:14:06 +01:00
msg.c Initialize msg/shm IPC objects before doing ipc_addid() 2015-10-13 03:46:12 +01:00
msgutil.c ipc, msg: fix message length check for negative values 2014-01-03 04:33:21 +00:00
namespace.c ns proc: Add support for the ipc namespace 2011-05-10 14:35:47 -07:00
sem.c ipc/sem.c: fully initialize sem_array before making it visible 2015-10-13 03:46:12 +01:00
shm.c ipc/shm: Fix shmat mmap nil-page protection 2017-03-16 02:18:58 +00:00
syscall.c ppc64 sys_ipc breakage in 2.6.34-rc2 2010-03-22 09:57:19 -07:00
util.c Initialize msg/shm IPC objects before doing ipc_addid() 2015-10-13 03:46:12 +01:00
util.h ipc, msg: fix message length check for negative values 2014-01-03 04:33:21 +00:00