From patchwork Wed Oct 19 08:32:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 5176 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp263312wrs; Wed, 19 Oct 2022 04:17:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4E+GXmUMxtkfSOZW0DudyTIGZrqDg3W/VJIJaNc3pi0P5HjSjSCy1XvFdnI4SVGkmbil+b X-Received: by 2002:a17:902:6b88:b0:17e:f177:400 with SMTP id p8-20020a1709026b8800b0017ef1770400mr8099559plk.72.1666178268732; Wed, 19 Oct 2022 04:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666178268; cv=none; d=google.com; s=arc-20160816; b=NWhujjfGv5A/PZGfaXED1eIE1hAFfGyFxKUW1k5Hija0xZ4B4rOzbFPYqZQEqctQ4S F5YJSeaXKEi2L9BxiCDMq4XzYLJwCN7LUWonsTo3/61NJVZ4Lj1cJsuK0gJ85Zn2cM/o j4HGy+czi1rFZhlUNeBRIMs13I3bMwFTmhJ6fBJM0uWQMgWW1UnpvT9XVnApwgtZgqJC iz7suXVTO74UUOzqIPnc/aXwcCnqW+vpgXHiet/Oo4gdOibrP9Iw/Pi9T0jjIjZqK/bi ZZv9Kgc3bu5mFdzkV/fVt6DyFkyczQv7ohoRUmfx1bjvKXG1CgAmeFIeZqFtnebhGZaG O0Rg== 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 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.17.04; Wed, 19 Oct 2022 04:17:48 -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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747114544486159703?= X-GMAIL-MSGID: =?utf-8?q?1747114544486159703?= 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;