Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AF680C6FD19 for ; Thu, 9 Mar 2023 00:33:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbjCIAdL (ORCPT ); Wed, 8 Mar 2023 19:33:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229525AbjCIAdH (ORCPT ); Wed, 8 Mar 2023 19:33:07 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6954612043 for ; Wed, 8 Mar 2023 16:33:04 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id a9so279536plh.11 for ; Wed, 08 Mar 2023 16:33:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; t=1678321984; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=8NX69L/y4AvylfjHZlVGoJXMkTEsL+QP4IGqtRYKSS0=; b=mNY9mNONo56A6D7ojY2BrqryoFhUyIAQtfXJpJvmE2gs5w3cg1pAQoBdQNGNHF+QUS b0CLeiMR7kcrpwWTO30tUnGmYyvfsDOkVijxQNfDsIbjWtqGTVYzxiax9Uo+5cVXz2t2 5icD3pOeHfMV7v8+s1+w4L4TJRBQZEsu0vtPI4PHIU3tzMgw0zq5UZ+1DK1+/IQ4Q6ma SHLR9+GFV6bm7vFVhXihCMrpW5Mu9lxK1WqgzEFbeAEUqC00aRlE1noJnr1VIMjQmhoD PpdXvr6SbwiCYHjYgbX7+ydIqXGAeApfPi1dX4fzHct/D4VxXrPNgdGZSJ+MDxIr78KN nCmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678321984; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8NX69L/y4AvylfjHZlVGoJXMkTEsL+QP4IGqtRYKSS0=; b=HmRjQUTnqVKRIh43e1XlhcPb95sYxcbaJTfzsPaz8pH2CPaxBqr6h/y8wObhLV2Mdu XHjDbgpLpBlbjZ2umv7/t7uxSj6NO+8qPq2Mcp31whQ/0HdIqe8fHgIPPlzUiWx8r/k6 Y4ExseWv+ebzoDWFsGpywhVpqmfOXu6sZ2WVIo3vHDbsath0DnfN+WDrGAa+OdoQU0p6 J5PipKOcTfR2hb8M5Ub01p4+5r3wl+mJMLUX1ulcYstZf5jfTK8LS75KbqBEqBKCAosd ZPKivYIb35CKITO64jVnARqVKnTF54VpRT+lRl6B6IpYaURjnb/1QlbcIXrobTbwnaEQ XbRQ== X-Gm-Message-State: AO0yUKULcDclNmuQjkhB/h0XGkkgr1YVcmIYZvkJbg124b7d7NBZHFiw v0k6u2YW20HppV8YmSXDQjvknR2EOIRUk+7i4elN1g== X-Google-Smtp-Source: AK7set+yVTwl/Hj6Yzw5umIz4qWrd0uciAr8L27IGj2EfxXvJSf0wfrTrTYSmqZnqhMDEkdVNw4F3K4YQXUXA9UBY54= X-Received: by 2002:a17:90a:c257:b0:233:bada:17b5 with SMTP id d23-20020a17090ac25700b00233bada17b5mr7427704pjx.4.1678321983734; Wed, 08 Mar 2023 16:33:03 -0800 (PST) MIME-Version: 1.0 References: <20230309003055.GA6586@zen> In-Reply-To: <20230309003055.GA6586@zen> From: Stanislav Fomichev Date: Wed, 8 Mar 2023 16:32:52 -0800 Message-ID: Subject: Re: [PATCH bpf-next] libbpf: poison strlcpy() To: Boris Burkov Cc: Rong Tao , andrii@kernel.org, rongtao@cestc.cn, 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Mar 8, 2023 at 4:30=E2=80=AFPM Boris Burkov wrote: > > On Thu, Jan 05, 2023 at 10:47:15AM -0800, sdf@google.com wrote: > > On 01/05, Rong Tao wrote: > > > From: Rong Tao > > > > > Since commit 9fc205b413b3("libbpf: Add sane strncpy alternative and u= se > > > it internally") introduce libbpf_strlcpy(), thus add strlcpy() to a p= oison > > > list to prevent accidental use of it. > > > > > Signed-off-by: Rong Tao > > > > Acked-by: Stanislav Fomichev > > > > > --- > > > 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 > above > #include > 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=3DFzAJ6x_mo5yfW6oYjQ_u1= QwLJ5CDog@mail.gmail.com/T/#t > Thanks, > Boris > > > > > > #include "libbpf.h" > > > #include "btf.h" > > > -- > > > 2.39.0 > >