]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
remoteproc: qcom_q6v5_mss: Validate MBA firmware size before load
authorSibi Sankar <sibis@codeaurora.org>
Wed, 22 Jul 2020 20:10:45 +0000 (01:40 +0530)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Tue, 28 Jul 2020 06:21:13 +0000 (23:21 -0700)
The following mem abort is observed when the mba firmware size exceeds
the allocated mba region. MBA firmware size is restricted to a maximum
size of 1M and remaining memory region is used by modem debug policy
firmware when available. Hence verify whether the MBA firmware size lies
within the allocated memory region and is not greater than 1M before
loading.

Err Logs:
Unable to handle kernel paging request at virtual address
Mem abort info:
...
Call trace:
  __memcpy+0x110/0x180
  rproc_start+0x40/0x218
  rproc_boot+0x5b4/0x608
  state_store+0x54/0xf8
  dev_attr_store+0x44/0x60
  sysfs_kf_write+0x58/0x80
  kernfs_fop_write+0x140/0x230
  vfs_write+0xc4/0x208
  ksys_write+0x74/0xf8
  __arm64_sys_write+0x24/0x30
...

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Fixes: 051fb70fd4ea4 ("remoteproc: qcom: Driver for the self-authenticating Hexagon v5")
Cc: stable@vger.kernel.org
Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
Link: https://lore.kernel.org/r/20200722201047.12975-2-sibis@codeaurora.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/remoteproc/qcom_q6v5_mss.c

index 03d7f3d702b3a938388a18200fdd5b602051a03f..7826f229957d1dde9d0e4144cea665745121ab78 100644 (file)
@@ -411,6 +411,12 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
 {
        struct q6v5 *qproc = rproc->priv;
 
+       /* MBA is restricted to a maximum size of 1M */
+       if (fw->size > qproc->mba_size || fw->size > SZ_1M) {
+               dev_err(qproc->dev, "MBA firmware load failed\n");
+               return -EINVAL;
+       }
+
        memcpy(qproc->mba_region, fw->data, fw->size);
 
        return 0;