Skip to content

Commit 3da6f4b

Browse files
committed
fix bounds on unmap_range to make sure Mapper is object safe
1 parent a4f43c8 commit 3da6f4b

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
@@ -463,7 +463,8 @@ pub trait Mapper<S: PageSize> {
463463
deallocator: &mut D,
464464
) -> Result<MapperFlushRange<S>, (UnmapError, MapperFlushRange<S>)>
465465
where
466-
D: FrameDeallocator<S>,
466+
Self: Sized,
467+
D: FrameDeallocator<S> + ?Sized,
467468
{
468469
pages
469470
.clone()

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
127127
deallocator: &mut D,
128128
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
129129
where
130-
D: FrameDeallocator<Size1GiB>,
130+
Self: Sized,
131+
D: FrameDeallocator<Size1GiB> + ?Sized,
131132
{
132133
self.inner.unmap_range(pages, deallocator)
133134
}
@@ -243,7 +244,8 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
243244
deallocator: &mut D,
244245
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
245246
where
246-
D: FrameDeallocator<Size2MiB>,
247+
Self: Sized,
248+
D: FrameDeallocator<Size2MiB> + ?Sized,
247249
{
248250
self.inner.unmap_range(pages, deallocator)
249251
}
@@ -359,7 +361,8 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
359361
deallocator: &mut D,
360362
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
361363
where
362-
D: FrameDeallocator<Size4KiB>,
364+
Self: Sized,
365+
D: FrameDeallocator<Size4KiB> + ?Sized,
363366
{
364367
self.inner.unmap_range(pages, deallocator)
365368
}

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)