Skip to content

Commit caf85c2

Browse files
committed
fix bounds on unmap_range to make sure Mapper is object safe
1 parent 13df8d7 commit caf85c2

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
@@ -471,7 +471,8 @@ pub trait Mapper<S: PageSize> {
471471
deallocator: &mut D,
472472
) -> Result<MapperFlushRange<S>, (UnmapError, MapperFlushRange<S>)>
473473
where
474-
D: FrameDeallocator<S>,
474+
Self: Sized,
475+
D: FrameDeallocator<S> + ?Sized,
475476
{
476477
pages
477478
.clone()

src/structures/paging/mapper/offset_page_table.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ impl<'a> Mapper<Size1GiB> for OffsetPageTable<'a> {
133133
deallocator: &mut D,
134134
) -> Result<MapperFlushRange<Size1GiB>, (UnmapError, MapperFlushRange<Size1GiB>)>
135135
where
136-
D: FrameDeallocator<Size1GiB>,
136+
Self: Sized,
137+
D: FrameDeallocator<Size1GiB> + ?Sized,
137138
{
138139
unsafe { self.inner.unmap_range(pages, deallocator) }
139140
}
@@ -255,7 +256,8 @@ impl<'a> Mapper<Size2MiB> for OffsetPageTable<'a> {
255256
deallocator: &mut D,
256257
) -> Result<MapperFlushRange<Size2MiB>, (UnmapError, MapperFlushRange<Size2MiB>)>
257258
where
258-
D: FrameDeallocator<Size2MiB>,
259+
Self: Sized,
260+
D: FrameDeallocator<Size2MiB> + ?Sized,
259261
{
260262
unsafe { self.inner.unmap_range(pages, deallocator) }
261263
}
@@ -377,7 +379,8 @@ impl<'a> Mapper<Size4KiB> for OffsetPageTable<'a> {
377379
deallocator: &mut D,
378380
) -> Result<MapperFlushRange<Size4KiB>, (UnmapError, MapperFlushRange<Size4KiB>)>
379381
where
380-
D: FrameDeallocator<Size4KiB>,
382+
Self: Sized,
383+
D: FrameDeallocator<Size4KiB> + ?Sized,
381384
{
382385
unsafe { self.inner.unmap_range(pages, deallocator) }
383386
}

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)