All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
	martin.lau@kernel.org, kernel-team@meta.com
Subject: Re: [PATCH bpf-next] libbpf: fix faccessat() usage on Android
Date: Sun, 28 Jan 2024 19:56:23 +0100	[thread overview]
Message-ID: <ZbajVxpkL7Vh_DW7@krava> (raw)
In-Reply-To: <20240126220944.2497665-1-andrii@kernel.org>

On Fri, Jan 26, 2024 at 02:09:44PM -0800, Andrii Nakryiko wrote:
> 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 <andrii@kernel.org>

Acked-by: Jiri Olsa <jolsa@kernel.org>

jirka

> ---
>  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 930cc9616527..5b30f3b67a02 100644
> --- a/tools/lib/bpf/libbpf_internal.h
> +++ b/tools/lib/bpf/libbpf_internal.h
> @@ -19,6 +19,20 @@
>  #include <libelf.h>
>  #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.34.1
> 
> 

  reply	other threads:[~2024-01-28 18:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-26 22:09 [PATCH bpf-next] libbpf: fix faccessat() usage on Android Andrii Nakryiko
2024-01-28 18:56 ` Jiri Olsa [this message]
2024-01-29 15:30 ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZbajVxpkL7Vh_DW7@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@meta.com \
    --cc=martin.lau@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.