Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2427164rwi; Tue, 1 Nov 2022 07:36:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7oz4pKXBYEboppvVDOvdXL2cIjxqX85SEo8xTEVgcxdTG1AP/DuNOZeZiSexZltSr3UuF5 X-Received: by 2002:a05:6402:5244:b0:461:d97e:5271 with SMTP id t4-20020a056402524400b00461d97e5271mr19915164edd.227.1667313376961; Tue, 01 Nov 2022 07:36:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667313376; cv=none; d=google.com; s=arc-20160816; b=zhpXG+nY0BvRwcGI5fzNTooFZbkhUJy7hy2JFleksZXY102iwoIolF7LQzgAsMozDC FV9cxpyRFckux/EIPqBcCKuAtZwGbjUIYcOw7SAknsaSN2Txb6t59HpeDW0WnPvWOoYe 6B4Y8eAwnZz80EC+RiHkGpKoRYiumWkjr1R+Zkpf9u2sb8WMO66SAI0r6njsGjNmY+B8 gd+rHjSFwgRPAL3VQ+NfXFbyXbuWKN2CI9gjPKD2LDxFqWiU8HuP4Ac6DRyd6uwO3m+D /SDWSybHNMNicEdvOe/uz2zoiteEfBKpkJfSDckY3ZatLiNdQBxaKdUFIBAOmB+7UZCh W4sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=trtkeYUL4md/p7iqX21AG1lqdJxBlESj6g7aM59leSc=; b=CcKo4iT2gai36TpsapFzdBiaqf/HuAD7UjPm/gpz28V3H85vESebz1fRFCyyvzHMUH g9GOiEN0A8yfP7hWT5ZzY6Wp2ZNPrbNDdhUosSB7qOqyPZaMczH9f7eaIh3erSyWxTen D7xjEAn2QDJD9aDZVGk/hBzP92ZvxG3JmEOMfb375w6Rg+Mibb92ukZn8YwbMbjyZtNo R3t7s72QBdvd8Q8zuCGeUYOLszO0S8RLda+uwyr3mm1Y1mkdBZ6zebKdesBX3L4hUN34 3utFfXRI9w1hE8sDTp7mvpayCOt5q4z35h9laDO/ApipMWs5k8Kx+NVcoUTlee2HH5pL N7zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a056402240d00b00463c13a9ab7si1504363eda.32.2022.11.01.07.35.51; Tue, 01 Nov 2022 07:36:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230026AbiKAOMp (ORCPT + 96 others); Tue, 1 Nov 2022 10:12:45 -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) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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....