Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3010117ybi; Mon, 17 Jun 2019 14:36:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+uD06NlUXg+mj9gmyHl7D8OUf7hINL0e1g2TBz5bPsf0W2E5Vt2x14oh60saS4kpG2Sn4 X-Received: by 2002:a62:584:: with SMTP id 126mr6277597pff.73.1560807412250; Mon, 17 Jun 2019 14:36:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560807412; cv=none; d=google.com; s=arc-20160816; b=aLCJaMPmjIRc94Cznn7YosKcH7BhfAHcS6Z1IhfDzzn7oRrIAeRH5spZkL7Df+oeHv d5mzKwaEsczJnBBENIL9GY1ACO4DCquEuizVj7GvhheMQsvC0WvIZXAYN/cFPtkM1Dme Bwp53yV95Hy0U3HPZYkjN5Jd6lE2vqMh3lW6Bx0PI1xxp31QyzFZZ0LznneUfwWiIofH gdWbx4VcC2yo+WRsfj+SoPCJlXl5t7Kncgr6xWAmFIAYifJ3YkcXQKAcfANiCxZnxFah yq67w3Og3EvqsRoE0PiEA9el0aJ464yNDTSldwPlwFSPxmhSjQ4HGg+m7odo5Uqrewhi R0Tw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZQNvWFWygP5ni2eLWKyPjWbweTv1BuBhFO75W6xh1JM=; b=wgSHE94HyLSU5qa73H6ls2g5dgZ9SD90nFaOPYOwkLRdB6ao+k9C6pb40ineSc/TXO boJQrOTKl6oxTAwIQ/Jd6GvVSYrohWz0xhDLhVybT/uKyGF2r1N4Ilwo4GZ3UgpcPfb6 4ZA42f397QwsC6uE4Gq1wWofGa6oB9gvgKuMGh1HO7vO9ELDyEt9AXxdektct4mExko9 vhsnh8x0UZSEjEPitxE3WVxqY+pL6DviLNPQm9V58EjuBK+WWBUoiYRelEGSks/kbtWo nk0Zsx2EmigUJyxu45/U0cbRhtpv5HmDOrUNc3Te9j/GzrZNXWW8h0zow6cpkt8UMlhG 1nLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=T1Jju1cx; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si10838376plz.148.2019.06.17.14.36.37; Mon, 17 Jun 2019 14:36:52 -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=@kernel.org header.s=default header.b=T1Jju1cx; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729307AbfFQVVN (ORCPT + 99 others); Mon, 17 Jun 2019 17:21:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:45656 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729283AbfFQVVL (ORCPT ); Mon, 17 Jun 2019 17:21:11 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 389D52133F; Mon, 17 Jun 2019 21:21:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560806470; bh=9TW6nDFtpQbe3fp7IK28uSIKJirN5VvFnYjgLlKLX1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T1Jju1cxhzZiL7pGCNjmTvTzPckc8WBaW/ahMKDhQK04JamCKS/cWixrIDKSlD682 RyZNuMH6AuzEf99m3Yp/pdF8b5gpFl2srnpmFOh3CFi8WIUbdMpewRsPMz2D9cIz+c H/1EtVtfVnu9tsOGlirmzsyiqpGyZbWMiyceEsqE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yonghong Song , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.1 063/115] tools/bpftool: move set_max_rlimit() before __bpf_object__open_xattr() Date: Mon, 17 Jun 2019 23:09:23 +0200 Message-Id: <20190617210803.429088914@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190617210759.929316339@linuxfoundation.org> References: <20190617210759.929316339@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit ac4e0e055fee5751c78bba1fc9ce508a6874d916 ] For a host which has a lower rlimit for max locked memory (e.g., 64KB), the following error occurs in one of our production systems: # /usr/sbin/bpftool prog load /paragon/pods/52877437/home/mark.o \ /sys/fs/bpf/paragon_mark_21 type cgroup/skb \ map idx 0 pinned /sys/fs/bpf/paragon_map_21 libbpf: Error in bpf_object__probe_name():Operation not permitted(1). Couldn't load basic 'r0 = 0' BPF program. Error: failed to open object file The reason is due to low locked memory during bpf_object__probe_name() which probes whether program name is supported in kernel or not during __bpf_object__open_xattr(). bpftool program load already tries to relax mlock rlimit before bpf_object__load(). Let us move set_max_rlimit() before __bpf_object__open_xattr(), which fixed the issue here. Fixes: 47eff61777c7 ("bpf, libbpf: introduce bpf_object__probe_caps to test BPF capabilities") Signed-off-by: Yonghong Song Signed-off-by: Alexei Starovoitov Signed-off-by: Sasha Levin --- tools/bpf/bpftool/prog.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index d2be5a06c339..ed8ef5c82256 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -873,6 +873,8 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) } } + set_max_rlimit(); + obj = __bpf_object__open_xattr(&attr, bpf_flags); if (IS_ERR_OR_NULL(obj)) { p_err("failed to open object file"); @@ -952,8 +954,6 @@ static int load_with_options(int argc, char **argv, bool first_prog_only) goto err_close_obj; } - set_max_rlimit(); - err = bpf_object__load(obj); if (err) { p_err("failed to load object file"); -- 2.20.1