Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp501907pxx; Wed, 28 Oct 2020 09:46:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxuzr/Ul2ZkRZ8Lczt8Mhh5XJ2JS0McsH20OqWAGqmhGp3XwrL2mHYvFYvnyA9QLdq4wek9 X-Received: by 2002:a17:906:bc91:: with SMTP id lv17mr8704264ejb.249.1603903567908; Wed, 28 Oct 2020 09:46:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603903567; cv=none; d=google.com; s=arc-20160816; b=sbZANZG6K4A99TImXs86AM71++O+TLV2O5OCXt/tvVIVsj0sxwzqc6F7wzThdd/UKx Goj5yR6dd/YpGAuwnNIESG6Lll4HPRxti3L0nxT/gRdAGTAJzaYNPQiHEZOcjKHHTxMs 90iZ6wGSazMbINHbqVF8oMxblAyaBnEgeJWHXZpeL+hI8qlUVvJSm9c1uz+lEV0WkU2t U11X3WntXoAXGEkEO7PArT9zGi/bppiFg/MTs3saJSk5u44Dzc6bfSc+l9B8zs8f7GS5 2G1xcCbtGjyp0r51b9e/N7K23U8cPMyER1uOLUD8Q55kvRn2NVgsAxz4vr8zX/BlAL7+ uqhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cMEbv5gc/qTX+lZ17x55jfcivhfC6g7CwN+Hlk4/W4Q=; b=qj6YECuF7otsY9ODqaXlpAmC5bAuRJ0lEOetmcz480C/JKhFIp3INK5kTflOIm9mV7 lnOmJZm3z5n7RRJ/c8dSHEg1pGliYdJRoRxLEVxUAG+ghJfCB6abZ07zBOy4oej0eW3s fxG7X0ySKC+wnYgRopiIClw7/STutcG3ADhbAoLQnAUyyP4zrYrXSuvR3DGeTw9tQM1h mMD2gvVLfB1zplBbY6UqSx+QkyhS8j1wxuGvoaINv4jwtJPVm71OJm8CLEoh+yy/6JOt Yp3Nf6ARuhGQSMOzGJOk7G5nyCzKdQaBo/mH+VH5QUJIf+fcgpe5WUraz3Q4WxM17hwM BciA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LUltvPd8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r21si3290edo.519.2020.10.28.09.45.44; Wed, 28 Oct 2020 09:46:07 -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=@kernel.org header.s=default header.b=LUltvPd8; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818370AbgJ0RTS (ORCPT + 99 others); Tue, 27 Oct 2020 13:19:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:58196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1782517AbgJ0O5S (ORCPT ); Tue, 27 Oct 2020 10:57:18 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 82B6522264; Tue, 27 Oct 2020 14:57:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810638; bh=FnOc2oimdimLgd4+mYKGyCjBzGqGhr+vJrVsviBb8Mo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LUltvPd8zgyutynDkMUHPnFG8L6r1PGu9BDL0fP1UqCH5hOKK20khMmHoaVp40P3z F3x9reQjkx7Z/sB0JDXmZ08DwwuRqGo+OUOeALoBbaYYRzs5VEM8DuQblSfEFlD4E8 tLHzmKg77H53z5abrd8NrDE3rNafl/YCA7jdBzdQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alex Gartrell , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.8 179/633] libbpf: Fix unintentional success return code in bpf_object__load Date: Tue, 27 Oct 2020 14:48:42 +0100 Message-Id: <20201027135531.084985113@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Gartrell [ Upstream commit ef05afa66c59c2031a3798916ef3ff3778232129 ] There are code paths where EINVAL is returned directly without setting errno. In that case, errno could be 0, which would mask the failure. For example, if a careless programmer set log_level to 10000 out of laziness, they would have to spend a long time trying to figure out why. Fixes: 4f33ddb4e3e2 ("libbpf: Propagate EPERM to caller on program load") Signed-off-by: Alex Gartrell Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20200826075549.1858580-1-alexgartrell@gmail.com Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 236c91aff48f8..e4d304247c1ba 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -5253,7 +5253,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt, free(log_buf); goto retry_load; } - ret = -errno; + ret = errno ? -errno : -LIBBPF_ERRNO__LOAD; cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg)); pr_warn("load bpf program failed: %s\n", cp); pr_perm_msg(ret); -- 2.25.1