All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2021-09-06 13:46 ` Jason Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Wang @ 2021-09-06 13:46 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: linux, linux-arm-kernel, linux-samsung-soc, linux-kernel, Jason Wang

The strlcpy should not be used because it doesn't limit the source
length. As linus says, it's a completely useless function if you
can't implicitly trust the source string - but that is almost always
why people think they should use it! All in all the BSD function
will lead some potential bugs.

But the strscpy doesn't require reading memory from the src string
beyond the specified "count" bytes, and since the return value is
easier to error-check than strlcpy()'s. In addition, the implementation
is robust to the string changing out from underneath it, unlike the
current strlcpy() implementation.

Thus, We prefer using strscpy instead of strlcpy.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 arch/arm/mach-s3c/mach-mini6410.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c/mach-mini6410.c b/arch/arm/mach-s3c/mach-mini6410.c
index 741fa1f09694..c14c2e27127b 100644
--- a/arch/arm/mach-s3c/mach-mini6410.c
+++ b/arch/arm/mach-s3c/mach-mini6410.c
@@ -262,7 +262,7 @@ static char mini6410_features_str[12] __initdata = "0";
 static int __init mini6410_features_setup(char *str)
 {
 	if (str)
-		strlcpy(mini6410_features_str, str,
+		strscpy(mini6410_features_str, str,
 			sizeof(mini6410_features_str));
 	return 1;
 }
-- 
2.33.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2021-09-06 13:46 ` Jason Wang
  0 siblings, 0 replies; 10+ messages in thread
From: Jason Wang @ 2021-09-06 13:46 UTC (permalink / raw)
  To: krzysztof.kozlowski
  Cc: linux, linux-arm-kernel, linux-samsung-soc, linux-kernel, Jason Wang

The strlcpy should not be used because it doesn't limit the source
length. As linus says, it's a completely useless function if you
can't implicitly trust the source string - but that is almost always
why people think they should use it! All in all the BSD function
will lead some potential bugs.

But the strscpy doesn't require reading memory from the src string
beyond the specified "count" bytes, and since the return value is
easier to error-check than strlcpy()'s. In addition, the implementation
is robust to the string changing out from underneath it, unlike the
current strlcpy() implementation.

Thus, We prefer using strscpy instead of strlcpy.

Signed-off-by: Jason Wang <wangborong@cdjrlc.com>
---
 arch/arm/mach-s3c/mach-mini6410.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c/mach-mini6410.c b/arch/arm/mach-s3c/mach-mini6410.c
