Skip to content

Commit

Permalink
binder: Check pointer before subtracting from base address.
Browse files Browse the repository at this point in the history
  • Loading branch information
wedsonaf committed Jun 8, 2021
1 parent 76001a4 commit 5baa6d7
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/android/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ impl Process {
pub(crate) fn buffer_get(&self, ptr: usize) -> Option<Allocation> {
let mut inner = self.inner.lock();
let mapping = inner.mapping.as_mut()?;
if ptr < mapping.address {
return None;
}
let offset = ptr - mapping.address;
let (size, odata) = mapping.alloc.reserve_existing(offset).ok()?;
let mut alloc = Allocation::new(self, offset, size, ptr, mapping.pages.clone());
Expand All @@ -557,6 +560,9 @@ impl Process {
pub(crate) fn buffer_raw_free(&self, ptr: usize) {
let mut inner = self.inner.lock();
if let Some(ref mut mapping) = &mut inner.mapping {
if ptr < mapping.address {
return;
}
if mapping
.alloc
.reservation_abort(ptr - mapping.address)
Expand Down

0 comments on commit 5baa6d7

Please sign in to comment.