Message ID | 20240712-asi-rfc-24-v1-19-144b319a40d8@google.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | Address Space Isolation (ASI) 2024 | expand |
On Fri, Jul 12, 2024 at 10:01 AM Brendan Jackman <jackmanb@google.com> wrote: > > From: Yosry Ahmed <yosryahmed@google.com> > > In pcpu_map_pages(), if __pcpu_map_pages() fails on a CPU, we call > __pcpu_unmap_pages() to clean up mappings on all CPUs where mappings > were created, but not on the CPU where __pcpu_map_pages() fails. > > __pcpu_map_pages() and __pcpu_unmap_pages() are wrappers around > vmap_pages_range_noflush() and vunmap_range_noflush(). All other callers > of vmap_pages_range_noflush() call vunmap_range_noflush() when mapping > fails, except pcpu_map_pages(). The reason could be that partial > mappings may be left behind from a failed mapping attempt. > > Call __pcpu_unmap_pages() for the failed CPU as well in > pcpu_map_pages(). > > This was found by code inspection, no failures or bugs were observed. > > Signed-off-by: Yosry Ahmed <yosryahmed@google.com> > Acked-by: Dennis Zhou <dennis@kernel.org> > > (am from https://lore.kernel.org/lkml/20240311194346.2291333-1-yosryahmed@google.com/) This went into v6.10 as commit 2ccd48ce35e87f09472b42dda96fbf7b5165f3c3. > --- > mm/percpu-vm.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c > index 2054c9213c43..cd69caf6aa8d 100644 > --- a/mm/percpu-vm.c > +++ b/mm/percpu-vm.c > @@ -231,10 +231,10 @@ static int pcpu_map_pages(struct pcpu_chunk *chunk, > return 0; > err: > for_each_possible_cpu(tcpu) { > - if (tcpu == cpu) > - break; > __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start), > page_end - page_start); > + if (tcpu == cpu) > + break; > } > pcpu_post_unmap_tlb_flush(chunk, page_start, page_end); > return err; > > -- > 2.45.2.993.g49e7a77208-goog >
diff --git a/mm/percpu-vm.c b/mm/percpu-vm.c index 2054c9213c43..cd69caf6aa8d 100644 --- a/mm/percpu-vm.c +++ b/mm/percpu-vm.c @@ -231,10 +231,10 @@ static int pcpu_map_pages(struct pcpu_chunk *chunk, return 0; err: for_each_possible_cpu(tcpu) { - if (tcpu == cpu) - break; __pcpu_unmap_pages(pcpu_chunk_addr(chunk, tcpu, page_start), page_end - page_start); + if (tcpu == cpu) + break; } pcpu_post_unmap_tlb_flush(chunk, page_start, page_end); return err;