• Oleg Nesterov's avatar
    uprobes: Shift ->readpage check from __copy_insn() to uprobe_register() · 41ccba02
    Oleg Nesterov authored
    copy_insn() fails with -EIO if ->readpage == NULL, but this error
    is not propagated unless uprobe_register() path finds ->mm which
    already mmaps this file. In this case (say) "perf record" does not
    actually install the probe, but the user can't know about this.
    
    Move this check into uprobe_register() so that this problem can be
    detected earlier and reported to user.
    
    Note: this is still not perfect,
    
    	- copy_insn() and arch_uprobe_analyze_insn() should be called
    	  by uprobe_register() but this is not simple, we need vm_file
    	  for read_mapping_page() (although perhaps we can pass NULL),
    	  and we need ->mm for is_64bit_mm() (although this logic is
    	  broken anyway).
    
    	- uprobe_register() should be called by create_trace_uprobe(),
    	  not by probe_event_enable(), so that an error can be detected
    	  at "perf probe -x" time. This also needs more changes in the
    	  core uprobe code, uprobe register/unregister interface was
    	  poorly designed from the very beginning.
    Reported-by: default avatarDenys Vlasenko <dvlasenk@redhat.com>
    Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
    Acked-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
    Signed-off-by: default avatarPeter Zijlstra <peterz@infradead.org>
    Cc: Hugh Dickins <hughd@google.com>
    Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20140519184054.GA6750@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
    41ccba02
uprobes.c 47.6 KB