Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2368841lqp; Sun, 24 Mar 2024 16:09:21 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXstnYbfQ1bXvKWYD9NihQwYXFIoQ5z9Q++yzhWXSZ7qwe6c54+zuBPgkcWzdMDqYnTM0Ts/hxbs6jewOJgytB0F0scwufratc6dYwgAg== X-Google-Smtp-Source: AGHT+IE6Y72TgqyLyIZDDsH+iVPan0ZTlqPsdyXM8zsfbT/rKcLbTj8quOdPS3vvZ+PY4OQLPJxu X-Received: by 2002:a50:d7d1:0:b0:567:56a4:3940 with SMTP id m17-20020a50d7d1000000b0056756a43940mr3907503edj.19.1711321760882; Sun, 24 Mar 2024 16:09:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711321760; cv=pass; d=google.com; s=arc-20160816; b=EeSMP+0kcFbmntEYkDbOC4NGiUdCirasgauNz7ixhre0WjWzeEly8rWznzReZ6Mb3s MfNHw3xV1mdZKmykLa42CsVhTnmQEtL5gAP5qgRsTil4RGftmbjifdsVFGKTNoTA3GKh U8A4GKzqBZn/LWs/zvRzBRlK1HgqdYywq1pB5/1cVMte87vDNWW1ZNNHrf5rxhLg4GWI COVW2WOcB/VtkdK+nAznuzxwxRGo8Ykmrg1ImFmCSO1DReazPFkmE3oCqFlF2xV4JsTM PgIxmkmnZ3AOLXSMf2GFfM5uWtEDX9nb9ufS7Hp/mVc7iEWoBNWRwiT5NfrdOZtOZ7QP 9mFw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ddQ7j7STxk82r0oy1Vwg4uyzhgEb8LPRoIyt2OtmloQ=; fh=Ixeiw5tXtcpLaHzdxHxLFF7t6oBT6GNp71uLxSBmRQo=; b=FgjyFf9JWKpvMms3ZTgXaf86nIFcuiwgN4VMEk4WQWgV9BY7+uLoTJkILLK8XOA0Xb p5gEHuHZgTe3O0RMg79eGagzMaB6iZRmNeQoILZKUokgVVG5PurKF/Jn8mPL3cX5B7i3 wK1HMnllcY7lOAtZWl4k+TXfEa3+lbWEAmKgPdd16ZD9zO1+gefbU9uBJKDUL1MBZhwv d05jnvSm4rP437Dc4rDIKrMFor/1LdhAjyx7CifbcClgoY15gTnVYxnZD10VKHkaPseB ZVZNcB+dQgnFbTY8bc6xAEQsvNAXHnXzPLmeGGMUkwRnsmSXEbW4nE6W4zb+SCW0nBUn OXyQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dldgVlO6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112989-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id u8-20020aa7d0c8000000b00568d2c1514csi1966885edo.467.2024.03.24.16.09.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 24 Mar 2024 16:09:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-112989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dldgVlO6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-112989-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-112989-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id CF2E61F2355F for ; Sun, 24 Mar 2024 22:59:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8181812DD94; Sun, 24 Mar 2024 22:36:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dldgVlO6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A553012D77E; Sun, 24 Mar 2024 22:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319801; cv=none; b=Mm1J0rBESb9O9e/zeBrM7GtHMSRWJf396s/coX3Ay6phIMxcUhBPcp88en0vI8c8GU6ajiTrEwkAXORZL3trVjeB645fNwh3zeF3nw093cnonaMsE8TE9WemFlUa7OqqnrO0NhnU6VKLgcVjsO2upl7lccjtWUPLPowdYyzuaOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711319801; c=relaxed/simple; bh=t7XSdAj6yxAQYf5fZv1wzXR8vjQRSTG70d/2KIqw3JE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hdyDZSmKV+jSnJJZKcm68cpyKfGk9+3Lw+w4WgnoUX8z+dB/bG+urP5fEFokXvVthV0GsO9SlxsI9qwUGhm6GQP6Jl1/g1UyYYUXt/+tEBNVQ32RmLnOHjNeTZlGA/OAtjtDp8767akIRrMA4cB4aznv/CLYcKRFY24QquKMQrE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dldgVlO6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDF57C43390; Sun, 24 Mar 2024 22:36:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711319801; bh=t7XSdAj6yxAQYf5fZv1wzXR8vjQRSTG70d/2KIqw3JE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dldgVlO6d3w7BZe3Mra8c1lCEHd2cdfE80cASxIwTTi5g7DUQLeWlkHV2QrLTKWuB 8AoMbJAZTjUhww55+OX0uBqOF9fMV8E7GyAa3ZCzoALRQEOm+zHDU4IDtRElk0Z7Hr +UcX18ZChFTrixLVyulCL2EPFh2vHMsaxMGoH24w6dyUaFhZiwXfeYzm9gIZc5dLQv r4f6kmkQLXfIDhkMjbT9fNsW28/aI3QKd8Dc9JADFdd0O7MxnEwxx+fPq1yL+/4SkW n0B3YG648Ug4ZaG+VsTI1fhb1ngO1inf66VDJppCnI4u2r0AdphwBl4Y+KMoFVw1OD XAGbNOb51DY6A== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrii Nakryiko , Daniel Borkmann , Jiri Olsa , Sasha Levin Subject: [PATCH 6.8 102/715] libbpf: Fix faccessat() usage on Android Date: Sun, 24 Mar 2024 18:24:41 -0400 Message-ID: <20240324223455.1342824-103-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324223455.1342824-1-sashal@kernel.org> References: <20240324223455.1342824-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Andrii Nakryiko [ Upstream commit ad57654053805bf9a62602aaec74cc78edb6f235 ] Android implementation of libc errors out with -EINVAL in faccessat() if passed AT_EACCESS ([0]), this leads to ridiculous issue with libbpf refusing to load /sys/kernel/btf/vmlinux on Androids ([1]). Fix by detecting Android and redefining AT_EACCESS to 0, it's equivalent on Android. [0] https://android.googlesource.com/platform/bionic/+/refs/heads/android13-release/libc/bionic/faccessat.cpp#50 [1] https://github.com/libbpf/libbpf-bootstrap/issues/250#issuecomment-1911324250 Fixes: 6a4ab8869d0b ("libbpf: Fix the case of running as non-root with capabilities") Signed-off-by: Andrii Nakryiko Signed-off-by: Daniel Borkmann Acked-by: Jiri Olsa Link: https://lore.kernel.org/bpf/20240126220944.2497665-1-andrii@kernel.org Signed-off-by: Sasha Levin --- tools/lib/bpf/libbpf_internal.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h index 27e4e320e1a69..878a0d0b51f5c 100644 --- a/tools/lib/bpf/libbpf_internal.h +++ b/tools/lib/bpf/libbpf_internal.h @@ -18,6 +18,20 @@ #include #include "relo_core.h" +/* Android's libc doesn't support AT_EACCESS in faccessat() implementation + * ([0]), and just returns -EINVAL even if file exists and is accessible. + * See [1] for issues caused by this. + * + * So just redefine it to 0 on Android. + * + * [0] https://android.googlesource.com/platform/bionic/+/refs/heads/android13-release/libc/bionic/faccessat.cpp#50 + * [1] https://github.com/libbpf/libbpf-bootstrap/issues/250#issuecomment-1911324250 + */ +#ifdef __ANDROID__ +#undef AT_EACCESS +#define AT_EACCESS 0 +#endif + /* make sure libbpf doesn't use kernel-only integer typedefs */ #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 -- 2.43.0