All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed
@ 2021-06-21 22:28 Gabriel Knezek
  2021-06-22  2:06 ` Kent Gibson
  2021-06-22  7:55 ` Bartosz Golaszewski
  0 siblings, 2 replies; 4+ messages in thread
From: Gabriel Knezek @ 2021-06-21 22:28 UTC (permalink / raw)
  To: linux-kernel, linux-gpio, bgolaszewski, linus.walleij, joe.reviewer
  Cc: Gabriel Knezek

When userspace requests a GPIO v1 line info changed event,
lineinfo_watch_read() populates and returns the gpioline_info_changed
structure. It contains 5 words of padding at the end which are not
initialized before being returned to userspace.

Zero the structure in gpio_v2_line_info_change_to_v1() before populating
its contents.

Fixes: aad955842d1c ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and
GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
Signed-off-by: Gabriel Knezek <gabeknez@linux.microsoft.com>
---
Changes in v3:
  - Include the Fixes tag referencing the code being fixed and properly
    version the patch.

Changes in v2:
  - Update commit message and subject with suggestions about clarity.
  - Patch series at https://www.spinics.net/lists/linux-gpio/msg62163.html

v1:
  - Initial patch
  - Patch series at https://www.spinics.net/lists/linux-gpio/msg62084.html

 drivers/gpio/gpiolib-cdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index ee5903aac497..af68532835fe 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -1865,6 +1865,7 @@ static void gpio_v2_line_info_changed_to_v1(
 		struct gpio_v2_line_info_changed *lic_v2,
 		struct gpioline_info_changed *lic_v1)
 {
+	memset(lic_v1, 0, sizeof(*lic_v1));
 	gpio_v2_line_info_to_v1(&lic_v2->info, &lic_v1->info);
 	lic_v1->timestamp = lic_v2->timestamp_ns;
 	lic_v1->event_type = lic_v2->event_type;
-- 
2.25.1


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

* Re: [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed
  2021-06-21 22:28 [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed Gabriel Knezek
@ 2021-06-22  2:06 ` Kent Gibson
  2021-06-22  2:42   ` Kent Gibson
  2021-06-22  7:55 ` Bartosz Golaszewski
  1 sibling, 1 reply; 4+ messages in thread
From: Kent Gibson @ 2021-06-22  2:06 UTC (permalink / raw)
  To: Gabriel Knezek, bgolaszewski
  Cc: linux-kernel, linux-gpio, linus.walleij, andy.shevchenko

On Mon, Jun 21, 2021 at 03:28:59PM -0700, Gabriel Knezek wrote:
> When userspace requests a GPIO v1 line info changed event,
> lineinfo_watch_read() populates and returns the gpioline_info_changed
> structure. It contains 5 words of padding at the end which are not
> initialized before being returned to userspace.
> 
> Zero the structure in gpio_v2_line_info_change_to_v1() before populating
> its contents.
> 
> Fixes: aad955842d1c ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and
> GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
> Signed-off-by: Gabriel Knezek <gabeknez@linux.microsoft.com>
> ---
> Changes in v3:
>   - Include the Fixes tag referencing the code being fixed and properly
>     version the patch.
> 
> Changes in v2:
>   - Update commit message and subject with suggestions about clarity.
>   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62163.html
> 
> v1:
>   - Initial patch
>   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62084.html
> 
>  drivers/gpio/gpiolib-cdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index ee5903aac497..af68532835fe 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -1865,6 +1865,7 @@ static void gpio_v2_line_info_changed_to_v1(
>  		struct gpio_v2_line_info_changed *lic_v2,
>  		struct gpioline_info_changed *lic_v1)
>  {
> +	memset(lic_v1, 0, sizeof(*lic_v1));
>  	gpio_v2_line_info_to_v1(&lic_v2->info, &lic_v1->info);
>  	lic_v1->timestamp = lic_v2->timestamp_ns;
>  	lic_v1->event_type = lic_v2->event_type;
> -- 
> 2.25.1
> 

<sigh> The joe.reviewer@hotmail.com in the git send-email example that I
provided off list was just that - an example that you were supposed to
replace with the actual reviewers :|.

I wouldn't generally bother with the links to the previous patch
versions, though it might be helpful given the rename and version
issues of the previous patches in this case.  If you are going to
provide links, use reference style with all the links at the bottom of
the mail.

Other than that, the only problem I have is that the Fixes tag line
shouldn't wrap - it is an exception to the rule.
Bart, are you ok with fixing that on the way in - assuming there are no
other objections?

Cheers,
Kent.


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

* Re: [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed
  2021-06-22  2:06 ` Kent Gibson
@ 2021-06-22  2:42   ` Kent Gibson
  0 siblings, 0 replies; 4+ messages in thread
From: Kent Gibson @ 2021-06-22  2:42 UTC (permalink / raw)
  To: Gabriel Knezek, bgolaszewski
  Cc: linux-kernel, linux-gpio, linus.walleij, andy.shevchenko

On Tue, Jun 22, 2021 at 10:06:55AM +0800, Kent Gibson wrote:
> On Mon, Jun 21, 2021 at 03:28:59PM -0700, Gabriel Knezek wrote:
> > When userspace requests a GPIO v1 line info changed event,
> > lineinfo_watch_read() populates and returns the gpioline_info_changed
> > structure. It contains 5 words of padding at the end which are not
> > initialized before being returned to userspace.
> > 
> > Zero the structure in gpio_v2_line_info_change_to_v1() before populating
> > its contents.
> > 
> > Fixes: aad955842d1c ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and
> > GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
> > Signed-off-by: Gabriel Knezek <gabeknez@linux.microsoft.com>
> > ---
> > Changes in v3:
> >   - Include the Fixes tag referencing the code being fixed and properly
> >     version the patch.
> > 
> > Changes in v2:
> >   - Update commit message and subject with suggestions about clarity.
> >   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62163.html
> > 
> > v1:
> >   - Initial patch
> >   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62084.html
> > 
> >  drivers/gpio/gpiolib-cdev.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> > index ee5903aac497..af68532835fe 100644
> > --- a/drivers/gpio/gpiolib-cdev.c
> > +++ b/drivers/gpio/gpiolib-cdev.c
> > @@ -1865,6 +1865,7 @@ static void gpio_v2_line_info_changed_to_v1(
> >  		struct gpio_v2_line_info_changed *lic_v2,
> >  		struct gpioline_info_changed *lic_v1)
> >  {
> > +	memset(lic_v1, 0, sizeof(*lic_v1));
> >  	gpio_v2_line_info_to_v1(&lic_v2->info, &lic_v1->info);
> >  	lic_v1->timestamp = lic_v2->timestamp_ns;
> >  	lic_v1->event_type = lic_v2->event_type;
> > -- 
> > 2.25.1
> > 
> 
> <sigh> The joe.reviewer@hotmail.com in the git send-email example that I
> provided off list was just that - an example that you were supposed to
> replace with the actual reviewers :|.
> 
> I wouldn't generally bother with the links to the previous patch
> versions, though it might be helpful given the rename and version
> issues of the previous patches in this case.  If you are going to
> provide links, use reference style with all the links at the bottom of
> the mail.
> 
> Other than that, the only problem I have is that the Fixes tag line
> shouldn't wrap - it is an exception to the rule.
> Bart, are you ok with fixing that on the way in - assuming there are no
> other objections?
> 
Nearly forgot...

Reviewed-by: Kent Gibson <warthog618@gmail.com>

> Cheers,
> Kent.
> 

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

* Re: [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed
  2021-06-21 22:28 [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed Gabriel Knezek
  2021-06-22  2:06 ` Kent Gibson
@ 2021-06-22  7:55 ` Bartosz Golaszewski
  1 sibling, 0 replies; 4+ messages in thread
From: Bartosz Golaszewski @ 2021-06-22  7:55 UTC (permalink / raw)
  To: Gabriel Knezek; +Cc: LKML, linux-gpio, Linus Walleij, joe.reviewer

On Tue, Jun 22, 2021 at 12:29 AM Gabriel Knezek
<gabeknez@linux.microsoft.com> wrote:
>
> When userspace requests a GPIO v1 line info changed event,
> lineinfo_watch_read() populates and returns the gpioline_info_changed
> structure. It contains 5 words of padding at the end which are not
> initialized before being returned to userspace.
>
> Zero the structure in gpio_v2_line_info_change_to_v1() before populating
> its contents.
>
> Fixes: aad955842d1c ("gpiolib: cdev: support GPIO_V2_GET_LINEINFO_IOCTL and
> GPIO_V2_GET_LINEINFO_WATCH_IOCTL")
> Signed-off-by: Gabriel Knezek <gabeknez@linux.microsoft.com>
> ---
> Changes in v3:
>   - Include the Fixes tag referencing the code being fixed and properly
>     version the patch.
>
> Changes in v2:
>   - Update commit message and subject with suggestions about clarity.
>   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62163.html
>
> v1:
>   - Initial patch
>   - Patch series at https://www.spinics.net/lists/linux-gpio/msg62084.html
>
>  drivers/gpio/gpiolib-cdev.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
> index ee5903aac497..af68532835fe 100644
> --- a/drivers/gpio/gpiolib-cdev.c
> +++ b/drivers/gpio/gpiolib-cdev.c
> @@ -1865,6 +1865,7 @@ static void gpio_v2_line_info_changed_to_v1(
>                 struct gpio_v2_line_info_changed *lic_v2,
>                 struct gpioline_info_changed *lic_v1)
>  {
> +       memset(lic_v1, 0, sizeof(*lic_v1));
>         gpio_v2_line_info_to_v1(&lic_v2->info, &lic_v1->info);
>         lic_v1->timestamp = lic_v2->timestamp_ns;
>         lic_v1->event_type = lic_v2->event_type;
> --
> 2.25.1
>

I fixed the wrapping of the Fixes tag and queued this for fixes with
Kent's review tag.

Bart

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

end of thread, other threads:[~2021-06-22  7:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-21 22:28 [PATCH v3] gpiolib: cdev: zero padding during conversion to gpioline_info_changed Gabriel Knezek
2021-06-22  2:06 ` Kent Gibson
2021-06-22  2:42   ` Kent Gibson
2021-06-22  7:55 ` Bartosz Golaszewski

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.