* [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test
@ 2026-07-10 11:23 Thomas Huth
2026-07-21 20:56 ` Jakub Kicinski
2026-08-13 14:45 ` Thomas Huth
0 siblings, 2 replies; 4+ messages in thread
From: Thomas Huth @ 2026-07-10 11:23 UTC (permalink / raw)
To: Bongsu Jeon, netdev; +Cc: Shuah Khan, linux-kselftest, linux-kernel
From: Thomas Huth <thuth@redhat.com>
pthread_join() stores the thread's return value (a "void *", i.e.
8 bytes on 64 bit computers) into the address of "status", but the
"status" variable is declared as "int" with only 4 bytes. The extra
four bytes clobber whatever is adjacent on the stack, which could
silently corrupt other local variables. Use "intptr_t" to declare
the "status" variables with the correct size.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
tools/testing/selftests/nci/nci_dev.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/nci/nci_dev.c b/tools/testing/selftests/nci/nci_dev.c
index 312f84ee0444f..4e7a5856f7ea3 100644
--- a/tools/testing/selftests/nci/nci_dev.c
+++ b/tools/testing/selftests/nci/nci_dev.c
@@ -6,6 +6,7 @@
* Test code for nci
*/
+#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
@@ -404,7 +405,7 @@ FIXTURE_SETUP(NCI)
struct msgtemplate msg;
pthread_t thread_t;
__u32 event_group;
- int status;
+ intptr_t status;
int rc;
self->open_state = false;
@@ -497,7 +498,7 @@ static void *virtual_deinit_v2(void *data)
FIXTURE_TEARDOWN(NCI)
{
pthread_t thread_t;
- int status;
+ intptr_t status;
int rc;
if (self->open_state) {
@@ -585,7 +586,7 @@ int start_polling(int dev_idx, int proto, int virtual_fd, int sd, int fid, int p
void *nla_start_poll_data[2] = {&dev_idx, &proto};
int nla_start_poll_len[2] = {4, 4};
pthread_t thread_t;
- int status;
+ intptr_t status;
int rc;
rc = pthread_create(&thread_t, NULL, virtual_poll_start,
@@ -605,7 +606,7 @@ int start_polling(int dev_idx, int proto, int virtual_fd, int sd, int fid, int p
int stop_polling(int dev_idx, int virtual_fd, int sd, int fid, int pid)
{
pthread_t thread_t;
- int status;
+ intptr_t status;
int rc;
rc = pthread_create(&thread_t, NULL, virtual_poll_stop,
@@ -816,7 +817,7 @@ int disconnect_tag(int nfc_sock, int virtual_fd)
{
pthread_t thread_t;
char buf[256];
- int status;
+ intptr_t status;
int len;
send(nfc_sock, &nci_t4t_select_cmd3[3], sizeof(nci_t4t_select_cmd3) - 3, 0);
@@ -860,7 +861,7 @@ TEST_F(NCI, deinit)
{
struct msgtemplate msg;
pthread_t thread_t;
- int status;
+ intptr_t status;
int rc;
rc = get_nci_devid(self->sd, self->fid, self->pid, self->dev_idex,
--
2.55.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test
2026-07-10 11:23 [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test Thomas Huth
@ 2026-07-21 20:56 ` Jakub Kicinski
2026-08-13 14:45 ` Thomas Huth
1 sibling, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2026-07-21 20:56 UTC (permalink / raw)
To: Thomas Huth, oe-linux-nfc
Cc: Bongsu Jeon, netdev, Shuah Khan, linux-kselftest, linux-kernel
On Fri, 10 Jul 2026 13:23:00 +0200 Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> pthread_join() stores the thread's return value (a "void *", i.e.
> 8 bytes on 64 bit computers) into the address of "status", but the
> "status" variable is declared as "int" with only 4 bytes. The extra
> four bytes clobber whatever is adjacent on the stack, which could
> silently corrupt other local variables. Use "intptr_t" to declare
> the "status" variables with the correct size.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
This should go via nfc, I just sent a patch to update MAINTAINERS.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test
2026-07-10 11:23 [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test Thomas Huth
2026-07-21 20:56 ` Jakub Kicinski
@ 2026-08-13 14:45 ` Thomas Huth
2026-08-17 17:30 ` David Heidelberg
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Huth @ 2026-08-13 14:45 UTC (permalink / raw)
To: Bongsu Jeon, David Heidelberg
Cc: Shuah Khan, linux-kselftest, linux-kernel, oe-linux-nfc
On 10/07/2026 13.23, Thomas Huth wrote:
> From: Thomas Huth <thuth@redhat.com>
>
> pthread_join() stores the thread's return value (a "void *", i.e.
> 8 bytes on 64 bit computers) into the address of "status", but the
> "status" variable is declared as "int" with only 4 bytes. The extra
> four bytes clobber whatever is adjacent on the stack, which could
> silently corrupt other local variables. Use "intptr_t" to declare
> the "status" variables with the correct size.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
> tools/testing/selftests/nci/nci_dev.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/tools/testing/selftests/nci/nci_dev.c b/tools/testing/selftests/nci/nci_dev.c
> index 312f84ee0444f..4e7a5856f7ea3 100644
> --- a/tools/testing/selftests/nci/nci_dev.c
> +++ b/tools/testing/selftests/nci/nci_dev.c
> @@ -6,6 +6,7 @@
> * Test code for nci
> */
>
> +#include <stdint.h>
> #include <stdlib.h>
> #include <errno.h>
> #include <string.h>
> @@ -404,7 +405,7 @@ FIXTURE_SETUP(NCI)
> struct msgtemplate msg;
> pthread_t thread_t;
> __u32 event_group;
> - int status;
> + intptr_t status;
> int rc;
>
> self->open_state = false;
> @@ -497,7 +498,7 @@ static void *virtual_deinit_v2(void *data)
> FIXTURE_TEARDOWN(NCI)
> {
> pthread_t thread_t;
> - int status;
> + intptr_t status;
> int rc;
>
> if (self->open_state) {
> @@ -585,7 +586,7 @@ int start_polling(int dev_idx, int proto, int virtual_fd, int sd, int fid, int p
> void *nla_start_poll_data[2] = {&dev_idx, &proto};
> int nla_start_poll_len[2] = {4, 4};
> pthread_t thread_t;
> - int status;
> + intptr_t status;
> int rc;
>
> rc = pthread_create(&thread_t, NULL, virtual_poll_start,
> @@ -605,7 +606,7 @@ int start_polling(int dev_idx, int proto, int virtual_fd, int sd, int fid, int p
> int stop_polling(int dev_idx, int virtual_fd, int sd, int fid, int pid)
> {
> pthread_t thread_t;
> - int status;
> + intptr_t status;
> int rc;
>
> rc = pthread_create(&thread_t, NULL, virtual_poll_stop,
> @@ -816,7 +817,7 @@ int disconnect_tag(int nfc_sock, int virtual_fd)
> {
> pthread_t thread_t;
> char buf[256];
> - int status;
> + intptr_t status;
> int len;
>
> send(nfc_sock, &nci_t4t_select_cmd3[3], sizeof(nci_t4t_select_cmd3) - 3, 0);
> @@ -860,7 +861,7 @@ TEST_F(NCI, deinit)
> {
> struct msgtemplate msg;
> pthread_t thread_t;
> - int status;
> + intptr_t status;
> int rc;
>
> rc = get_nci_devid(self->sd, self->fid, self->pid, self->dev_idex,
Friendly ping!
Thomas
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test
2026-08-13 14:45 ` Thomas Huth
@ 2026-08-17 17:30 ` David Heidelberg
0 siblings, 0 replies; 4+ messages in thread
From: David Heidelberg @ 2026-08-17 17:30 UTC (permalink / raw)
To: Thomas Huth, Bongsu Jeon
Cc: Shuah Khan, linux-kselftest, linux-kernel, oe-linux-nfc
On 13/08/2026 16:45, Thomas Huth wrote:
> On 10/07/2026 13.23, Thomas Huth wrote:
>> From: Thomas Huth <thuth@redhat.com>
[...]
Hello Thomas,
sadly this one missed my inbox for some reason.
Could you please send v2 with added `Fixes: ` and `Cc: stable@vger.kernel.org` tags?
Thanks
David
>
> Friendly ping!
>
> Thomas
>
--
David Heidelberg
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-08-17 17:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-10 11:23 [PATCH] selftests: nci: Fix wrong size of status variables in nci_dev test Thomas Huth
2026-07-21 20:56 ` Jakub Kicinski
2026-08-13 14:45 ` Thomas Huth
2026-08-17 17:30 ` David Heidelberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®