index 741fa1f09694..c14c2e27127b 100644
--- a/arch/arm/mach-s3c/mach-mini6410.c
+++ b/arch/arm/mach-s3c/mach-mini6410.c
@@ -262,7 +262,7 @@ static char mini6410_features_str[12] __initdata = "0";
 static int __init mini6410_features_setup(char *str)
 {
 	if (str)
-		strlcpy(mini6410_features_str, str,
+		strscpy(mini6410_features_str, str,
 			sizeof(mini6410_features_str));
 	return 1;
 }
-- 
2.33.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
  2021-09-06 13:46 ` Jason Wang
@ 2021-09-06 13:57   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-06 13:57 UTC (permalink / raw)
  To: Jason Wang; +Cc: linux, linux-arm-kernel, linux-samsung-soc, linux-kernel

On 06/09/2021 15:46, Jason Wang wrote:
> The strlcpy should not be used because it doesn't limit the source
> length. As linus says, it's a completely useless function if you
> can't implicitly trust the source string - but that is almost always
> why people think they should use it! All in all the BSD function
> will lead some potential bugs.
> 
> But the strscpy doesn't require reading memory from the src string
> beyond the specified "count" bytes, and since the return value is
> easier to error-check than strlcpy()'s. In addition, the implementation
> is robust to the string changing out from underneath it, unlike the
> current strlcpy() implementation.
> 
> Thus, We prefer using strscpy instead of strlcpy.

Don't copy-paste kernel documentation into commits. It's enough to say
that strlcpy is preferred, according to the kernel coding style (see
strlcpy()).

If you want to add more sentences, make them relevant, e.g. describe
possible effect of bugs depending on the source.




Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2021-09-06 13:57   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-06 13:57 UTC (permalink / raw)
  To: Jason Wang; +Cc: linux, linux-arm-kernel, linux-samsung-soc, linux-kernel

On 06/09/2021 15:46, Jason Wang wrote:
> The strlcpy should not be used because it doesn't limit the source
> length. As linus says, it's a completely useless function if you
> can't implicitly trust the source string - but that is almost always
> why people think they should use it! All in all the BSD function
> will lead some potential bugs.
> 
> But the strscpy doesn't require reading memory from the src string
> beyond the specified "count" bytes, and since the return value is
> easier to error-check than strlcpy()'s. In addition, the implementation
> is robust to the string changing out from underneath it, unlike the
> current strlcpy() implementation.
> 
> Thus, We prefer using strscpy instead of strlcpy.

Don't copy-paste kernel documentation into commits. It's enough to say
that strlcpy is preferred, according to the kernel coding style (see
strlcpy()).

If you want to add more sentences, make them relevant, e.g. describe
possible effect of bugs depending on the source.




Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
  2021-09-06 13:46 ` Jason Wang
@ 2021-09-20  8:15   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-20  8:15 UTC (permalink / raw)
  To: Jason Wang
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, linux

On Mon, 6 Sep 2021 21:46:56 +0800, Jason Wang wrote:
> The strlcpy should not be used because it doesn't limit the source
> length. As linus says, it's a completely useless function if you
> can't implicitly trust the source string - but that is almost always
> why people think they should use it! All in all the BSD function
> will lead some potential bugs.
> 
> But the strscpy doesn't require reading memory from the src string
> beyond the specified "count" bytes, and since the return value is
> easier to error-check than strlcpy()'s. In addition, the implementation
> is robust to the string changing out from underneath it, unlike the
> current strlcpy() implementation.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c: Use strscpy to replace strlcpy
      commit: aa519471715ce73034ffaa52fc85681de31c1acf

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2021-09-20  8:15   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2021-09-20  8:15 UTC (permalink / raw)
  To: Jason Wang
  Cc: Krzysztof Kozlowski, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, linux

On Mon, 6 Sep 2021 21:46:56 +0800, Jason Wang wrote:
> The strlcpy should not be used because it doesn't limit the source
> length. As linus says, it's a completely useless function if you
> can't implicitly trust the source string - but that is almost always
> why people think they should use it! All in all the BSD function
> will lead some potential bugs.
> 
> But the strscpy doesn't require reading memory from the src string
> beyond the specified "count" bytes, and since the return value is
> easier to error-check than strlcpy()'s. In addition, the implementation
> is robust to the string changing out from underneath it, unlike the
> current strlcpy() implementation.
> 
> [...]

Applied, thanks!

[1/1] ARM: s3c: Use strscpy to replace strlcpy
      commit: aa519471715ce73034ffaa52fc85681de31c1acf

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
  2022-05-22 15:11 ` 陈学兵
@ 2022-05-23  7:10   ` Krzysztof Kozlowski
  -1 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-23  7:10 UTC (permalink / raw)
  To: 陈学兵
  Cc: alim.akhtar, linux, linux-arm-kernel, linux-samsung-soc

On 22/05/2022 17:11, 陈学兵 wrote:
> 
> The strlcpy should not be used because it doesn't limit the source
> length.  Preferred is strscpy.
> 
> Signed-off-by: XueBing Chen <chenxuebing@jari.cn>

Your name in From field does not match exactly one used in
Signed-off-by. Name might be actually the same, but different alphabet
is used. Please use the same one - latin transliteration - in both cases.

> ---
>  arch/arm/mach-s3c/mach-mini2440.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-s3c/mach-mini2440.c b/arch/arm/mach-s3c/mach-mini2440.c
> index 551ec660ab59..98cebc06521c 100644
> --- a/arch/arm/mach-s3c/mach-mini2440.c
> +++ b/arch/arm/mach-s3c/mach-mini2440.c
> @@ -624,7 +624,7 @@ static char mini2440_features_str[12] __initdata = "0tb";
>  static int __init mini2440_features_setup(char *str)
>  {
>  	if (str)
> -		strlcpy(mini2440_features_str, str,
> +		strscpy(mini2440_features_str, str,
>  			sizeof(mini2440_features_str));
>  	return 1;
>  }


Best regards,
Krzysztof

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2022-05-23  7:10   ` Krzysztof Kozlowski
  0 siblings, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2022-05-23  7:10 UTC (permalink / raw)
  To: 陈学兵
  Cc: alim.akhtar, linux, linux-arm-kernel, linux-samsung-soc

On 22/05/2022 17:11, 陈学兵 wrote:
> 
> The strlcpy should not be used because it doesn't limit the source
> length.  Preferred is strscpy.
> 
> Signed-off-by: XueBing Chen <chenxuebing@jari.cn>

Your name in From field does not match exactly one used in
Signed-off-by. Name might be actually the same, but different alphabet
is used. Please use the same one - latin transliteration - in both cases.

> ---
>  arch/arm/mach-s3c/mach-mini2440.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-s3c/mach-mini2440.c b/arch/arm/mach-s3c/mach-mini2440.c
> index 551ec660ab59..98cebc06521c 100644
> --- a/arch/arm/mach-s3c/mach-mini2440.c
> +++ b/arch/arm/mach-s3c/mach-mini2440.c
> @@ -624,7 +624,7 @@ static char mini2440_features_str[12] __initdata = "0tb";
>  static int __init mini2440_features_setup(char *str)
>  {
>  	if (str)
> -		strlcpy(mini2440_features_str, str,
> +		strscpy(mini2440_features_str, str,
>  			sizeof(mini2440_features_str));
>  	return 1;
>  }


Best regards,
Krzysztof

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2022-05-22 15:11 ` 陈学兵
  0 siblings, 0 replies; 10+ messages in thread
From: 陈学兵 @ 2022-05-22 15:11 UTC (permalink / raw)
  To: krzk; +Cc: alim.akhtar, linux, linux-arm-kernel, linux-samsung-soc


The strlcpy should not be used because it doesn't limit the source
length.  Preferred is strscpy.

Signed-off-by: XueBing Chen <chenxuebing@jari.cn>
---
 arch/arm/mach-s3c/mach-mini2440.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c/mach-mini2440.c b/arch/arm/mach-s3c/mach-mini2440.c
index 551ec660ab59..98cebc06521c 100644
--- a/arch/arm/mach-s3c/mach-mini2440.c
+++ b/arch/arm/mach-s3c/mach-mini2440.c
@@ -624,7 +624,7 @@ static char mini2440_features_str[12] __initdata = "0tb";
 static int __init mini2440_features_setup(char *str)
 {
 	if (str)
-		strlcpy(mini2440_features_str, str,
+		strscpy(mini2440_features_str, str,
 			sizeof(mini2440_features_str));
 	return 1;
 }
-- 
2.36.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH] ARM: s3c: Use strscpy to replace strlcpy
@ 2022-05-22 15:11 ` 陈学兵
  0 siblings, 0 replies; 10+ messages in thread
From: 陈学兵 @ 2022-05-22 15:11 UTC (permalink / raw)
  To: krzk; +Cc: alim.akhtar, linux, linux-arm-kernel, linux-samsung-soc


The strlcpy should not be used because it doesn't limit the source
length.  Preferred is strscpy.

Signed-off-by: XueBing Chen <chenxuebing@jari.cn>
---
 arch/arm/mach-s3c/mach-mini2440.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mach-s3c/mach-mini2440.c b/arch/arm/mach-s3c/mach-mini2440.c
index 551ec660ab59..98cebc06521c 100644
--- a/arch/arm/mach-s3c/mach-mini2440.c
+++ b/arch/arm/mach-s3c/mach-mini2440.c
@@ -624,7 +624,7 @@ static char mini2440_features_str[12] __initdata = "0tb";
 static int __init mini2440_features_setup(char *str)
 {
 	if (str)
-		strlcpy(mini2440_features_str, str,
+		strscpy(mini2440_features_str, str,
 			sizeof(mini2440_features_str));
 	return 1;
 }
-- 
2.36.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-05-23  7:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-06 13:46 [PATCH] ARM: s3c: Use strscpy to replace strlcpy Jason Wang
2021-09-06 13:46 ` Jason Wang
2021-09-06 13:57 ` Krzysztof Kozlowski
2021-09-06 13:57   ` Krzysztof Kozlowski
2021-09-20  8:15 ` Krzysztof Kozlowski
2021-09-20  8:15   ` Krzysztof Kozlowski
2022-05-22 15:11 陈学兵
2022-05-22 15:11 ` 陈学兵
2022-05-23  7:10 ` Krzysztof Kozlowski
2022-05-23  7:10   ` Krzysztof Kozlowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.