Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3978395rwb; Sun, 9 Oct 2022 15:10:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5hHjfOe59b0ZLDYmD1JFIUDEAK0zJEAEQ6E5TQDPjQosyJKGeCaGRV2OWm/v/vllh8QSgh X-Received: by 2002:a17:907:7e83:b0:782:7c78:3828 with SMTP id qb3-20020a1709077e8300b007827c783828mr12528599ejc.7.1665353421620; Sun, 09 Oct 2022 15:10:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665353421; cv=none; d=google.com; s=arc-20160816; b=s0mB+u7C1RBwXRIAJ4j/sXZG8IuuZ/rsOGGEBUyQkv2n3nN5OZo6sVsntKAy8KFUAb Qq0xb9KDKrFGQIqp6MszDhTlxgGDmKTpRuPjAAADYto9s/E9+sf3bGSf0y/c/xzY6P9R JZmTcTYRlL1cITXsHsiPYvn1SIYNZSvyOnaH08U94sAOqKpcrK5D3Ag9dfO82PNLKaPG pZTot00RKl1zTdGFjTLhQegMBWG7DSYu7dpo822KZXrEEQfsQSCz9ZpKXuPHFLk3+M2O aUtKIuGERS17ZKSsUExKjd03b8azopNoI0vPPQVzITQZ18jIbMzD0wVJz0LJZUIwEw6L aYNQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZDQCqO4UnPrtRdp5KbEsvJFqpJrCu8wRQpQTTLKIfO4=; b=WAlhxxkQ+GIvtKJbmWLwy+75r6yF5cp4VBK6YwSNzFZjINeiD07oPH0URCH+jzjq5m nBeXhY+X4x1l0reg/Tu0GQdA7jyC6F13ZJ8w0XTERF/kFgsVQRHOamwmbaV/L7aSTPWV mB7Z2jZ0vhaqB1RK3KEaTXUB1im8PRr2XI1b6G0zE0DS2X6mcaHj/xZWA78Dyak00spo Ue9p8tQhkOhKHRr/mnvc4AVB1oFtHNk70hgrl4D4JCQYh83bGtlP+A9krxc8jmj5l6wM J/Kzo/KYoLHri3rxzXQVi7AgRHZ+hDCwCKaEJismq65oqSkM7f2jJJGdR6uuQFfi64Fj CF9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XJN4bnnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eb10-20020a0564020d0a00b00457fb8f2a64si10595850edb.563.2022.10.09.15.09.53; Sun, 09 Oct 2022 15:10:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XJN4bnnS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230253AbiJIWIE (ORCPT + 99 others); Sun, 9 Oct 2022 18:08:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40526 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230236AbiJIWIA (ORCPT ); Sun, 9 Oct 2022 18:08:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1666A275D5; Sun, 9 Oct 2022 15:08:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A78C560C93; Sun, 9 Oct 2022 22:07:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 252CFC4347C; Sun, 9 Oct 2022 22:07:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665353279; bh=rtZm1ZNYm9K689JvinO0L3Z4ajEDSTjzpaS8oPPrgBs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJN4bnnSc7NRFwWg4AsG2fNjfGxlqKZaKA2giKBpo0kVDlVggAplfetauU609J8BK +XKCJXkcenB2/TTXThUDdP2S1Ou+v2VNhd1x8XI9alvbq4js6v+4u/sr/x78SnMX9o QD7tZK67B/iCzgGV3skaiK53G+8Jm9CRrBBM6tXAdtQUoeQhOLiIknvLponB/U65je L+lt/6REVkMaNgwmwcHbgoxT8o6bkXcrBDDC8cVLB7oNCy0/t9ex6kndigt5SGkeCW MbrIcIYX2kYIbBpAYTP4r9yQ3uRL4yKAosjhBcC1IZ1FKRMdJq/ScixF3Gd4WPfu6Y AYNRTQ3LRKW6Q== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hengqi Chen , Goro Fuji , Andrii Nakryiko , Sasha Levin , ast@kernel.org, daniel@iogearbox.net, bpf@vger.kernel.org Subject: [PATCH AUTOSEL 6.0 02/77] libbpf: Do not require executable permission for shared libraries Date: Sun, 9 Oct 2022 18:06:39 -0400 Message-Id: <20221009220754.1214186-2-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009220754.1214186-1-sashal@kernel.org> References: <20221009220754.1214186-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hengqi Chen [ Upstream commit 9e32084ef1c33a87a736d6ce3fcb95b60dac9aa1 ] Currently, resolve_full_path() requires executable permission for both programs and shared libraries. This causes failures on distos like Debian since the shared libraries are not installed executable and Linux is not requiring shared libraries to have executable permissions. Let's remove executable permission check for shared libraries. Reported-by: Goro Fuji Signed-off-by: Hengqi Chen Signed-off-by: Andrii Nakryiko Link: https://lore.kernel.org/bpf/20220806102021.3867130-1-hengqi.chen@gmail.com Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 50d41815f431..c09a781d31bb 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -10662,15 +10662,17 @@ static const char *arch_specific_lib_paths(void) static int resolve_full_path(const char *file, char *result, size_t result_sz) { const char *search_paths[3] = {}; - int i; + int i, perm; if (str_has_sfx(file, ".so") || strstr(file, ".so.")) { search_paths[0] = getenv("LD_LIBRARY_PATH"); search_paths[1] = "/usr/lib64:/usr/lib"; search_paths[2] = arch_specific_lib_paths(); + perm = R_OK; } else { search_paths[0] = getenv("PATH"); search_paths[1] = "/usr/bin:/usr/sbin"; + perm = R_OK | X_OK; } for (i = 0; i < ARRAY_SIZE(search_paths); i++) { @@ -10689,8 +10691,8 @@ static int resolve_full_path(const char *file, char *result, size_t result_sz) if (!seg_len) continue; snprintf(result, result_sz, "%.*s/%s", seg_len, s, file); - /* ensure it is an executable file/link */ - if (access(result, R_OK | X_OK) < 0) + /* ensure it has required permissions */ + if (access(result, perm) < 0) continue; pr_debug("resolved '%s' to '%s'\n", file, result); return 0; -- 2.35.1