linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] monitor/rfcomm: Fix a potential memory access issue
@ 2016-11-19  1:32 mcchou
  2016-11-21 10:06 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 8+ messages in thread
From: mcchou @ 2016-11-19  1:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: luiz.von.dentz, josephsih, Miao-chen Chou

From: Miao-chen Chou <mcchou@chromium.org>

Packed structs have a default alignment of 1. If address of a member
is taken, the pointer value could be unaligned. Unaligned memory accesses
can result in a crash in some architectures.
---
 monitor/rfcomm.c | 2 +-
 monitor/rfcomm.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/monitor/rfcomm.c b/monitor/rfcomm.c
index b32ad40..7c688af 100644
--- a/monitor/rfcomm.c
+++ b/monitor/rfcomm.c
@@ -106,7 +106,7 @@ struct rfcomm_rpn {
 	uint8_t xon;
 	uint8_t xoff;
 	uint16_t pm;
-} __attribute__ ((packed));
+} __attribute__ ((packed, aligned(2)));

 struct rfcomm_rls {
 	uint8_t dlci;
diff --git a/monitor/rfcomm.h b/monitor/rfcomm.h
index c157352..a8af484 100644
--- a/monitor/rfcomm.h
+++ b/monitor/rfcomm.h
@@ -77,4 +77,4 @@ struct rfcomm_pn {
 	uint16_t mtu;
 	uint8_t  max_retrans;
 	uint8_t  credits;
-} __attribute__((packed));
+} __attribute__((packed, aligned(2)));
--
2.8.0.rc3.226.g39d4020


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

end of thread, other threads:[~2016-12-07 23:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-19  1:32 [PATCH] monitor/rfcomm: Fix a potential memory access issue mcchou
2016-11-21 10:06 ` Luiz Augusto von Dentz
2016-11-21 10:18   ` Luiz Augusto von Dentz
2016-12-03  2:08     ` [PATCH 2/2] " mcchou
2016-12-07 14:12       ` Luiz Augusto von Dentz
2016-12-07 20:27         ` Miao-chen Chou
2016-12-07 21:07           ` Johan Hedberg
2016-12-07 23:20             ` Miao-chen Chou

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).