From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934945Ab1JEQYR (ORCPT ); Wed, 5 Oct 2011 12:24:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:15791 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934476Ab1JEQYQ (ORCPT ); Wed, 5 Oct 2011 12:24:16 -0400 Date: Wed, 5 Oct 2011 18:19:14 +0200 From: Oleg Nesterov To: Srikar Dronamraju Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Linux-mm , Arnaldo Carvalho de Melo , Linus Torvalds , Jonathan Corbet , Hugh Dickins , Christoph Hellwig , Masami Hiramatsu , Thomas Gleixner , Andi Kleen , LKML , Jim Keniston , Roland McGrath , Ananth N Mavinakayanahalli , Andrew Morton Subject: Re: [PATCH v5 3.1.0-rc4-tip 9/26] Uprobes: Background page replacement. Message-ID: <20111005161914.GA903@redhat.com> References: <20110920115938.25326.93059.sendpatchset@srdronam.in.ibm.com> <20110920120137.25326.72005.sendpatchset@srdronam.in.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110920120137.25326.72005.sendpatchset@srdronam.in.ibm.com> User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/20, Srikar Dronamraju wrote: > > +int __weak read_opcode(struct task_struct *tsk, unsigned long vaddr, > + uprobe_opcode_t *opcode) > +{ > + struct vm_area_struct *vma; > + struct page *page; > + void *vaddr_new; > + int ret; > + > + ret = get_user_pages(tsk, tsk->mm, vaddr, 1, 0, 0, &page, &vma); > + if (ret <= 0) > + return ret; > + ret = -EINVAL; > + > + /* > + * We are interested in text pages only. Our pages of interest > + * should be mapped for read and execute only. We desist from > + * adding probes in write mapped pages since the breakpoints > + * might end up in the file copy. > + */ > + if (!valid_vma(vma)) > + goto put_out; Another case when valid_vma() looks suspicious. We are going to restore the original instruction. We shouldn't fail (at least we shouldn't "leak" ->mm_uprobes_count) if ->vm_flags was changed between register_uprobe() and unregister_uprobe(). Oleg.