From mboxrd@z Thu Jan 1 00:00:00 1970 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 23666C43219 for ; Tue, 1 Nov 2022 14:12:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229958AbiKAOMq (ORCPT ); Tue, 1 Nov 2022 10:12:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229553AbiKAOMn (ORCPT ); Tue, 1 Nov 2022 10:12:43 -0400 Received: from www62.your-server.de (www62.your-server.de [213.133.104.62]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D41D51AF2B; Tue, 1 Nov 2022 07:12:42 -0700 (PDT) Received: from sslproxy02.your-server.de ([78.47.166.47]) by www62.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92.3) (envelope-from ) id 1oprkf-000Ezv-35; Tue, 01 Nov 2022 14:56:25 +0100 Received: from [85.1.206.226] (helo=linux.home) by sslproxy02.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oprke-000H9q-I3; Tue, 01 Nov 2022 14:56:24 +0100 Subject: Re: [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning To: Rong Tao , david.laight@aculab.com Cc: andrii.nakryiko@gmail.com, andrii@kernel.org, ast@kernel.org, bpf@vger.kernel.org, haoluo@google.com, john.fastabend@gmail.com, jolsa@kernel.org, kpsingh@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, martin.lau@linux.dev, mykolal@fb.com, rongtao@cestc.cn, sdf@google.com, shuah@kernel.org, song@kernel.org, yhs@fb.com References: <70ddf02157bc418cbc38230c87a7b228@AcuMS.aculab.com> From: Daniel Borkmann Message-ID: Date: Tue, 1 Nov 2022 14:56:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.103.6/26706/Tue Nov 1 08:52:34 2022) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/1/22 1:21 PM, Rong Tao wrote: > From: Rong Tao > > move libbpf_strlcpy() to bpf_util.h, and replace strncpy() with > libbpf_strlcpy(), fix compile warning. > > Compile samples/bpf, warning: > $ cd samples/bpf > $ make > ... > cgroup_helpers.c: In function ‘__enable_controllers’: > cgroup_helpers.c:80:17: warning: ‘strncpy’ specified bound 4097 equals destination size [-Wstringop-truncation] > 80 | strncpy(enable, controllers, sizeof(enable)); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > BPF CI now throws a new warning after your patch: https://github.com/kernel-patches/bpf/actions/runs/3369416153/jobs/5589052613 [...] xsk.c:536:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] libbpf_strlcpy(ifr.ifr_name, ctx->ifname, IFNAMSIZ); ^ xsk.c:755:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] libbpf_strlcpy(ctx->ifname, ifname, IFNAMSIZ); ^ xsk.c:942:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration] libbpf_strlcpy(ctx->ifname, ifname, IFNAMSIZ); ^ 3 errors generated. make: *** [Makefile:166: /tmp/work/bpf/bpf/tools/testing/selftests/bpf/xsk.o] Error 1 make: *** Waiting for unfinished jobs....