Skip to content

Commit 6f197c7

Browse files
committed
fix bounds on unmap_range to make sure Mapper is object safe
1 parent e232d1f commit 6f197c7

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

src/structures/paging/mapper/mapped_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size1GiB> for MappedPageTable<'a, P> {
651651
deallocator: &mut D,
652652
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
653653
where
654-
D: FrameDeallocator<Size1GiB>,
654+
Self: Sized,
655+
D: FrameDeallocator<Size1GiB> + ?Sized,
655656
{
656657
self.modify_range_1gib(
657658
pages,
@@ -856,7 +857,8 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size2MiB> for MappedPageTable<'a, P> {
856857
deallocator: &mut D,
857858
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
858859
where
859-
D: FrameDeallocator<Size2MiB>,
860+
Self: Sized,
861+
D: FrameDeallocator<Size2MiB> + ?Sized,
860862
{
861863
self.modify_range_2mib(
862864
pages,
@@ -1074,7 +1076,8 @@ impl<'a, P: PageTableFrameMapping> Mapper<Size4KiB> for MappedPageTable<'a, P> {
10741076
deallocator: &mut D,
10751077
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
10761078
where
1077-
D: FrameDeallocator<Size4KiB>,
1079+
Self: Sized,
1080+
D: FrameDeallocator<Size4KiB> + ?Sized,
10781081
{
10791082
self.modify_range_4kib(
10801083
pages,

src/structures/paging/mapper/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,8 @@ pub trait Mapper<S: PageSize> {
470470
deallocator: &mut D,
471471
) -> Result<MapperFlushRange<S>, (UnmapError, MapperFlushRange<S>)>
472472
where
473-
D: FrameDeallocator<S>,
473+
Self: Sized,
474+
D: FrameDeallocator<S> + ?Sized,
474475
{
475476
pages
476477
.clone()

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
131131
deallocator: &mut D,
132132
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
133133
where
134-
D: FrameDeallocator<Size1GiB>,
134+
Self: Sized,
135+
D: FrameDeallocator<Size1GiB> + ?Sized,
135136
{
136137
unsafe { self.inner.unmap_range(pages, deallocator) }
137138
}
@@ -251,7 +252,8 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
251252
deallocator: &mut D,
252253
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
253254
where
254-
D: FrameDeallocator<Size2MiB>,
255+
Self: Sized,
256+
D: FrameDeallocator<Size2MiB> + ?Sized,
255257
{
256258
unsafe { self.inner.unmap_range(pages, deallocator) }
257259
}
@@ -371,7 +373,8 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
371373
deallocator: &mut D,
372374
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
373375
where
374-
D: FrameDeallocator<Size4KiB>,
376+
Self: Sized,
377+
D: FrameDeallocator<Size4KiB> + ?Sized,
375378
{
376379
unsafe { self.inner.unmap_range(pages, deallocator) }
377380
}

src/structures/paging/mapper/recursive_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,8 @@ impl<'a> Mapper<Size1GiB> for RecursivePageTable<'a> {
824824
deallocator: &mut D,
825825
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
826826
where
827-
D: FrameDeallocator<Size1GiB>,
827+
Self: Sized,
828+
D: FrameDeallocator<Size1GiB> + ?Sized,
828829
{
829830
self.modify_range_1gib(
830831
pages,
@@ -1046,7 +1047,8 @@ impl<'a> Mapper<Size2MiB> for RecursivePageTable<'a> {
10461047
deallocator: &mut D,
10471048
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
10481049
where
1049-
D: FrameDeallocator<Size2MiB>,
1050+
Self: Sized,
1051+
D: FrameDeallocator<Size2MiB> + ?Sized,
10501052
{
10511053
self.modify_range_2mib(
10521054
pages,
@@ -1297,7 +1299,8 @@ impl<'a> Mapper<Size4KiB> for RecursivePageTable<'a> {
12971299
deallocator: &mut D,
12981300
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
12991301
where
1300-
D: FrameDeallocator<Size4KiB>,
1302+
Self: Sized,
1303+
D: FrameDeallocator<Size4KiB> + ?Sized,
13011304
{
13021305
self.modify_range_4kib(
13031306
pages,

0 commit comments

Comments
 (0)