On Thu, Jun 25, 2026 at 03:48:18PM +0200, Oleg Nesterov wrote:
> On 06/25, Jiri Olsa wrote:
> >
> > On Wed, Jun 24, 2026 at 04:36:23PM +0200, Oleg Nesterov wrote:
> > >
> > > Perhaps we can later optimize this code a bit? I mean something like
> > >
> > >   start_reachable = ...;
> > >   end_reachable = ...;
> > >
> > >   VMA_ITERATOR(vmi, mm, start_reachable);
> > >
> > >   for_each_vma(vmi, vma) {
> > >           if (!vma_is_special_mapping(...))
> > >                   continue;
> > >           if (vma->vm_start > end_reachable)
> > >                   break;
> > >           return vma;
> > >   }
> >
> > looks good, will try to use that
> 
> See my next email, we can use for_each_vma_range().
> 
> But let me repeat, we can add this mimor optimization later, I don't want
> to delay this series.
> 
> > > >  static int __arch_uprobe_optimize(struct arch_uprobe *auprobe, struct 
> > > > mm_struct *mm,
> > > >                                   unsigned long vaddr)
> > > >  {
> > > > -       struct uprobe_trampoline *tramp;
> > > > -       struct vm_area_struct *vma;
> > > > -       bool new = false;
> > > > -       int err = 0;
> > > > +       struct pt_regs *regs = task_pt_regs(current);
> > > > +       struct vm_area_struct *vma, *tramp;
> > > >
> > > > +       if (!user_64bit_mode(regs))
> > > > +               return -EINVAL;
> > > >         vma = find_vma(mm, vaddr);
> > > >         if (!vma)
> > > >                 return -EINVAL;
> > >
> > > I guess find_vma() can't fail, the caller arch_uprobe_optimize() has 
> > > called
> > > copy_from_vaddr() under mmap_write_lock()... Nevermind.
> >
> > hum, how's that.. I'll check, but where's the magic? :)
> 
> arch_uprobe_optimize() -> copy_from_vaddr() reads this mm at the same vaddr,
> this means that vma at this vaddr must exist. Unless I am totally confused ;)
> But even if I am right please ignore. I just tried to understand if find_vma()
> can fail or not here.

ok, will leave these 2 changes for later

jirka

Reply via email to