Skip to content

Commit 4579e90

Browse files
wedsonafSven Van Asbroeck
authored and
Sven Van Asbroeck
committed
binder: Check pointer before subtracting from base address.
1 parent 4d2dba4 commit 4579e90

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/android/process.rs

+6
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,9 @@ impl Process {
537537
pub(crate) fn buffer_get(&self, ptr: usize) -> Option<Allocation> {
538538
let mut inner = self.inner.lock();
539539
let mapping = inner.mapping.as_mut()?;
540+
if ptr < mapping.address {
541+
return None;
542+
}
540543
let offset = ptr - mapping.address;
541544
let (size, odata) = mapping.alloc.reserve_existing(offset).ok()?;
542545
let mut alloc = Allocation::new(self, offset, size, ptr, mapping.pages.clone());
@@ -549,6 +552,9 @@ impl Process {
549552
pub(crate) fn buffer_raw_free(&self, ptr: usize) {
550553
let mut inner = self.inner.lock();
551554
if let Some(ref mut mapping) = &mut inner.mapping {
555+
if ptr < mapping.address {
556+
return;
557+
}
552558
if mapping
553559
.alloc
554560
.reservation_abort(ptr - mapping.address)

0 commit comments

Comments
 (0)