]> git.baikalelectronics.ru Git - kernel.git/commit
firmware: arm_ffa: Fix a possible ffa_linux_errmap buffer overflow
authorSudeep Holla <sudeep.holla@arm.com>
Wed, 7 Jul 2021 13:47:39 +0000 (14:47 +0100)
committerSudeep Holla <sudeep.holla@arm.com>
Mon, 12 Jul 2021 13:20:08 +0000 (14:20 +0100)
commit9ce67cb410d3a67c41aca9d697d530697aa69322
tree9cf2654efd9d34f7c67e852b279d661e28720e55
parente864b20613f10f54f1a18c5a7efb9ec658a45b61
firmware: arm_ffa: Fix a possible ffa_linux_errmap buffer overflow

The ffa_linux_errmap buffer access index is supposed to range from 0-8
but it ranges from 1-9 instead. It reads one element out of bounds. It
also changes the success into -EINVAL though ffa_to_linux_errno is never
used in case of success, it is expected to work for success case too.

It is slightly confusing code as the negative of the error code
is used as index to the buffer. Fix it by negating it at the start and
make it more readable.

Link: https://lore.kernel.org/r/20210707134739.1869481-1-sudeep.holla@arm.com
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
drivers/firmware/arm_ffa/driver.c