lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1611fe67d311461aa5f820836318bacc@AcuMS.aculab.com>
Date:   Sat, 29 Oct 2022 12:23:33 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Rong Tao' <rtoax@...mail.com>,
        "andrii.nakryiko@...il.com" <andrii.nakryiko@...il.com>
CC:     "andrii@...nel.org" <andrii@...nel.org>,
        "ast@...nel.org" <ast@...nel.org>,
        "bpf@...r.kernel.org" <bpf@...r.kernel.org>,
        "daniel@...earbox.net" <daniel@...earbox.net>,
        "haoluo@...gle.com" <haoluo@...gle.com>,
        "john.fastabend@...il.com" <john.fastabend@...il.com>,
        "jolsa@...nel.org" <jolsa@...nel.org>,
        "kpsingh@...nel.org" <kpsingh@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "martin.lau@...ux.dev" <martin.lau@...ux.dev>,
        "mykolal@...com" <mykolal@...com>,
        "rongtao@...tc.cn" <rongtao@...tc.cn>,
        "sdf@...gle.com" <sdf@...gle.com>,
        "shuah@...nel.org" <shuah@...nel.org>,
        "song@...nel.org" <song@...nel.org>, "yhs@...com" <yhs@...com>
Subject: RE: [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning

From: Rong Tao
> Sent: 29 October 2022 04:00
> 
> From: Rong Tao <rongtao@...tc.cn>
> 
> Replace strncpy() with strncat(), strncat() leaves the dst string zero
> terminated. Compile samples/bpf warning:

This only makes a difference because tests for strncat() have not been added.
srtncat() really is never the string function you are looking for.

	David


> 
> $ cd samples/bpf
> $ make
> ...
> In function ‘__enable_controllers’:
> samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:80:17: warning: ‘strncpy’ specified
> bound 4097 equals destination size [-Wstringop-truncation]
>    80 |                 strncpy(enable, controllers, sizeof(enable));
>       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Signed-off-by: Rong Tao <rongtao@...tc.cn>
> ---
>  tools/testing/selftests/bpf/cgroup_helpers.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/bpf/cgroup_helpers.c
> b/tools/testing/selftests/bpf/cgroup_helpers.c
> index a70e873b267e..912e6522c7c5 100644
> --- a/tools/testing/selftests/bpf/cgroup_helpers.c
> +++ b/tools/testing/selftests/bpf/cgroup_helpers.c
> @@ -77,7 +77,8 @@ static int __enable_controllers(const char *cgroup_path, const char *controllers
>  		enable[len] = 0;
>  		close(fd);
>  	} else {
> -		strncpy(enable, controllers, sizeof(enable) - 1);
> +		enable[0] = '\0';
> +		strncat(enable, controllers, sizeof(enable) - 1);
>  	}
> 
>  	snprintf(path, sizeof(path), "%s/cgroup.subtree_control", cgroup_path);
> --
> 2.31.1

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