Skip to content

Commit 8b6e7cf

Browse files
jhovoldsmb49
authored andcommitted
misc: fastrpc: fix memory corruption on probe
BugLink: https://bugs.launchpad.net/bugs/1992211 commit 9baa141 upstream. Add the missing sanity check on the probed-session count to avoid corrupting memory beyond the fixed-size slab-allocated session array when there are more than FASTRPC_MAX_SESSIONS sessions defined in the devicetree. Fixes: f6f9279 ("misc: fastrpc: Add Qualcomm fastrpc basic driver model") Cc: stable@vger.kernel.org # 5.1 Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20220829080531.29681-2-johan+linaro@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent fc94927 commit 8b6e7cf

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/misc/fastrpc.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,6 +1357,11 @@ static int fastrpc_cb_probe(struct platform_device *pdev)
13571357
of_property_read_u32(dev->of_node, "qcom,nsessions", &sessions);
13581358

13591359
spin_lock_irqsave(&cctx->lock, flags);
1360+
if (cctx->sesscount >= FASTRPC_MAX_SESSIONS) {
1361+
dev_err(&pdev->dev, "too many sessions\n");
1362+
spin_unlock_irqrestore(&cctx->lock, flags);
1363+
return -ENOSPC;
1364+
}
13601365
sess = &cctx->session[cctx->sesscount];
13611366
sess->used = false;
13621367
sess->valid = true;

0 commit comments

Comments
 (0)