Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2572326lqp; Mon, 25 Mar 2024 03:06:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhPEgFWs+cSvVsO4ecG1iTOs9WXQx4HGPrRiNVN+yESPnzmqrzrB1jUVVeJ3qcjhF2U3NqoW71Man6VXop+fI41U8Pq/85Op6jU4kr+g== X-Google-Smtp-Source: AGHT+IGFbInZ/grJ3CXc3o+oLGJLtdkQAsMO0jBKC0HmpUZUI3U0gTbqPTx/IVqcF2i5dUWyJxOM X-Received: by 2002:a17:902:f786:b0:1e0:c224:abea with SMTP id q6-20020a170902f78600b001e0c224abeamr2360936pln.43.1711361166087; Mon, 25 Mar 2024 03:06:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711361166; cv=pass; d=google.com; s=arc-20160816; b=AW1F7dx7Mma8JtN5jgMbsO/kDOmO3a5QBrHieUL6bVAzJiO7XjhVLHYREeMwG+BvAV wOSqzzMuBSbUDnkYYRVm7MFXEgx5xpxHU0xrrJ9YgAGUh001NZm9LznuehYQo3FO/nSc TpDijNKoL+p+sMe0WzNJHccI2aJmhchKcs40PnwH+ekxC/ixv5GSvXq0zyA8+jJUNFTk vaoLo6iOHMuCakPynkI3M8CR4sK91wGc2kDotiXHagh9KQ03kVSmOhZuEhUaygHwtk1Y n1mrTRK2XkM6BSp7D26b/LXol4GAfnwWmSSXMTc8/SuEAL3cZ4Q7AqEBuWNp4hjdIrG2 YQ8Q== 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=hQDGIKZoD7qmQMEKkIzAXbW+ApvBBwavwvEeuKvKxhE=; fh=Ixeiw5tXtcpLaHzdxHxLFF7t6oBT6GNp71uLxSBmRQo=; b=N6xCshpiyH5C32PQvhD8c0cmJnPg8Vltgkd7T0dZ58/KcKNCHrCPz0jwiLZRgZi1fJ 1io45BJ6cuHsEALaVRqcAEQ7psO2NG90JLyH/p0MAFrZbXnUkJ8uJugnO2ueNUFITCET WldU9fVrTn0qpsW3fmkIFW6WN4GEbWi1KYQ+eh3TG1CDpiJmadTgNNKzhJohMnz8xttB e0XarYruQWnpsqCBEoreU7QAwroQqrR/2wC4cELfwAEW/uN9Nx/VLNgSso8IA5RJ2J2G nOf/STE0UjhmHJ++28q8zyGQMxgluAEdLOhiqelxg/fDodrWQ8qV9Hv5FFO+rdvN/3vL KNSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WhBW5FKM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115844-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id p14-20020a170902e74e00b001dffd28cabcsi4419630plf.167.2024.03.25.03.06.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 03:06:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WhBW5FKM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115844-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115844-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 69721B3863D for ; Mon, 25 Mar 2024 09:32:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 81A2637C91E; Mon, 25 Mar 2024 03:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WhBW5FKM" 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 DCED2145B2F; Sun, 24 Mar 2024 23:13:53 +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=1711322034; cv=none; b=HLEiUaBDseKuHi+c/kO6PLRRGS3gng00GElcHm6jORVWoyCkk8pPTHsJxPXW1rCDSGJkdDumDXYaRe9Bpl/fwKCDD/2pW811H971oTT/2a9tyqGi0NqNiStQWbkWpaykCeZdpfFbFDKbG9Dg6SI5+17LBIj4HD/3+LOBtCLPHpU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711322034; c=relaxed/simple; bh=ngN9xWqtsFLOKtMY70Ro83f6fR4n3SwhYSw3XqZWPRQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UIEvxT55EtYjJ4B8rh1V7cmt4daW7E8S99Oz79zu60+dyTn7YQlvq014dsakDsHhZqC1nLO5iAHISBbKQpIxiSHTwTRreUBP8MmWBiPBuSPG6RnkiFxvRA21iPTy0JfUXE2kuTTo9A7h4A1TlpV1OGu6KJKqk+74g532KrJ4b0Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WhBW5FKM; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0A582C433C7; Sun, 24 Mar 2024 23:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711322033; bh=ngN9xWqtsFLOKtMY70Ro83f6fR4n3SwhYSw3XqZWPRQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WhBW5FKMfADGAtb5Y2sSMG4lSjSxk1Qr9lZKgTYTIdSfq8f+d6x3MHqjwpF2zGfNr NJ1iqALULvn60wXXjTTklKZF6VDMr7p1cENR9ElFIkAbQHLN6Ja6VS72UjE+QozMyy BwE6C61cjL89Fgwhz/fn31sR186ubGuG7USBL62FO/+oRy/XfR/A8DAv7ywJksCtnk 7X7Tge9PMiyjTvcs+spXqAVPiphZzCrG3OHtibRlvJw2bPXZ0zm7WHVHPX/Ut0zeLC /jKR6J/EPEZ7JXB86pNjOjRYRi8TtQVWG8uR7K3bzTmxqcZjeL8l+NU9gqusLwQaLM ID0kJoC/EUcpA== 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.1 105/451] libbpf: Fix faccessat() usage on Android Date: Sun, 24 Mar 2024 19:06:21 -0400 Message-ID: <20240324231207.1351418-106-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324231207.1351418-1-sashal@kernel.org> References: <20240324231207.1351418-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 377642ff51fce..8669f6e0f6e2f 100644 --- a/tools/lib/bpf/libbpf_internal.h +++ b/tools/lib/bpf/libbpf_internal.h @@ -17,6 +17,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