[{"id":1761467,"web_url":"http://patchwork.ozlabs.org/comment/1761467/","msgid":"<87r2vr57jq.fsf@concordia.ellerman.id.au>","date":"2017-09-01T05:09:29","subject":"Re: [PATCH] uprobe: Warn if unable to install breakpoint","submitter":{"id":46580,"url":"http://patchwork.ozlabs.org/api/people/46580/","name":"Michael Ellerman","email":"mpe@ellerman.id.au"},"content":"\"Naveen N. Rao\" <naveen.n.rao@linux.vnet.ibm.com> writes:\n\n> When we try to install a uprobe breakpoint in uprobe_mmap(), we ignore\n> all errors encountered in the process per this comment at the top of\n> the function:\n>     /*\n>      * Called from mmap_region/vma_adjust with mm->mmap_sem acquired.\n>      *\n>      * Currently we ignore all errors and always return 0, the callers\n>      * can't handle the failure anyway.\n>      */\n>\n> However, this is very confusing for users since no probe hits are\n> recorded nor is an error logged in dmesg.\n>\n> Fix this by logging an error in dmesg so that users can discover that\n> there was an issue with the uprobe. To facilitate use of uprobe_warn(),\n> we move that function to the top of the file.\n>\n> With this patch, we see a message similar to this in dmesg:\n>     [  201.449213] uprobe: uprobe_t:9740 failed to setup probe at 0x95c (-524)\n>\n> Reported-by: Anton Blanchard <anton@samba.org>\n> Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>\n> ---\n>  kernel/events/uprobes.c | 21 ++++++++++++++-------\n>  1 file changed, 14 insertions(+), 7 deletions(-)\n>\n> diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c\n> index 0e137f98a50c..587c591a535c 100644\n> --- a/kernel/events/uprobes.c\n> +++ b/kernel/events/uprobes.c\n> @@ -112,6 +112,12 @@ struct xol_area {\n>  \tunsigned long \t\t\tvaddr;\t\t/* Page(s) of instruction slots */\n>  };\n>  \n> +static void uprobe_warn(struct task_struct *t, const char *msg)\n> +{\n> +\tpr_warn(\"uprobe: %s:%d failed to %s\\n\",\n> +\t\t\tcurrent->comm, current->pid, msg);\n\nThat should probably be ratelimited no?\n\ncheers","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xk6lG5qMBz9s81\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 15:10:50 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xk6lG4zldzDqlx\n\tfor <patchwork-incoming@ozlabs.org>;\n\tFri,  1 Sep 2017 15:10:50 +1000 (AEST)","from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xk6jm1spZzDqZ7\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri,  1 Sep 2017 15:09:32 +1000 (AEST)","from authenticated.ozlabs.org (localhost [127.0.0.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPSA id 3xk6jm0gfZz9sPt;\n\tFri,  1 Sep 2017 15:09:32 +1000 (AEST)"],"From":"Michael Ellerman <mpe@ellerman.id.au>","To":"\"Naveen N. Rao\" <naveen.n.rao@linux.vnet.ibm.com>,\n\tIngo Molnar <mingo@kernel.org>","Subject":"Re: [PATCH] uprobe: Warn if unable to install breakpoint","In-Reply-To":"<20170831183215.4306-1-naveen.n.rao@linux.vnet.ibm.com>","References":"<20170831183215.4306-1-naveen.n.rao@linux.vnet.ibm.com>","User-Agent":"Notmuch/0.21 (https://notmuchmail.org)","Date":"Fri, 01 Sep 2017 15:09:29 +1000","Message-ID":"<87r2vr57jq.fsf@concordia.ellerman.id.au>","MIME-Version":"1.0","Content-Type":"text/plain","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.23","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Srikar Dronamraju <srikar@linux.vnet.ibm.com>,\n\tlinuxppc-dev@lists.ozlabs.org, Anton Blanchard <anton@samba.org>,\n\tOleg Nesterov <oleg@redhat.com>, linux-kernel@vger.kernel.org","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}},{"id":1768100,"web_url":"http://patchwork.ozlabs.org/comment/1768100/","msgid":"<20170913191650.f57qytp7ztvwihy6@naverao1-tp.localdomain>","date":"2017-09-13T19:16:50","subject":"Re: [PATCH] uprobe: Warn if unable to install breakpoint","submitter":{"id":15185,"url":"http://patchwork.ozlabs.org/api/people/15185/","name":"Naveen N. Rao","email":"naveen.n.rao@linux.vnet.ibm.com"},"content":"On 2017/09/01 03:09PM, Michael Ellerman wrote:\n> \"Naveen N. Rao\" <naveen.n.rao@linux.vnet.ibm.com> writes:\n> \n> > When we try to install a uprobe breakpoint in uprobe_mmap(), we ignore\n> > all errors encountered in the process per this comment at the top of\n> > the function:\n> >     /*\n> >      * Called from mmap_region/vma_adjust with mm->mmap_sem acquired.\n> >      *\n> >      * Currently we ignore all errors and always return 0, the callers\n> >      * can't handle the failure anyway.\n> >      */\n> >\n> > However, this is very confusing for users since no probe hits are\n> > recorded nor is an error logged in dmesg.\n> >\n> > Fix this by logging an error in dmesg so that users can discover that\n> > there was an issue with the uprobe. To facilitate use of uprobe_warn(),\n> > we move that function to the top of the file.\n> >\n> > With this patch, we see a message similar to this in dmesg:\n> >     [  201.449213] uprobe: uprobe_t:9740 failed to setup probe at 0x95c (-524)\n> >\n> > Reported-by: Anton Blanchard <anton@samba.org>\n> > Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>\n> > ---\n> >  kernel/events/uprobes.c | 21 ++++++++++++++-------\n> >  1 file changed, 14 insertions(+), 7 deletions(-)\n> >\n> > diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c\n> > index 0e137f98a50c..587c591a535c 100644\n> > --- a/kernel/events/uprobes.c\n> > +++ b/kernel/events/uprobes.c\n> > @@ -112,6 +112,12 @@ struct xol_area {\n> >  \tunsigned long \t\t\tvaddr;\t\t/* Page(s) of instruction slots */\n> >  };\n> >  \n> > +static void uprobe_warn(struct task_struct *t, const char *msg)\n> > +{\n> > +\tpr_warn(\"uprobe: %s:%d failed to %s\\n\",\n> > +\t\t\tcurrent->comm, current->pid, msg);\n> \n> That should probably be ratelimited no?\n\nUprobes can only be installed by root today, so it is not as bad. But, I \ndo agree that it is good to ratelimit. I will send a subsequent patch to \ndo this.\n\nThanks for the review,\n- Naveen","headers":{"Return-Path":"<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>","X-Original-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Delivered-To":["patchwork-incoming@ozlabs.org","linuxppc-dev@lists.ozlabs.org"],"Received":["from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\t(using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xss6x5Ftjz9ryQ\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 14 Sep 2017 05:24:41 +1000 (AEST)","from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 3xss6x3rS6zDqws\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 14 Sep 2017 05:24:41 +1000 (AEST)","from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com\n\t[148.163.156.1])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 3xsrzZ62LyzDqpb\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tThu, 14 Sep 2017 05:18:18 +1000 (AEST)","from pps.filterd (m0098404.ppops.net [127.0.0.1])\n\tby mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id\n\tv8DJFPij100753\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 13 Sep 2017 15:18:15 -0400","from e23smtp06.au.ibm.com (e23smtp06.au.ibm.com [202.81.31.148])\n\tby mx0a-001b2d01.pphosted.com with ESMTP id 2cy5jj9478-1\n\t(version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT)\n\tfor <linuxppc-dev@lists.ozlabs.org>; Wed, 13 Sep 2017 15:18:14 -0400","from localhost\n\tby e23smtp06.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use\n\tOnly! Violators will be prosecuted\n\tfor <linuxppc-dev@lists.ozlabs.org> from\n\t<naveen.n.rao@linux.vnet.ibm.com>; Thu, 14 Sep 2017 05:18:12 +1000","from d23relay06.au.ibm.com (202.81.31.225)\n\tby e23smtp06.au.ibm.com (202.81.31.212) with IBM ESMTP SMTP Gateway:\n\tAuthorized Use Only! Violators will be prosecuted; \n\tThu, 14 Sep 2017 05:18:09 +1000","from d23av05.au.ibm.com (d23av05.au.ibm.com [9.190.234.119])\n\tby d23relay06.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id\n\tv8DJGsQA37486768\n\tfor <linuxppc-dev@lists.ozlabs.org>; Thu, 14 Sep 2017 05:16:54 +1000","from d23av05.au.ibm.com (localhost [127.0.0.1])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id\n\tv8DJGrgU011932\n\tfor <linuxppc-dev@lists.ozlabs.org>; Thu, 14 Sep 2017 05:16:54 +1000","from localhost ([9.84.217.95])\n\tby d23av05.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id\n\tv8DJGqPW011890; Thu, 14 Sep 2017 05:16:53 +1000"],"Authentication-Results":"ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com\n\t(client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com;\n\tenvelope-from=naveen.n.rao@linux.vnet.ibm.com; receiver=<UNKNOWN>)","Date":"Thu, 14 Sep 2017 00:46:50 +0530","From":"\"Naveen N. Rao\" <naveen.n.rao@linux.vnet.ibm.com>","To":"Michael Ellerman <mpe@ellerman.id.au>","Subject":"Re: [PATCH] uprobe: Warn if unable to install breakpoint","References":"<20170831183215.4306-1-naveen.n.rao@linux.vnet.ibm.com>\n\t<87r2vr57jq.fsf@concordia.ellerman.id.au>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<87r2vr57jq.fsf@concordia.ellerman.id.au>","User-Agent":"NeoMutt/20170714 (1.8.3)","X-TM-AS-MML":"disable","x-cbid":"17091319-0040-0000-0000-00000355FEF8","X-IBM-AV-DETECTION":"SAVI=unused REMOTE=unused XFE=unused","x-cbparentid":"17091319-0041-0000-0000-00000CD64C1A","Message-Id":"<20170913191650.f57qytp7ztvwihy6@naverao1-tp.localdomain>","X-Proofpoint-Virus-Version":"vendor=fsecure engine=2.50.10432:, ,\n\tdefinitions=2017-09-13_06:, , signatures=0","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n\tspamscore=0 suspectscore=0\n\tmalwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam\n\tadjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000\n\tdefinitions=main-1709130295","X-BeenThere":"linuxppc-dev@lists.ozlabs.org","X-Mailman-Version":"2.1.24","Precedence":"list","List-Id":"Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>","List-Unsubscribe":"<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>","List-Archive":"<http://lists.ozlabs.org/pipermail/linuxppc-dev/>","List-Post":"<mailto:linuxppc-dev@lists.ozlabs.org>","List-Help":"<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>","List-Subscribe":"<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>","Cc":"Srikar Dronamraju <srikar@linux.vnet.ibm.com>,\n\tlinux-kernel@vger.kernel.org, \n\tOleg Nesterov <oleg@redhat.com>, Anton Blanchard <anton@samba.org>,\n\tlinuxppc-dev@lists.ozlabs.org, Ingo Molnar <mingo@kernel.org>","Errors-To":"linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org","Sender":"\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>"}}]