All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kselftest: arm64: Add a null pointer check
@ 2024-04-23  8:21 ` Kunwu Chan
  0 siblings, 0 replies; 10+ messages in thread
From: Kunwu Chan @ 2024-04-23  8:21 UTC (permalink / raw)
  To: kunwu.chan, catalin.marinas, will, shuah
  Cc: linux-arm-kernel, linux-kselftest, linux-kernel, Kunwu Chan

There is a 'malloc' call, which can be unsuccessful.
This patch will add the malloc failure checking
to avoid possible null dereference and give more information
about test fail reasons.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
index 5701163460ef..955f87c1170d 100644
--- a/tools/testing/selftests/arm64/tags/tags_test.c
+++ b/tools/testing/selftests/arm64/tags/tags_test.c
@@ -6,6 +6,7 @@
 #include <stdint.h>
 #include <sys/prctl.h>
 #include <sys/utsname.h>
+#include "../../kselftest.h"
 
 #define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
 #define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
@@ -21,6 +22,9 @@ int main(void)
 	if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
 		tbi_enabled = 1;
 	ptr = (struct utsname *)malloc(sizeof(*ptr));
+	if (!ptr)
+		ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
+
 	if (tbi_enabled)
 		tag = 0x42;
 	ptr = (struct utsname *)SET_TAG(ptr, tag);
-- 
2.40.1


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

* [PATCH] kselftest: arm64: Add a null pointer check
@ 2024-04-23  8:21 ` Kunwu Chan
  0 siblings, 0 replies; 10+ messages in thread
From: Kunwu Chan @ 2024-04-23  8:21 UTC (permalink / raw)
  To: kunwu.chan, catalin.marinas, will, shuah
  Cc: linux-arm-kernel, linux-kselftest, linux-kernel, Kunwu Chan

There is a 'malloc' call, which can be unsuccessful.
This patch will add the malloc failure checking
to avoid possible null dereference and give more information
about test fail reasons.

Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
index 5701163460ef..955f87c1170d 100644
--- a/tools/testing/selftests/arm64/tags/tags_test.c
+++ b/tools/testing/selftests/arm64/tags/tags_test.c
@@ -6,6 +6,7 @@
 #include <stdint.h>
 #include <sys/prctl.h>
 #include <sys/utsname.h>
+#include "../../kselftest.h"
 
 #define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
 #define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
@@ -21,6 +22,9 @@ int main(void)
 	if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
 		tbi_enabled = 1;
 	ptr = (struct utsname *)malloc(sizeof(*ptr));
+	if (!ptr)
+		ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
+
 	if (tbi_enabled)
 		tag = 0x42;
 	ptr = (struct utsname *)SET_TAG(ptr, tag);
-- 
2.40.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

* Re: [PATCH] kselftest: arm64: Add a null pointer check
  2024-04-23  8:21 ` Kunwu Chan
@ 2024-04-23  8:42   ` Muhammad Usama Anjum
  -1 siblings, 0 replies; 10+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-23  8:42 UTC (permalink / raw)
  To: Kunwu Chan, kunwu.chan, catalin.marinas, will, shuah
  Cc: Muhammad Usama Anjum, linux-arm-kernel, linux-kselftest, linux-kernel

On 4/23/24 1:21 PM, Kunwu Chan wrote:
> There is a 'malloc' call, which can be unsuccessful.
> This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
LGTM

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> 
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
>  tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
> index 5701163460ef..955f87c1170d 100644
> --- a/tools/testing/selftests/arm64/tags/tags_test.c
> +++ b/tools/testing/selftests/arm64/tags/tags_test.c
> @@ -6,6 +6,7 @@
>  #include <stdint.h>
>  #include <sys/prctl.h>
>  #include <sys/utsname.h>
> +#include "../../kselftest.h"
The test isn't conformed to TAP. Maybe the next patch could be to conform
the whole test into TAP, would be easy and straight forward.

