Skip to content

Commit 8859e3c

Browse files
c_mtharujb-essential
authored andcommitted
msm: adsprpc: Fix integer overflow in refcount of map
Integer overflow in refcount of map is leading to use after free. Error out if refcount reaches INT_MAX. Change-Id: I21e88361a8e70ef8c5c9593f1fc0ddd2b351a55a Acked-by: Himateja Reddy <hmreddy@qti.qualcomm.com> Signed-off-by: Tharun Kumar Merugu <mtharu@codeaurora.org>
1 parent fbd2d45 commit 8859e3c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/char/adsprpc.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,10 @@ static int fastrpc_mmap_find(struct fastrpc_file *fl, int fd, uintptr_t va,
432432
if (va >= map->va &&
433433
va + len <= map->va + map->len &&
434434
map->fd == fd) {
435+
if (map->refs + 1 == INT_MAX) {
436+
spin_unlock(&fl->hlock);
437+
return -ETOOMANYREFS;
438+
}
435439
map->refs++;
436440
match = map;
437441
break;
@@ -444,6 +448,10 @@ static int fastrpc_mmap_find(struct fastrpc_file *fl, int fd, uintptr_t va,
444448
if (va >= map->va &&
445449
va + len <= map->va + map->len &&
446450
map->fd == fd) {
451+
if (map->refs + 1 == INT_MAX) {
452+
spin_unlock(&me->hlock);
453+
return -ETOOMANYREFS;
454+
}
447455
map->refs++;
448456
match = map;
449457
break;

0 commit comments

Comments
 (0)