Skip to content

Commit cf909a6

Browse files
committed
fix bounds on unmap_range to make sure Mapper is object safe
1 parent 331815b commit cf909a6

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
@@ -461,7 +461,8 @@ pub trait Mapper<S: PageSize> {
461461
deallocator: &mut D,
462462
) -> Result<MapperFlushRange<S>, (UnmapError, MapperFlushRange<S>)>
463463
where
464-
D: FrameDeallocator<S>,
464+
Self: Sized,
465+
D: FrameDeallocator<S> + ?Sized,
465466
{
466467
pages
467468
.clone()

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
126126
deallocator: &mut D,
127127
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
128128
where
129-
D: FrameDeallocator<Size1GiB>,
129+
Self: Sized,
130+
D: FrameDeallocator<Size1GiB> + ?Sized,
130131
{
131132
self.inner.unmap_range(pages, deallocator)
132133
}
@@ -242,7 +243,8 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
242243
deallocator: &mut D,
243244
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
244245
where
245-
D: FrameDeallocator<Size2MiB>,
246+
Self: Sized,
247+
D: FrameDeallocator<Size2MiB> + ?Sized,
246248
{
247249
self.inner.unmap_range(pages, deallocator)
248250
}
@@ -358,7 +360,8 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
358360
deallocator: &mut D,
359361
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
360362
where
361-
D: FrameDeallocator<Size4KiB>,
363+
Self: Sized,
364+
D: FrameDeallocator<Size4KiB> + ?Sized,
362365
{
363366
self.inner.unmap_range(pages, deallocator)
364367
}

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)