1
0
Fork 0
alistair23-linux/drivers/staging/vc04_services
Ben Wolsieffer 5a96b2d38d staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETION
The compatibility ioctl wrapper for VCHIQ_IOC_AWAIT_COMPLETION assumes that
the native ioctl always uses a message buffer and decrements msgbufcount.
Certain message types do not use a message buffer and in this case
msgbufcount is not decremented, and completion->header for the message is
NULL. Because the wrapper unconditionally decrements msgbufcount, the
calling process may assume that a message buffer has been used even when
it has not.

This results in a memory leak in the userspace code that interfaces with
this driver. When msgbufcount is decremented, the userspace code assumes
that the buffer can be freed though the reference in completion->header,
which cannot happen when the reference is NULL.

This patch causes the wrapper to only decrement msgbufcount when the
native ioctl decrements it. Note that we cannot simply copy the native
ioctl's value of msgbufcount, because the wrapper only retrieves messages
from the native ioctl one at a time, while userspace may request multiple
messages.

See https://github.com/raspberrypi/linux/pull/2703 for more discussion of
this patch.

Fixes: 5569a12609 ("staging: vchiq_arm: Add compatibility wrappers for ioctls")
Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
Acked-by: Stefan Wahren <stefan.wahren@i2se.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-11 11:47:39 -08:00
..
bcm2835-audio staging: vc04_services: Drop unused parameters from vchi_connect() 2018-10-09 15:24:21 +02:00
bcm2835-camera staging: vc04_services: Drop unused parameters from vchi_connect() 2018-10-09 15:24:21 +02:00
interface staging: vchiq_arm: fix compat VCHIQ_IOC_AWAIT_COMPLETION 2018-11-11 11:47:39 -08:00
Kconfig staging: vc04_services: Remove depends on HAS_DMA in case of platform dependency 2018-04-23 15:51:34 +02:00
Makefile staging: vc04_services: Remove defines from Makefile 2018-05-06 19:04:43 -07:00