Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp885028rwi; Wed, 19 Oct 2022 04:18:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7ECKInghtIOkW3jd8AJjJ2e9TH+eOG4SGNEJ7zatfz/uLwGvZJ6UkoQUFZKUPnQMwziva8 X-Received: by 2002:a17:90b:3ecd:b0:20d:9ddb:f287 with SMTP id rm13-20020a17090b3ecd00b0020d9ddbf287mr40350307pjb.167.1666178294829; Wed, 19 Oct 2022 04:18:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178294; cv=none; d=google.com; s=arc-20160816; b=XVeDlkACU6UmMXU2p+QbF6yQO3ClJlLmooNeivbLd2Uv7smMF+w4nEljDRuwNlPajU uUNW3HE4hzCSsq8IFMtLduxkqjWTGAvbA+vLxQbKuNQ1Mm86AlOq7d2nz7RnQR2hRzCl mtTSlFDacJfF/gTtKPS1THKUwnSwb/m1AbM8Gz5o2ZCG5oWa7BnK/ABVKbCkV6M+Lelc jCq4HcvOCvnWl+M6Pc5Yy5f1MLfooX0kVeRJMmFhiajzTArSWCkEfqiD0MRcasTJzGKQ GyBltiXmVF++z0QEhqze3SlcMyI6T7pr3QgXKFibezn9p6iMqb2wctfnZ8Th/rirgeqF IBvQ== 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=A542ofY7gZrMwXmPtbt2afpPGQOb8oRq6zVNIkCWupY=; b=tDXouBKNVRa8S80gTFpgSKkLnDoC86/KA7iCZo1hkYwmVeNL3m8R4KdCbCU5nbMm9R CYo/hMNCb/MpAdhLu67JHQ53WWYJTn2QiFwV1qEItByQLKjsYPMBpYjrQQNkvjpNq07V dUDhB0LcLX8V30Tb7tufnV9x20f7nPCikHKAzB9jSG7L8VPZV3TbI//EL7wpUWqsDsJu UQgiMDNIfpzcjCOvRckKDeDkOIaurTz+PE3SiUGqUvt2RC6YF/PGqZb+ACP8fgyh0l1W twt5v5efdorQ/WBhetBRPDPoQWrTfnX3JO2N9wFENfg4jjYGoHwbQ3gFeLpOQ50Bv1Jk XFvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="U/wul6mN"; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f1-20020a637541000000b0045a2b6e23b6si18560809pgn.290.2022.10.19.04.18.02; Wed, 19 Oct 2022 04:18:14 -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=@linuxfoundation.org header.s=korg header.b="U/wul6mN"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234799AbiJSLDC (ORCPT + 99 others); Wed, 19 Oct 2022 07:03:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234791AbiJSLCj (ORCPT ); Wed, 19 Oct 2022 07:02:39 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DCD0AE86A; Wed, 19 Oct 2022 03:32:02 -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 ams.source.kernel.org (Postfix) with ESMTPS id 81632B824AC; Wed, 19 Oct 2022 09:09:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D94EAC433D7; Wed, 19 Oct 2022 09:09:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170590; bh=ViUItGQxEFe5clm+nOnl0yUEomw7O/ntvn4zFXwEoTs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U/wul6mNsT4M/WLJKotjcoXs18B+ZrXfyZNIODJpDMRxg0Y4wt+YYVh/Gvv6Q7C8F kgAVWYwlGZPjG0lOLFRXZoQTbARXDVYkJ0FEjdSczZKlFz+/Jjkys5M/aqN/0KyUn+ rXnOxkkZNZqvZH/3mCI5FkvbfMYxCLHct4exXcSg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Goro Fuji , Hengqi Chen , Andrii Nakryiko , Sasha Levin Subject: [PATCH 6.0 680/862] libbpf: Do not require executable permission for shared libraries Date: Wed, 19 Oct 2022 10:32:47 +0200 Message-Id: <20221019083320.022071682@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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(-) --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -10667,15 +10667,17 @@ static const char *arch_specific_lib_pat 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++) { @@ -10694,8 +10696,8 @@ static int resolve_full_path(const char 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;