>  
>  #define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
>  #define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
> @@ -21,6 +22,9 @@ int main(void)
>  	if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
>  		tbi_enabled = 1;
>  	ptr = (struct utsname *)malloc(sizeof(*ptr));
> +	if (!ptr)
> +		ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
> +
>  	if (tbi_enabled)
>  		tag = 0x42;
>  	ptr = (struct utsname *)SET_TAG(ptr, tag);

-- 
BR,
Muhammad Usama Anjum

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

* Re: [PATCH] kselftest: arm64: Add a null pointer check
@ 2024-04-23  8:42   ` Muhammad Usama Anjum
  0 siblings, 0 replies; 10+ messages in thread
From: Muhammad Usama Anjum @ 2024-04-23  8:42 UTC (permalink / raw)
  To: Kunwu Chan, kunwu.chan, catalin.marinas, will, shuah
  Cc: Muhammad Usama Anjum, linux-arm-kernel, linux-kselftest, linux-kernel

On 4/23/24 1:21 PM, Kunwu Chan wrote:
> There is a 'malloc' call, which can be unsuccessful.
> This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
LGTM

Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> 
> Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
> ---
>  tools/testing/selftests/arm64/tags/tags_test.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/tools/testing/selftests/arm64/tags/tags_test.c b/tools/testing/selftests/arm64/tags/tags_test.c
> index 5701163460ef..955f87c1170d 100644
> --- a/tools/testing/selftests/arm64/tags/tags_test.c
> +++ b/tools/testing/selftests/arm64/tags/tags_test.c
> @@ -6,6 +6,7 @@
>  #include <stdint.h>
>  #include <sys/prctl.h>
>  #include <sys/utsname.h>
> +#include "../../kselftest.h"
The test isn't conformed to TAP. Maybe the next patch could be to conform
the whole test into TAP, would be easy and straight forward.

>  
>  #define SHIFT_TAG(tag)		((uint64_t)(tag) << 56)
>  #define SET_TAG(ptr, tag)	(((uint64_t)(ptr) & ~SHIFT_TAG(0xff)) | \
> @@ -21,6 +22,9 @@ int main(void)
>  	if (prctl(PR_SET_TAGGED_ADDR_CTRL, PR_TAGGED_ADDR_ENABLE, 0, 0, 0) == 0)
>  		tbi_enabled = 1;
>  	ptr = (struct utsname *)malloc(sizeof(*ptr));
> +	if (!ptr)
> +		ksft_exit_fail_msg("Failed to allocate utsname buffer\n");
> +
>  	if (tbi_enabled)
>  		tag = 0x42;
>  	ptr = (struct utsname *)SET_TAG(ptr, tag);

-- 
BR,
Muhammad Usama Anjum

_______________________________________________
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] kselftest: arm64: Add a null pointer check
  2024-04-23  8:21 ` Kunwu Chan
@ 2024-04-23  9:00   ` Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2024-04-23  9:00 UTC (permalink / raw)
  To: Kunwu Chan, linux-kselftest, kernel-janitors, linux-arm-kernel,
	Catalin Marinas, Muhammad Usama Anjum, Shuah Khan, Will Deacon
  Cc: LKML, Kunwu Chan

…
> This patch will add the malloc failure checking
…

* Please use a corresponding imperative wording for the change description.

* Would you like to add the tag “Fixes” accordingly?


Regards,
Markus

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

* Re: [PATCH] kselftest: arm64: Add a null pointer check
@ 2024-04-23  9:00   ` Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2024-04-23  9:00 UTC (permalink / raw)
  To: Kunwu Chan, linux-kselftest, kernel-janitors, linux-arm-kernel,
	Catalin Marinas, Muhammad Usama Anjum, Shuah Khan, Will Deacon
  Cc: LKML, Kunwu Chan

…
> This patch will add the malloc failure checking
…

* Please use a corresponding imperative wording for the change description.

* Would you like to add the tag “Fixes” accordingly?


Regards,
Markus

_______________________________________________
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] kselftest: arm64: Add a null pointer check
  2024-04-23  8:21 ` Kunwu Chan
@ 2024-04-28  8:59   ` Will Deacon
  -1 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2024-04-28  8:59 UTC (permalink / raw)
  To: kunwu.chan, catalin.marinas, shuah, Kunwu Chan
  Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kselftest,
	linux-kernel

