s390/vmcp: fix uaccess check and avoid undefined behavior
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Mon, 7 Aug 2017 13:16:15 +0000 (15:16 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 9 Aug 2017 13:09:32 +0000 (09:09 -0400)
commit267239cc10f18251892a0783104df3dc22b620d5
treef420241fbc3f469085c8d5a2105a90b3fd4d26ac
parent34ad7cdc1bb2ea65934d235be89fabf1bb40d824
s390/vmcp: fix uaccess check and avoid undefined behavior

The vmcp device driver should return -EFAULT if get_user() fails, due
to an invalid user space address. In addition the buffer size value
from user space is passed unchecked to get_order(). The return value
of get_order(0) undefined.

Therefore explicitly test for zero before calling get_order() and also
return -EFAULT if get_user() fails.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/char/vmcp.c