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]
Date:	Thu, 20 Jun 2013 12:17:55 +0100
From:	"David Laight" <David.Laight@...LAB.COM>
To:	"Zhao Hongjiang" <zhaohongjiang@...wei.com>, <davem@...emloft.net>
Cc:	<kuznet@....inr.ac.ru>, <jmorris@...ei.org>,
	<yoshfuji@...ux-ipv6.org>, <kaber@...sh.net>,
	<netdev@...r.kernel.org>
Subject: RE: [PATCH 1/5] net: ipv4: using strlcpy instead of strncpy

> for NUL terminated string, need alway set '\0' in the end.
> 
> Signed-off-by: Zhao Hongjiang <zhaohongjiang@...wei.com>
> ---
>  net/ipv4/tcp_cong.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c
> index 019c238..3280234 100644
> --- a/net/ipv4/tcp_cong.c
> +++ b/net/ipv4/tcp_cong.c
> @@ -170,7 +170,7 @@ void tcp_get_default_congestion_control(char *name)
> 
>  	rcu_read_lock();
>  	ca = list_entry(tcp_cong_list.next, struct tcp_congestion_ops, list);
> -	strncpy(name, ca->name, TCP_CA_NAME_MAX);
> +	strlcpy(name, ca->name, sizeof(name));
>  	rcu_read_unlock();
>  }

Did you actually test this? I think not!

Blindly changing strncpy() to strlcpy() isn't a good idea.
You actually need to worry about the length of both arrays
and whether the source is always 0 terminated.
(Any whether the target is required to be terminated.)
Also, if the target might get copied to user space whether
you might be leaking uninitialized kernel memory.

The one above is just plain wrong though.

	David



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