* [PATCH bpf-next] libbpf: poison strlcpy()
@ 2023-01-05 14:36 Rong Tao
2023-01-05 18:47 ` sdf
2023-01-06 16:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 5+ messages in thread
From: Rong Tao @ 2023-01-05 14:36 UTC (permalink / raw)
To: andrii
Cc: rongtao, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau,
Song Liu, Yonghong Song, John Fastabend, KP Singh,
Stanislav Fomichev, Hao Luo, Jiri Olsa,
open list:BPF [LIBRARY] (libbpf), open list
From: Rong Tao <rongtao@cestc.cn>
Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and use
it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a poison
list to prevent accidental use of it.
Signed-off-by: Rong Tao <rongtao@cestc.cn>
---
tools/lib/bpf/libbpf_internal.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/libbpf_internal.h b/tools/lib/bpf/libbpf_internal.h
index 377642ff51fc..2d26ded383ca 100644
--- a/tools/lib/bpf/libbpf_internal.h
+++ b/tools/lib/bpf/libbpf_internal.h
@@ -20,8 +20,8 @@
/* make sure libbpf doesn't use kernel-only integer typedefs */
#pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64
-/* prevent accidental re-addition of reallocarray() */
-#pragma GCC poison reallocarray
+/* prevent accidental re-addition of reallocarray()/strlcpy() */
+#pragma GCC poison reallocarray strlcpy
#include "libbpf.h"
#include "btf.h"
--
2.39.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH bpf-next] libbpf: poison strlcpy() 2023-01-05 14:36 [PATCH bpf-next] libbpf: poison strlcpy() Rong Tao @ 2023-01-05 18:47 ` sdf 2023-03-09 0:30 ` Boris Burkov 2023-01-06 16:10 ` patchwork-bot+netdevbpf 1 sibling, 1 reply; 5+ messages in thread From: sdf @ 2023-01-05 18:47 UTC (permalink / raw) To: Rong Tao Cc: andrii, rongtao, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, Hao Luo, Jiri Olsa, open list:BPF [LIBRARY] (libbpf), open list On 01/05, Rong Tao wrote: > From: Rong Tao <rongtao@cestc.cn> > Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and use > it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a poison > list to prevent accidental use of it. > Signed-off-by: Rong Tao <rongtao@cestc.cn> Acked-by: Stanislav Fomichev <sdf@google.com> > --- > tools/lib/bpf/libbpf_internal.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > diff --git a/tools/lib/bpf/libbpf_internal.h > b/tools/lib/bpf/libbpf_internal.h > index 377642ff51fc..2d26ded383ca 100644 > --- a/tools/lib/bpf/libbpf_internal.h > +++ b/tools/lib/bpf/libbpf_internal.h > @@ -20,8 +20,8 @@ > /* make sure libbpf doesn't use kernel-only integer typedefs */ > #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 > -/* prevent accidental re-addition of reallocarray() */ > -#pragma GCC poison reallocarray > +/* prevent accidental re-addition of reallocarray()/strlcpy() */ > +#pragma GCC poison reallocarray strlcpy > #include "libbpf.h" > #include "btf.h" > -- > 2.39.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] libbpf: poison strlcpy() 2023-01-05 18:47 ` sdf @ 2023-03-09 0:30 ` Boris Burkov 2023-03-09 0:32 ` Stanislav Fomichev 0 siblings, 1 reply; 5+ messages in thread From: Boris Burkov @ 2023-03-09 0:30 UTC (permalink / raw) To: sdf Cc: Rong Tao, andrii, rongtao, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, Hao Luo, Jiri Olsa, open list:BPF [LIBRARY] (libbpf), open list On Thu, Jan 05, 2023 at 10:47:15AM -0800, sdf@google.com wrote: > On 01/05, Rong Tao wrote: > > From: Rong Tao <rongtao@cestc.cn> > > > Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and use > > it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a poison > > list to prevent accidental use of it. > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > Acked-by: Stanislav Fomichev <sdf@google.com> > > > --- > > tools/lib/bpf/libbpf_internal.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > diff --git a/tools/lib/bpf/libbpf_internal.h > > b/tools/lib/bpf/libbpf_internal.h > > index 377642ff51fc..2d26ded383ca 100644 > > --- a/tools/lib/bpf/libbpf_internal.h > > +++ b/tools/lib/bpf/libbpf_internal.h > > @@ -20,8 +20,8 @@ > > /* make sure libbpf doesn't use kernel-only integer typedefs */ > > #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 > > > -/* prevent accidental re-addition of reallocarray() */ > > -#pragma GCC poison reallocarray > > +/* prevent accidental re-addition of reallocarray()/strlcpy() */ > > +#pragma GCC poison reallocarray strlcpy On my musl system, I believe this broke compilation, as string.h defines strlcpy, and is included after this poisoning when compiling strset.c FWIW, I could work around it by adding #include <string.h> above #include <libbpf_internal.h> in strset.c, since the poison doesn't apply to symbols that existed before it ran, but this feels like a kludge, and not in the spirit of the original poisoning patch.. I'm curious what the proper workaround should be for a libc that defines strlcpy. Thanks, Boris > > > #include "libbpf.h" > > #include "btf.h" > > -- > > 2.39.0 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] libbpf: poison strlcpy() 2023-03-09 0:30 ` Boris Burkov @ 2023-03-09 0:32 ` Stanislav Fomichev 0 siblings, 0 replies; 5+ messages in thread From: Stanislav Fomichev @ 2023-03-09 0:32 UTC (permalink / raw) To: Boris Burkov Cc: Rong Tao, andrii, rongtao, Alexei Starovoitov, Daniel Borkmann, Martin KaFai Lau, Song Liu, Yonghong Song, John Fastabend, KP Singh, Hao Luo, Jiri Olsa, open list:BPF [LIBRARY] (libbpf), open list On Wed, Mar 8, 2023 at 4:30 PM Boris Burkov <boris@bur.io> wrote: > > On Thu, Jan 05, 2023 at 10:47:15AM -0800, sdf@google.com wrote: > > On 01/05, Rong Tao wrote: > > > From: Rong Tao <rongtao@cestc.cn> > > > > > Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and use > > > it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a poison > > > list to prevent accidental use of it. > > > > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > > > Acked-by: Stanislav Fomichev <sdf@google.com> > > > > > --- > > > tools/lib/bpf/libbpf_internal.h | 4 ++-- > > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > > diff --git a/tools/lib/bpf/libbpf_internal.h > > > b/tools/lib/bpf/libbpf_internal.h > > > index 377642ff51fc..2d26ded383ca 100644 > > > --- a/tools/lib/bpf/libbpf_internal.h > > > +++ b/tools/lib/bpf/libbpf_internal.h > > > @@ -20,8 +20,8 @@ > > > /* make sure libbpf doesn't use kernel-only integer typedefs */ > > > #pragma GCC poison u8 u16 u32 u64 s8 s16 s32 s64 > > > > > -/* prevent accidental re-addition of reallocarray() */ > > > -#pragma GCC poison reallocarray > > > +/* prevent accidental re-addition of reallocarray()/strlcpy() */ > > > +#pragma GCC poison reallocarray strlcpy > > On my musl system, I believe this broke compilation, as string.h defines > strlcpy, and is included after this poisoning when compiling strset.c > > FWIW, I could work around it by adding > #include <string.h> > above > #include <libbpf_internal.h> > in strset.c, since the poison doesn't apply to symbols that existed > before it ran, but this feels like a kludge, and not in the spirit of > the original poisoning patch.. > > I'm curious what the proper workaround should be for a libc that defines > strlcpy. Let's move this discussion into [0]? There is a similar issue for uclibc it seems. 0: https://lore.kernel.org/bpf/CAKH8qBshq-J2H+Bo1xA=FzAJ6x_mo5yfW6oYjQ_u1QwLJ5CDog@mail.gmail.com/T/#t > Thanks, > Boris > > > > > > #include "libbpf.h" > > > #include "btf.h" > > > -- > > > 2.39.0 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH bpf-next] libbpf: poison strlcpy() 2023-01-05 14:36 [PATCH bpf-next] libbpf: poison strlcpy() Rong Tao 2023-01-05 18:47 ` sdf @ 2023-01-06 16:10 ` patchwork-bot+netdevbpf 1 sibling, 0 replies; 5+ messages in thread From: patchwork-bot+netdevbpf @ 2023-01-06 16:10 UTC (permalink / raw) To: Rong Tao Cc: andrii, rongtao, ast, daniel, martin.lau, song, yhs, john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf, linux-kernel Hello: This patch was applied to bpf/bpf-next.git (master) by Daniel Borkmann <daniel@iogearbox.net>: On Thu, 5 Jan 2023 22:36:33 +0800 you wrote: > From: Rong Tao <rongtao@cestc.cn> > > Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and use > it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a poison > list to prevent accidental use of it. > > Signed-off-by: Rong Tao <rongtao@cestc.cn> > > [...] Here is the summary with links: - [bpf-next] libbpf: poison strlcpy() https://git.kernel.org/bpf/bpf-next/c/6d0c4b11e743 You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2023-03-09 0:33 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2023-01-05 14:36 [PATCH bpf-next] libbpf: poison strlcpy() Rong Tao 2023-01-05 18:47 ` sdf 2023-03-09 0:30 ` Boris Burkov 2023-03-09 0:32 ` Stanislav Fomichev 2023-01-06 16:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox