Skip to contentSkip to conversation

platform/surface: aggregator: Fix access of unaligned value

PATCH In review Maximilian Luz 3 participants 3 messages Feb 11, 2021

Subsystems (3)
lore
Share & tools
lore

Maximilian Luz

author maintainer
#0 lore raw

PATCH v2 1/1 platform/surface: aggregator: Fix access of unaligned value

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.

Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")

---

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(-)
drivers/platform/surface/aggregator/ssh_packet_layer.c +1 -1
index 583315db8b02..15d96eac6811 100644
@@ -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)
Signature · 1 line
2.30.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 6 lines · Maximilian Luz

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.

Quoted 34 lines
Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")

---

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(-)
drivers/platform/surface/aggregator/ssh_packet_layer.c +1 -1
index 583315db8b02..15d96eac6811 100644
@@ -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)
Signature · 1 line
2.30.0
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
In reply to Maximilian Luz

Hi,

Quoted 10 lines · Maximilian Luz

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.

Fixes c167b9c7e3d6 ("platform/surface: Add Surface Aggregator subsystem")

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

Quoted 29 lines

---

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(-)
drivers/platform/surface/aggregator/ssh_packet_layer.c +1 -1
index 583315db8b02..15d96eac6811 100644
@@ -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)