The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* Re: [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name
       [not found] ` <20260504075036.12190-1-zxl434815272@gmail.com>
@ 2026-05-04 12:45   ` David Laight
  2026-05-07  0:02     ` 007
       [not found]   ` <20260504075036.12190-2-zxl434815272@gmail.com>
       [not found]   ` <20260504075036.12190-3-zxl434815272@gmail.com>
  2 siblings, 1 reply; 7+ messages in thread
From: David Laight @ 2026-05-04 12:45 UTC (permalink / raw)
  To: Zhang Xiaolei; +Cc: linux-gpio, brgl, warthog618, linux-kernel

On Mon,  4 May 2026 15:50:34 +0800
Zhang Xiaolei <zxl434815272@gmail.com> wrote:

> Replace strcpy() with strscpy() to avoid potential buffer overflow
> when copying the consumer string.

You ought to run code before submitting patches.
This wasn't even compiled.

-- David

> 
> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
> ---
>  tools/gpio/gpio-utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
> index 4096bcd511d1..176bccfcccb0 100644
> --- a/tools/gpio/gpio-utils.c
> +++ b/tools/gpio/gpio-utils.c
> @@ -82,7 +82,7 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
>  		req.offsets[i] = lines[i];
>  
>  	req.config = *config;
> -	strcpy(req.consumer, consumer);
> +	strcpy(req.consumer, consumer, sizeof(req.consumer));
>  	req.num_lines = num_lines;
>  
>  	ret = ioctl(fd, GPIO_V2_GET_LINE_IOCTL, &req);


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

* Re: [PATCH v2 2/3] tools: gpio: validate arguments in gpiotools_request_line
       [not found]   ` <20260504075036.12190-2-zxl434815272@gmail.com>
@ 2026-05-04 16:13     ` Maxwell Doose
  2026-05-07  0:04       ` 007
  0 siblings, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 16:13 UTC (permalink / raw)
  To: Zhang Xiaolei; +Cc: linux-gpio, brgl, warthog618, linux-kernel

On Mon, May 4, 2026 at 2:56 AM Zhang Xiaolei <zxl434815272@gmail.com> wrote:
>
> Add validation for input pointers and number of lines.
>

Perhaps make the commit message more descriptive?

>
> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
> ---
>  tools/gpio/gpio-utils.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
> index 176bccfcccb0..930a38fe7911 100644
> --- a/tools/gpio/gpio-utils.c
> +++ b/tools/gpio/gpio-utils.c
> @@ -65,6 +65,12 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
>         int i;
>         int ret;
>
> +       if (!device_name || !lines || !config || !consumer || !num_lines)
> +               return -EINVAL;
> +
> +       if (num_lines > GPIO_V2_LINES_MAX)
> +               return -EINVAL;
> +

I'm wondering if we might want to use ERANGE here for the num_lines >
GPIO_V2_LINES_MAX check instead of EINVAL.

best regards,
maxwell

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

* Re: [PATCH v2 3/3] tools: gpio: fix ioctl name in error message
       [not found]   ` <20260504075036.12190-3-zxl434815272@gmail.com>
@ 2026-05-04 17:47     ` Maxwell Doose
  2026-05-07  0:03       ` 007
  2026-05-07  0:41     ` [PATCH v3] " Zhang Xiaolei
  1 sibling, 1 reply; 7+ messages in thread
From: Maxwell Doose @ 2026-05-04 17:47 UTC (permalink / raw)
  To: Zhang Xiaolei; +Cc: linux-gpio, brgl, warthog618, linux-kernel

Hi Zhang,

On Mon, May 4, 2026 at 2:56 AM Zhang Xiaolei <zxl434815272@gmail.com> wrote:
>
> Use the correct ioctl name in the error message.
>
> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
> ---
>  tools/gpio/gpio-utils.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
[snip]

Patch looks technically good but when I meant split these patches I
meant into entirely separate patches. Please split this away from the
patch series.

best regards,
max

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

* Re: [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name
  2026-05-04 12:45   ` [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name David Laight
@ 2026-05-07  0:02     ` 007
  0 siblings, 0 replies; 7+ messages in thread
From: 007 @ 2026-05-07  0:02 UTC (permalink / raw)
  To: David Laight; +Cc: linux-gpio, brgl, warthog618, linux-kernel

OK, I will check it next time, thanks for the reminder.

Best regards

Zhang Xiaolei


On 5/4/26 20:45, David Laight wrote:
> On Mon,  4 May 2026 15:50:34 +0800
> Zhang Xiaolei <zxl434815272@gmail.com> wrote:
>
>> Replace strcpy() with strscpy() to avoid potential buffer overflow
>> when copying the consumer string.
> You ought to run code before submitting patches.
> This wasn't even compiled.
>
> -- David
>
>> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
>> ---
>>   tools/gpio/gpio-utils.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
>> index 4096bcd511d1..176bccfcccb0 100644
>> --- a/tools/gpio/gpio-utils.c
>> +++ b/tools/gpio/gpio-utils.c
>> @@ -82,7 +82,7 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
>>   		req.offsets[i] = lines[i];
>>   
>>   	req.config = *config;
>> -	strcpy(req.consumer, consumer);
>> +	strcpy(req.consumer, consumer, sizeof(req.consumer));
>>   	req.num_lines = num_lines;
>>   
>>   	ret = ioctl(fd, GPIO_V2_GET_LINE_IOCTL, &req);

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

* Re: [PATCH v2 3/3] tools: gpio: fix ioctl name in error message
  2026-05-04 17:47     ` [PATCH v2 3/3] tools: gpio: fix ioctl name in error message Maxwell Doose
@ 2026-05-07  0:03       ` 007
  0 siblings, 0 replies; 7+ messages in thread
From: 007 @ 2026-05-07  0:03 UTC (permalink / raw)
  To: Maxwell Doose; +Cc: linux-gpio, brgl, warthog618, linux-kernel

Hi, bro, I will redo it, thanks for the reminder.

Best regards

Zhang Xiaolei

On 5/5/26 01:47, Maxwell Doose wrote:
> Hi Zhang,
>
> On Mon, May 4, 2026 at 2:56 AM Zhang Xiaolei <zxl434815272@gmail.com> wrote:
>> Use the correct ioctl name in the error message.
>>
>> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
>> ---
>>   tools/gpio/gpio-utils.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
> [snip]
>
> Patch looks technically good but when I meant split these patches I
> meant into entirely separate patches. Please split this away from the
> patch series.
>
> best regards,
> max

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

* Re: [PATCH v2 2/3] tools: gpio: validate arguments in gpiotools_request_line
  2026-05-04 16:13     ` [PATCH v2 2/3] tools: gpio: validate arguments in gpiotools_request_line Maxwell Doose
@ 2026-05-07  0:04       ` 007
  0 siblings, 0 replies; 7+ messages in thread
From: 007 @ 2026-05-07  0:04 UTC (permalink / raw)
  To: Maxwell Doose; +Cc: linux-gpio, brgl, warthog618, linux-kernel

OK, I will redo it, thanks.

Best regards,

Zhang Xiaolei

On 5/5/26 00:13, Maxwell Doose wrote:
> On Mon, May 4, 2026 at 2:56 AM Zhang Xiaolei <zxl434815272@gmail.com> wrote:
>> Add validation for input pointers and number of lines.
>>
> Perhaps make the commit message more descriptive?
>
>> Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
>> ---
>>   tools/gpio/gpio-utils.c | 6 ++++++
>>   1 file changed, 6 insertions(+)
>>
>> diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
>> index 176bccfcccb0..930a38fe7911 100644
>> --- a/tools/gpio/gpio-utils.c
>> +++ b/tools/gpio/gpio-utils.c
>> @@ -65,6 +65,12 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
>>          int i;
>>          int ret;
>>
>> +       if (!device_name || !lines || !config || !consumer || !num_lines)
>> +               return -EINVAL;
>> +
>> +       if (num_lines > GPIO_V2_LINES_MAX)
>> +               return -EINVAL;
>> +
> I'm wondering if we might want to use ERANGE here for the num_lines >
> GPIO_V2_LINES_MAX check instead of EINVAL.
>
> best regards,
> maxwell

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

* [PATCH v3] tools: gpio: fix ioctl name in error message
       [not found]   ` <20260504075036.12190-3-zxl434815272@gmail.com>
  2026-05-04 17:47     ` [PATCH v2 3/3] tools: gpio: fix ioctl name in error message Maxwell Doose
@ 2026-05-07  0:41     ` Zhang Xiaolei
  1 sibling, 0 replies; 7+ messages in thread
From: Zhang Xiaolei @ 2026-05-07  0:41 UTC (permalink / raw)
  To: linux-gpio; +Cc: brgl, warthog618, linux-kernel, Zhang Xiaolei

Use the correct ioctl name in the error message.

Signed-off-by: Zhang Xiaolei <zxl434815272@gmail.com>
---
 tools/gpio/gpio-utils.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c
index 930a38fe7911..0d52d58cc6b6 100644
--- a/tools/gpio/gpio-utils.c
+++ b/tools/gpio/gpio-utils.c
@@ -95,7 +95,7 @@ int gpiotools_request_line(const char *device_name, unsigned int *lines,
 	if (ret == -1) {
 		ret = -errno;
 		fprintf(stderr, "Failed to issue %s (%d), %s\n",
-			"GPIO_GET_LINE_IOCTL", ret, strerror(errno));
+			"GPIO_V2_GET_LINE_IOCTL", ret, strerror(errno));
 	}
 
 	if (close(fd) == -1)
-- 
2.34.1


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

end of thread, other threads:[~2026-05-07  0:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260503190016.13439-1-zxl434815272@gmail.com>
     [not found] ` <20260504075036.12190-1-zxl434815272@gmail.com>
2026-05-04 12:45   ` [PATCH v2 1/3] tools: gpio: use strscpy() for consumer name David Laight
2026-05-07  0:02     ` 007
     [not found]   ` <20260504075036.12190-2-zxl434815272@gmail.com>
2026-05-04 16:13     ` [PATCH v2 2/3] tools: gpio: validate arguments in gpiotools_request_line Maxwell Doose
2026-05-07  0:04       ` 007
     [not found]   ` <20260504075036.12190-3-zxl434815272@gmail.com>
2026-05-04 17:47     ` [PATCH v2 3/3] tools: gpio: fix ioctl name in error message Maxwell Doose
2026-05-07  0:03       ` 007
2026-05-07  0:41     ` [PATCH v3] " Zhang Xiaolei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox