Skip to content

Commit

Permalink
msm: adsprpc: Fix integer overflow in refcount of map
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
c_mtharu authored and jb-essential committed Dec 2, 2019
1 parent fbd2d45 commit 8859e3c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/char/adsprpc.c
Expand Up @@ -432,6 +432,10 @@ static int fastrpc_mmap_find(struct fastrpc_file *fl, int fd, uintptr_t va,
if (va >= map->va &&
va + len <= map->va + map->len &&
map->fd == fd) {
if (map->refs + 1 == INT_MAX) {
spin_unlock(&fl->hlock);
return -ETOOMANYREFS;
}
map->refs++;
match = map;
break;
Expand All @@ -444,6 +448,10 @@ static int fastrpc_mmap_find(struct fastrpc_file *fl, int fd, uintptr_t va,
if (va >= map->va &&
va + len <= map->va + map->len &&
map->fd == fd) {
if (map->refs + 1 == INT_MAX) {
spin_unlock(&me->hlock);
return -ETOOMANYREFS;
}
map->refs++;
match = map;
break;
Expand Down

0 comments on commit 8859e3c

Please sign in to comment.