On Tue, 23 Apr 2024 16:21:02 +0800, Kunwu Chan wrote:
> There is a 'malloc' call, which can be unsuccessful.
> This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
> 
> 

Applied to arm64 (for-next/selftests), thanks!

[1/1] kselftest: arm64: Add a null pointer check
      https://git.kernel.org/arm64/c/80164282b362

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

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

* Re: [PATCH] kselftest: arm64: Add a null pointer check
@ 2024-04-28  8:59   ` Will Deacon
  0 siblings, 0 replies; 10+ messages in thread
From: Will Deacon @ 2024-04-28  8:59 UTC (permalink / raw)
  To: kunwu.chan, catalin.marinas, shuah, Kunwu Chan
  Cc: kernel-team, Will Deacon, linux-arm-kernel, linux-kselftest,
	linux-kernel

On Tue, 23 Apr 2024 16:21:02 +0800, Kunwu Chan wrote:
> There is a 'malloc' call, which can be unsuccessful.
> This patch will add the malloc failure checking
> to avoid possible null dereference and give more information
> about test fail reasons.
> 
> 

Applied to arm64 (for-next/selftests), thanks!

[1/1] kselftest: arm64: Add a null pointer check
      https://git.kernel.org/arm64/c/80164282b362

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
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: kselftest: arm64: Add a null pointer check
  2024-04-28  8:59   ` Will Deacon
@ 2024-04-28 15:38     ` Markus Elfring
  -1 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2024-04-28 15:38 UTC (permalink / raw)
  To: Kunwu Chan, Will Deacon, linux-kselftest
  Cc: LKML, kernel-janitors, linux-arm-kernel, kernel-team, Kunwu Chan,
	Catalin Marinas, Muhammad Usama Anjum, Shuah Khan

> > There is a 'malloc' call, which can be unsuccessful.
> > This patch will add the malloc failure checking
> > to avoid possible null dereference and give more information
> > about test fail reasons.
>
> Applied to arm64 (for-next/selftests), thanks!
>
> [1/1] kselftest: arm64: Add a null pointer check
>       https://git.kernel.org/arm64/c/80164282b362

Why did you not adhere to known requirements for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc5#n94

* Imperative mood

* Addition of the tag “Fixes”


Regards,
Markus

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

* Re: kselftest: arm64: Add a null pointer check
@ 2024-04-28 15:38     ` Markus Elfring
  0 siblings, 0 replies; 10+ messages in thread
From: Markus Elfring @ 2024-04-28 15:38 UTC (permalink / raw)
  To: Kunwu Chan, Will Deacon, linux-kselftest
  Cc: LKML, kernel-janitors, linux-arm-kernel, kernel-team, Kunwu Chan,
	Catalin Marinas, Muhammad Usama Anjum, Shuah Khan

> > There is a 'malloc' call, which can be unsuccessful.
> > This patch will add the malloc failure checking
> > to avoid possible null dereference and give more information
> > about test fail reasons.
>
> Applied to arm64 (for-next/selftests), thanks!
>
> [1/1] kselftest: arm64: Add a null pointer check
>       https://git.kernel.org/arm64/c/80164282b362

Why did you not adhere to known requirements for such a change description?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.9-rc5#n94

* Imperative mood

* Addition of the tag “Fixes”


Regards,
Markus

_______________________________________________
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

end of thread, other threads:[~2024-04-28 15:39 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-23  8:21 [PATCH] kselftest: arm64: Add a null pointer check Kunwu Chan
2024-04-23  8:21 ` Kunwu Chan
2024-04-23  8:42 ` Muhammad Usama Anjum
2024-04-23  8:42   ` Muhammad Usama Anjum
2024-04-23  9:00 ` Markus Elfring
2024-04-23  9:00   ` Markus Elfring
2024-04-28  8:59 ` Will Deacon
2024-04-28  8:59   ` Will Deacon
2024-04-28 15:38   ` Markus Elfring
2024-04-28 15:38     ` Markus Elfring

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.