Received: by 10.192.165.156 with SMTP id m28csp1035038imm; Wed, 11 Apr 2018 11:11:58 -0700 (PDT) X-Google-Smtp-Source: AIpwx49d3gcu+7IzRjbqy13sS2x1elWkP/LvNuOCPORwEEzNxJwpZPgJsV12oVNfEBxEUASMOf0A X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr6219552plp.355.1523470318168; Wed, 11 Apr 2018 11:11:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523470318; cv=none; d=google.com; s=arc-20160816; b=ycGBjaL3sUD7RvrIv+RnEowlNz0npOCtQNACmIpBAjjb/BX/X8s0xs0ZdODU/WMszb OxqRRao6VL/gvImbMA3tSg85NSVqxcjFU0XyoWFLPwNr2WloLGQiLwR8HC8m4mZ18KWO 5mVc2dTYmeAjPCKLyrhcdrkt0b6got2AZGUIB9Q1LDIoa/SFXsjMSizjESXBXfcUvzRJ G2AcU5+HXOI8LeZWxs9vxGSUoFzJvooFo+rmcjRgsjHIZItrHCtFZVpHofZJHaZ/7dPR sGSlCjDhNvYok1BqvwRMdEtNnvecNYdqQqb+9dw+P7IBUecsQOPZiii9yb04WE0OGtG1 kuQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-id:spamdiagnosticmetadata:spamdiagnosticoutput :content-language:accept-language:in-reply-to:references:message-id :date:thread-index:thread-topic:subject:cc:to:from:dkim-signature :dkim-signature:arc-authentication-results; bh=EQDzWDn55W1uzoom8BwVjcnnl1o8sDzAF5ibUvA8YEE=; b=WeX8KdwysrJLgLr6LISSq6dCf9c31sbV3x2wZoWbo4WvAe9XJbA8vJHD2tZuhX678k 8RMlpvRZcT2TXatbZ9obWeQ/Wu8TIA0iQZW0K2SNzDX1KMuBw46roeJtwFuezwpsWXw9 3RfwekYBjl8bl+JiZ0TuN0tG5BzCT7z62LZeZYtKwZhEz76EIivmjvoC1IVW9Lmaf9nC txQK30pK4rR8RI0u2RkPaX10Dl8/k+F7IXTDXmOQiyAwAHQuCsCQcBJZ0yvQmZYwVLos wTni4ySYsbM4gTP7W484SJXdfj/M0LWcuXDdCrIdCgOdL8u0SyoTtSo2CUhKsk6xzuIk FZyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=pU+WU6DV; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=KzW7lOPJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v90si1242961pfk.350.2018.04.11.11.11.21; Wed, 11 Apr 2018 11:11:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=pU+WU6DV; dkim=pass header.i=@fb.onmicrosoft.com header.s=selector1-fb-com header.b=KzW7lOPJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754150AbeDKSDg (ORCPT + 99 others); Wed, 11 Apr 2018 14:03:36 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:37060 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753116AbeDKSDc (ORCPT ); Wed, 11 Apr 2018 14:03:32 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3BI1Y7M015408; Wed, 11 Apr 2018 11:03:13 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-id : content-transfer-encoding : mime-version; s=facebook; bh=EQDzWDn55W1uzoom8BwVjcnnl1o8sDzAF5ibUvA8YEE=; b=pU+WU6DV2SBG+OJ+hcbxy8EpL7eWwABOu+oWvXHZ4U4gzkyXKvMH1TLViYgMdskvQvCc e+yWdaSUkixDb1jUxlylSRlphpXQ8oHA+VGQYwKxtlIpe0JikkwlaIY3+EwVHHDe2juZ PS4nDv+dNld3nKzkYDvCZTCpcfK4PbSJJDA= Received: from maileast.thefacebook.com ([199.201.65.23]) by mx0a-00082601.pphosted.com with ESMTP id 2h9nnh8ect-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 11 Apr 2018 11:03:13 -0700 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.183.28) by o365-in.thefacebook.com (192.168.177.23) with Microsoft SMTP Server (TLS) id 14.3.361.1; Wed, 11 Apr 2018 14:03:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=EQDzWDn55W1uzoom8BwVjcnnl1o8sDzAF5ibUvA8YEE=; b=KzW7lOPJMZQ6Z0wdDr2FbAzrr5AlAZsUcuwkoETJ8phc5m6ivlNc0zo3vtqtn8wjjmJNUgbuytQmIBTru3QDwaZsHtom7Ckb8MNbtSBSRSYIUyrC5rPv7SG3kyE87SpHwhru9qyRHdkopzY7rFbywO4EMcDzgLRZ0X87/8ZwE1k= Received: from DM5PR15MB1548.namprd15.prod.outlook.com (10.173.222.139) by DM5PR15MB1562.namprd15.prod.outlook.com (10.173.222.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.653.12; Wed, 11 Apr 2018 18:02:37 +0000 Received: from DM5PR15MB1548.namprd15.prod.outlook.com ([fe80::650a:d533:cc4f:3900]) by DM5PR15MB1548.namprd15.prod.outlook.com ([fe80::650a:d533:cc4f:3900%18]) with mapi id 15.20.0653.018; Wed, 11 Apr 2018 18:02:37 +0000 From: Song Liu To: Ingo Molnar CC: Vince Weaver , "linux-kernel@vger.kernel.org" , Peter Zijlstra Subject: Re: perf: fuzzer leads to trace_kprobe: Could not insert message flood Thread-Topic: perf: fuzzer leads to trace_kprobe: Could not insert message flood Thread-Index: AQHT0NsKF6lgcxb36UeZZJCEysMOEaP6arGAgAEOK4CAAGP5AA== Date: Wed, 11 Apr 2018 18:02:37 +0000 Message-ID: References: <20180411120447.2gzrwijrtayjv3eg@gmail.com> In-Reply-To: <20180411120447.2gzrwijrtayjv3eg@gmail.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: Apple Mail (2.3445.6.18) x-originating-ip: [2620:10d:c090:200::4:bb2e] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR15MB1562;7:aBXkthG3FNUB52ajGOGfivQ138d+5Gayels9WP6ybl3vUjN32dD1p/9zFBQQ6Q6pQBswA/Dlef/z6g2X0XgEzaognwyiHX3epbTQAlvueu7OuEFY6WOfXzqFjO22cp41zUf4ilNAPmCdwU48iWuGvKjFt9q1q+WvawTkKNec7sbxavg9vMYhO2lfZj0TmblPV0WGLOIaE7kRs3PBantUg7hn15lNR3qiL1d8ABH9fTRg/PmFbhqZuylGe2EAgR0G;20:Z/2cHmsUu3IugME5jvGJUPdXxBxmZ75krHcezCuYYwC/TlzJbff4AKVr0gsJVwlpWeJ1ARfaG3lMDEmPczuIo6mEIBbKt5tP3aU7xeN36RHIUr+JVlmj99cn27E3xE3x1EKndzbfFn+x+jxhFtaWps3h/V5pDJze7xXBeWe92w0= x-ms-exchange-antispam-srfa-diagnostics: SOS; x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DM5PR15MB1562; x-ms-traffictypediagnostic: DM5PR15MB1562: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(67672495146484); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231221)(11241501184)(944501327)(52105095)(6041310)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR15MB1562;BCL:0;PCL:0;RULEID:;SRVR:DM5PR15MB1562; x-forefront-prvs: 0639027A9E x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(396003)(39860400002)(366004)(346002)(376002)(51914003)(57704003)(189003)(199004)(54906003)(25786009)(57306001)(3660700001)(105586002)(106356001)(186003)(486006)(3280700002)(476003)(2906002)(68736007)(6512007)(15650500001)(229853002)(33656002)(97736004)(4326008)(2900100001)(6436002)(7736002)(305945005)(82746002)(6486002)(478600001)(5250100002)(102836004)(36756003)(6246003)(53936002)(46003)(86362001)(6916009)(6116002)(11346002)(99286004)(83716003)(8936002)(81156014)(81166006)(50226002)(53546011)(6506007)(59450400001)(8676002)(14454004)(5660300001)(76176011)(446003)(316002)(2616005);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR15MB1562;H:DM5PR15MB1548.namprd15.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: fb.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HJoHf9mhrFG20M8d2ndv6l8OED0mcDchXC0mEbrfFIjZ8txAYSLN+MIEBKEHuR2f1QT8+qq6J2YGyKg3ER7cJF+kH75Hem9OvEHt21WArEEj6PKdQYz2iAz5f0y/DhWzFVkOIVzC6ascZfPg2+IUwkCzkGDEerFuzY+T0QdnCmbwAOrEMTgb4IfuduouL9MxCzWDOQ17W98gzOS+3jRTIWMX0WUSDkOm1IzR1aaCvMSU6uOFJCzjorUhBs+pnHsr4ax0onE1mP1Jt0FvQfRNmYEqGuvkDQPN3tV/TaRPwThGGaY8aIOk6hcm/GxbCwr3Ah1BRAeh8jYIgQdIMrI8Ea9MoYi+rMFAFIdkbrQ2s5A29eEXt136TpHBFsTpWwtLXTyN5DH6UJdp9vCw4fF6gb3gpiEfM1B0YRBh4oKVod8= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <763552D62E7F8B4BB68471725BDF2B8F@namprd15.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 869babe2-bbc3-4f4b-aa52-08d59fd66909 X-MS-Exchange-CrossTenant-Network-Message-Id: 869babe2-bbc3-4f4b-aa52-08d59fd66909 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Apr 2018 18:02:37.5758 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR15MB1562 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-11_08:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 11, 2018, at 5:04 AM, Ingo Molnar wrote: >=20 >=20 > * Song Liu wrote: >=20 >>=20 >>=20 >>> On Apr 10, 2018, at 7:48 AM, Vince Weaver wr= ote: >>>=20 >>> Author: Song Liu >>> Date: Wed Dec 6 14:45:15 2017 -0800 >>>=20 >>> When running the perf_fuzzer on a current git checkout my logs are floo= ded=20 >>> with messages such as this: >>> [71487.869077] trace_kprobe: Could not insert probe at unknown+0: -22 >>> [71488.174479] trace_kprobe: Could not insert probe at unknown+0: -22 >>>=20 >>> Presumably this is due to the introduction of the perf_kprobe PMU in >>> commit e12f03d7031a977356e3d7b75a68c2185ff8d155 >>> Author: Song Liu >>> Date: Wed Dec 6 14:45:15 2017 -0800 >>>=20 >>> Is there a way to get this error disabled, or else rate-limited? >>>=20 >>> Vince >>=20 >> Hi Vince,=20 >>=20 >> Thanks for the report.=20 >>=20 >> This is a new API that creates probe together with perf_event_open(). Ba= sed on=20 >> my limited understanding of perf_fuzzer, it doesn't understand this API,= and uses=20 >> it in an abnormal way. [...] >=20 > Vince's point is valid: the kernel log should not be flooded with pointle= ss=20 > messages as a response to user-space ABI uses ... >=20 > Why is there a kernel log message at all, isn't an error returned? >=20 >> [...] I would recommend perf_fuzzer to understand this new API and test = it.=20 >> [...] >=20 > This bug needs to be fixed: a new API must not effectively DoS fuzzing ef= forts by=20 > spamming the kernel log ... Yeah, the new API allows non-root user to trigger this message. We should o= nly=20 allow root to create kprobe with perf_event_open().=20 On the other hand, do we need to fix this for root? In fact, a simple bash = loop=20 can create something similar through the text interface (with root): root@virt-test:~# for x in {0..5} ; do echo p:xx xx+$x >> /sys/kernel/debug= /tracing/kprobe_events ; done -bash: echo: write error: No such file or directory -bash: echo: write error: No such file or directory -bash: echo: write error: No such file or directory -bash: echo: write error: No such file or directory -bash: echo: write error: No such file or directory -bash: echo: write error: No such file or directory root@virt-test:~# dmesg | tail -n 5 [ 664.208374] trace_kprobe: Could not insert probe at xx+1: -2 [ 664.237882] trace_kprobe: Could not insert probe at xx+2: -2 [ 664.268067] trace_kprobe: Could not insert probe at xx+3: -2 [ 664.297395] trace_kprobe: Could not insert probe at xx+4: -2 [ 664.327614] trace_kprobe: Could not insert probe at xx+5: -2 This happens before the new API is introduced.=20 The following patch does capable(CAP_SYS_ADMIN) for perf_kprobe and=20 perf_uprobe at an earlier stage, so non-root user cannot trigger=20 this error message. Please let me know whether we need to fix this=20 for root.=20 Thanks, Song From c6708e9e3cd5ba7afb5a7f693b04abf64fec031e Mon Sep 17 00:00:00 2001 From: Song Liu Date: Wed, 11 Apr 2018 10:37:00 -0700 Subject: [PATCH] perf: need CAP_SYS_ADMIN to create k/uprobe with perf_event_open() Non-root user cannot create kprobe or uprobe through the text-based interface (kprobe_events, uprobe_events). So they cannot create the probes with perf_event_open(). To ensure this, we check capable(CAP_SYS_ADMIN) at perf_[k,u]probe_event_init(). Fixes: e12f03d7031a ("perf/core: Implement the 'perf_kprobe' PMU") Fixes: 33ea4b24277b ("perf/core: Implement the 'perf_uprobe' PMU") Signed-off-by: Song Liu Reported-by: Vince Weaver Cc: Ingo Molnar --- kernel/events/core.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index d7af828..2d5fe26 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -8400,6 +8400,10 @@ static int perf_kprobe_event_init(struct perf_event = *event) if (event->attr.type !=3D perf_kprobe.type) return -ENOENT; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + /* * no branch sampling for probe events */ @@ -8437,6 +8441,10 @@ static int perf_uprobe_event_init(struct perf_event = *event) if (event->attr.type !=3D perf_uprobe.type) return -ENOENT; + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; + /* * no branch sampling for probe events */ -- 2.9.5