linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] platform/surface: aggregator: Fix access of unaligned value
@ 2021-02-11 12:41 Maximilian Luz
  2021-02-11 13:06 ` Andy Shevchenko
  2021-02-11 15:50 ` Hans de Goede
  0 siblings, 2 replies; 3+ messages in thread
From: Maximilian Luz @ 2021-02-11 12:41 UTC (permalink / raw)
  To: Hans de Goede
  Cc: Maximilian Luz, Mark Gross, Andy Shevchenko, platform-driver-x86,
	linux-kernel, kernel-test-robot

The raw message frame length is unaligned and explicitly marked as
little endian. It should not be accessed without the appropriate
accessor functions. Fix this.

Note that payload.len already contains the correct length after parsing
via sshp_parse_frame(), so we can simply use that instead.

Reported-by: kernel-test-robot <lkp@intel.com>
Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
---

Changes in v2:
 - Use payload.len instead of getting the frame length directly. Note
   that payload.len equals the frame length and is already correctly set
   in sshp_parse_frame(), so they are exactly the same thing. Makes it
   look a bit nicer though.

   I did drop the ACKs/Reveiewd-by in case you want to check that
   yourselves and since that's essentially the whole change.

---
 drivers/platform/surface/aggregator/ssh_packet_layer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/surface/aggregator/ssh_packet_layer.c b/drivers/platform/surface/aggregator/ssh_packet_layer.c
index 583315db8b02..15d96eac6811 100644
--- a/drivers/platform/surface/aggregator/ssh_packet_layer.c
+++ b/drivers/platform/surface/aggregator/ssh_packet_layer.c
@@ -1774,7 +1774,7 @@ static size_t ssh_ptl_rx_eval(struct ssh_ptl *ptl, struct ssam_span *source)
 		break;
 	}
 
-	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(frame->len);
+	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(payload.len);
 }
 
 static int ssh_ptl_rx_threadfn(void *data)
-- 
2.30.0


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

* Re: [PATCH v2] platform/surface: aggregator: Fix access of unaligned value
  2021-02-11 12:41 [PATCH v2] platform/surface: aggregator: Fix access of unaligned value Maximilian Luz
@ 2021-02-11 13:06 ` Andy Shevchenko
  2021-02-11 15:50 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2021-02-11 13:06 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Hans de Goede, Mark Gross, platform-driver-x86, linux-kernel,
	kernel-test-robot

On Thu, Feb 11, 2021 at 01:41:49PM +0100, Maximilian Luz wrote:
> The raw message frame length is unaligned and explicitly marked as
> little endian. It should not be accessed without the appropriate
> accessor functions. Fix this.
> 
> Note that payload.len already contains the correct length after parsing
> via sshp_parse_frame(), so we can simply use that instead.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

> Reported-by: kernel-test-robot <lkp@intel.com>
> Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>
> ---
> 
> Changes in v2:
>  - Use payload.len instead of getting the frame length directly. Note
>    that payload.len equals the frame length and is already correctly set
>    in sshp_parse_frame(), so they are exactly the same thing. Makes it
>    look a bit nicer though.
> 
>    I did drop the ACKs/Reveiewd-by in case you want to check that
>    yourselves and since that's essentially the whole change.
> 
> ---
>  drivers/platform/surface/aggregator/ssh_packet_layer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/surface/aggregator/ssh_packet_layer.c b/drivers/platform/surface/aggregator/ssh_packet_layer.c
> index 583315db8b02..15d96eac6811 100644
> --- a/drivers/platform/surface/aggregator/ssh_packet_layer.c
> +++ b/drivers/platform/surface/aggregator/ssh_packet_layer.c
> @@ -1774,7 +1774,7 @@ static size_t ssh_ptl_rx_eval(struct ssh_ptl *ptl, struct ssam_span *source)
>  		break;
>  	}
>  
> -	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(frame->len);
> +	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(payload.len);
>  }
>  
>  static int ssh_ptl_rx_threadfn(void *data)
> -- 
> 2.30.0
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] platform/surface: aggregator: Fix access of unaligned value
  2021-02-11 12:41 [PATCH v2] platform/surface: aggregator: Fix access of unaligned value Maximilian Luz
  2021-02-11 13:06 ` Andy Shevchenko
@ 2021-02-11 15:50 ` Hans de Goede
  1 sibling, 0 replies; 3+ messages in thread
From: Hans de Goede @ 2021-02-11 15:50 UTC (permalink / raw)
  To: Maximilian Luz
  Cc: Mark Gross, Andy Shevchenko, platform-driver-x86, linux-kernel,
	kernel-test-robot

Hi,

On 2/11/21 1:41 PM, Maximilian Luz wrote:
> The raw message frame length is unaligned and explicitly marked as
> little endian. It should not be accessed without the appropriate
> accessor functions. Fix this.
> 
> Note that payload.len already contains the correct length after parsing
> via sshp_parse_frame(), so we can simply use that instead.
> 
> Reported-by: kernel-test-robot <lkp@intel.com>
> Fixes: c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")
> Signed-off-by: Maximilian Luz <luzmaximilian@gmail.com>

Thank you for your patch, I've applied this patch to my review-hans 
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans

Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.

Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.

Regards,

Hans

> ---
> 
> Changes in v2:
>  - Use payload.len instead of getting the frame length directly. Note
>    that payload.len equals the frame length and is already correctly set
>    in sshp_parse_frame(), so they are exactly the same thing. Makes it
>    look a bit nicer though.
> 
>    I did drop the ACKs/Reveiewd-by in case you want to check that
>    yourselves and since that's essentially the whole change.
> 
> ---
>  drivers/platform/surface/aggregator/ssh_packet_layer.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/surface/aggregator/ssh_packet_layer.c b/drivers/platform/surface/aggregator/ssh_packet_layer.c
> index 583315db8b02..15d96eac6811 100644
> --- a/drivers/platform/surface/aggregator/ssh_packet_layer.c
> +++ b/drivers/platform/surface/aggregator/ssh_packet_layer.c
> @@ -1774,7 +1774,7 @@ static size_t ssh_ptl_rx_eval(struct ssh_ptl *ptl, struct ssam_span *source)
>  		break;
>  	}
>  
> -	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(frame->len);
> +	return aligned.ptr - source->ptr + SSH_MESSAGE_LENGTH(payload.len);
>  }
>  
>  static int ssh_ptl_rx_threadfn(void *data)
> 


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

end of thread, other threads:[~2021-02-11 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 12:41 [PATCH v2] platform/surface: aggregator: Fix access of unaligned value Maximilian Luz
2021-02-11 13:06 ` Andy Shevchenko
2021-02-11 15:50 ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).