Received: by 2002:a17:90b:8d0:0:0:0:0 with SMTP id ds16csp5078750pjb; Mon, 27 Jul 2020 12:21:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGgAiwMPk2QI/G8LoaGYKev08CrW2Q7zix+jC+eoW2bO4AQQWrzvOyE0NDpMcy+m9yybnx X-Received: by 2002:a17:906:22c1:: with SMTP id q1mr13396139eja.443.1595877711914; Mon, 27 Jul 2020 12:21:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595877711; cv=none; d=google.com; s=arc-20160816; b=PEewga3UHGOjiI50kjpi4s9poFcGlDfgzvpTJ6Kk8kqhVr7zR7yBuoR9ddqCTqWtDV Z7kcMQm4IJizZXKMjAgPq/MNdbK1bOdlzJ+LJfBWYAs3pBRlbcNKwA3L2BUc0yWjAxah FP0UEqGKoJkZY1/t/WDvO8lHPcoVBcxvvZcmvi7/rVS4RrQBjNytfIX3GYgzLNC9oz/2 LXJXZDOt3qJKcRa8zm2mw/ayc9SXvUggJX1+/YEgT46xAs6Iy07awWifqeUzIV5Tol85 L+j+QQEowGzrUg6Z7/4dgAPAvOM/Id+intmEcnzPgKaCLOH8gW9QvOCqokM5LIEX0tNa y5Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:smtp-origin-cluster :cc:to:smtp-origin-hostname:from:smtp-origin-hostprefix :dkim-signature; bh=oEnmyUCkDbp6GsiBTaBZObGYGFPu+HplQnEkNgp2CuY=; b=mo9PyAhJ1tdXIgbRbgVYq4Rb0FA2Gi/gnz+CYtd6WNgVQQFF7B+ioCv4/t+NcbL4cZ uPS/CpTvI2cpvb61Y9o6nt5YeHeiOa2/oBw/7VPRO0Z7B4pORjw1VwGh3ApP/jzkNJUJ sSh04skhKLAqRrgV6P1YoYug/aOXmZafilPGYGRblh5KGzLwXussCDIR1hJSLPpAA+6w EYy5AxrrjpkqhTdcQan6J5Vh2iSENemJmAxXN4ObjBKlT9/crQ5FuP35MBHwSWLnpmZm xxQ3VWjM9ixS3b7LGmzxijc37AoA77BfkrkHx80/snX8TDlS43s6sU4suGYbkFZDO9uP d83w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=GFG5oYLB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si6084669edr.497.2020.07.27.12.21.30; Mon, 27 Jul 2020 12:21:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@fb.com header.s=facebook header.b=GFG5oYLB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=fb.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732222AbgG0SqK (ORCPT + 99 others); Mon, 27 Jul 2020 14:46:10 -0400 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:37602 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732135AbgG0Sp7 (ORCPT ); Mon, 27 Jul 2020 14:45:59 -0400 Received: from pps.filterd (m0148460.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 06RIiMsC009832 for ; Mon, 27 Jul 2020 11:45:57 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=facebook; bh=oEnmyUCkDbp6GsiBTaBZObGYGFPu+HplQnEkNgp2CuY=; b=GFG5oYLByL2Fq9EFd3YRNmtcGqo7PK7FVxXTjeE6We89i27k27x3wzofTTpr1Kt6RCwe gCGUO7IXL1+EUuhrvtmFOaNFytCljsyk0r3oTxMrh7Efav1gF6ApDl8+fbdGDSnzq68a gp0DP+zrUovgNgohOPCo3t7czX+hsiVVR24= Received: from maileast.thefacebook.com ([163.114.130.16]) by mx0a-00082601.pphosted.com with ESMTP id 32gj8kga7d-10 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Mon, 27 Jul 2020 11:45:57 -0700 Received: from intmgw002.41.prn1.facebook.com (2620:10d:c0a8:1b::d) by mail.thefacebook.com (2620:10d:c0a8:83::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Mon, 27 Jul 2020 11:45:27 -0700 Received: by devvm1096.prn0.facebook.com (Postfix, from userid 111017) id 253331DAFEAB; Mon, 27 Jul 2020 11:45:11 -0700 (PDT) Smtp-Origin-Hostprefix: devvm From: Roman Gushchin Smtp-Origin-Hostname: devvm1096.prn0.facebook.com To: CC: , Alexei Starovoitov , Daniel Borkmann , , , Roman Gushchin Smtp-Origin-Cluster: prn0c01 Subject: [PATCH bpf-next v2 29/35] bpf: libbpf: cleanup RLIMIT_MEMLOCK usage Date: Mon, 27 Jul 2020 11:45:00 -0700 Message-ID: <20200727184506.2279656-30-guro@fb.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200727184506.2279656-1-guro@fb.com> References: <20200727184506.2279656-1-guro@fb.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-FB-Internal: Safe Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235,18.0.687 definitions=2020-07-27_13:2020-07-27,2020-07-27 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 adultscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 suspectscore=13 bulkscore=0 priorityscore=1501 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2007270127 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As bpf is not using memlock rlimit for memory accounting anymore, let's remove the related code from libbpf. Bpf operations can't fail because of exceeding the limit anymore. Signed-off-by: Roman Gushchin --- tools/lib/bpf/libbpf.c | 31 +------------------------------ tools/lib/bpf/libbpf.h | 5 ----- 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e51479d60285..841060f5cee3 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -112,32 +112,6 @@ void libbpf_print(enum libbpf_print_level level, con= st char *format, ...) va_end(args); } =20 -static void pr_perm_msg(int err) -{ - struct rlimit limit; - char buf[100]; - - if (err !=3D -EPERM || geteuid() !=3D 0) - return; - - err =3D getrlimit(RLIMIT_MEMLOCK, &limit); - if (err) - return; - - if (limit.rlim_cur =3D=3D RLIM_INFINITY) - return; - - if (limit.rlim_cur < 1024) - snprintf(buf, sizeof(buf), "%zu bytes", (size_t)limit.rlim_cur); - else if (limit.rlim_cur < 1024*1024) - snprintf(buf, sizeof(buf), "%.1f KiB", (double)limit.rlim_cur / 1024); - else - snprintf(buf, sizeof(buf), "%.1f MiB", (double)limit.rlim_cur / (1024*= 1024)); - - pr_warn("permission error while running as root; try raising 'ulimit -l= '? current value: %s\n", - buf); -} - #define STRERR_BUFSIZE 128 =20 /* Copied from tools/perf/util/util.h */ @@ -3420,8 +3394,7 @@ bpf_object__probe_loading(struct bpf_object *obj) cp =3D libbpf_strerror_r(ret, errmsg, sizeof(errmsg)); pr_warn("Error in %s():%s(%d). Couldn't load trivial BPF " "program. Make sure your kernel supports BPF " - "(CONFIG_BPF_SYSCALL=3Dy) and/or that RLIMIT_MEMLOCK is " - "set to big enough value.\n", __func__, cp, ret); + "(CONFIG_BPF_SYSCALL=3Dy)", __func__, cp, ret); return -ret; } close(ret); @@ -3918,7 +3891,6 @@ bpf_object__create_maps(struct bpf_object *obj) err_out: cp =3D libbpf_strerror_r(err, errmsg, sizeof(errmsg)); pr_warn("map '%s': failed to create: %s(%d)\n", map->name, cp, err); - pr_perm_msg(err); for (j =3D 0; j < i; j++) zclose(obj->maps[j].fd); return err; @@ -5419,7 +5391,6 @@ load_program(struct bpf_program *prog, struct bpf_i= nsn *insns, int insns_cnt, ret =3D -errno; cp =3D libbpf_strerror_r(errno, errmsg, sizeof(errmsg)); pr_warn("load bpf program failed: %s\n", cp); - pr_perm_msg(ret); =20 if (log_buf && log_buf[0] !=3D '\0') { ret =3D -LIBBPF_ERRNO__VERIFY; diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index c6813791fa7e..8d2f1194cb02 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -610,11 +610,6 @@ bpf_prog_linfo__lfind(const struct bpf_prog_linfo *p= rog_linfo, =20 /* * Probe for supported system features - * - * Note that running many of these probes in a short amount of time can = cause - * the kernel to reach the maximal size of lockable memory allowed for t= he - * user, causing subsequent probes to fail. In this case, the caller may= want - * to adjust that limit with setrlimit(). */ LIBBPF_API bool bpf_probe_prog_type(enum bpf_prog_type prog_type, __u32 ifindex); --=20 2.26.2