Re: [PATCH v2 1/3] kernel/uprobes: Warn if unable to install breakpoint

From: Naveen N. Rao
Date: Sat Sep 16 2017 - 07:46:25 EST


On 2017/09/15 05:53PM, Oleg Nesterov wrote:
> On 09/14, Naveen N. Rao wrote:
> >
> > +static void uprobe_warn(struct task_struct *t, const char *msg)
> > +{
> > + pr_warn("uprobe: %s:%d failed to %s\n",
> > + current->comm, current->pid, msg);
> > +}
> > +
> > /*
> > * valid_vma: Verify if the specified vma is an executable vma
> > * Relax restrictions while unregistering: vm_flags might have
> > @@ -1087,7 +1093,14 @@ int uprobe_mmap(struct vm_area_struct *vma)
> > if (!fatal_signal_pending(current) &&
> > filter_chain(uprobe, UPROBE_FILTER_MMAP, vma->vm_mm)) {
> > unsigned long vaddr = offset_to_vaddr(vma, uprobe->offset);
> > - install_breakpoint(uprobe, vma->vm_mm, vma, vaddr);
> > + int ret = install_breakpoint(uprobe, vma->vm_mm, vma, vaddr);
> > + if (ret) {
> > + char msg[64];
> > + snprintf(msg, sizeof(msg),
> > + "setup probe at 0x%llx (%d)",
> > + uprobe->offset, ret);
> > + uprobe_warn(current, (const char *)msg);
>
> Agreed, but... this is cosmetic, but I don't really like this snprintf().
>
> I won't insist too much, but wouldn't it better to turn uprobe_warn() into
> uprobe_warn(struct task_struct *t, char *fmt, ...) ?

Good point. In fact, I think we can just use pr_fmt().

Thanks,
Naveen