From: mcchou@chromium.org
To: linux-bluetooth@vger.kernel.org
Cc: luiz.von.dentz@intel.com, josephsih@chromium.org,
Miao-chen Chou <mcchou@chromium.org>
Subject: [PATCH] monitor/rfcomm: Fix a potential memory access issue
Date: Fri, 18 Nov 2016 17:32:52 -0800 [thread overview]
Message-ID: <1479519172-32499-1-git-send-email-mcchou@chromium.org> (raw)
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
next reply other threads:[~2016-11-19 1:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-19 1:32 mcchou [this message]
2016-11-21 10:06 ` [PATCH] monitor/rfcomm: Fix a potential memory access issue 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1479519172-32499-1-git-send-email-mcchou@chromium.org \
--to=mcchou@chromium.org \
--cc=josephsih@chromium.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.von.dentz@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).