From: Alexander Aring <alex.aring@gmail.com>
To: linux-wpan@vger.kernel.org
Cc: linux-bluetooth@vger.kernel.org, kernel@pengutronix.de,
mcr@sandelman.ca, lukasz.duda@nordicsemi.no,
martin.gergeleit@hs-rm.de, Alexander Aring <alex.aring@gmail.com>
Subject: [RFC bluetooth-next 2/4] 6lowpan: iphc: add check for reserved values
Date: Wed, 11 Nov 2015 18:14:37 +0100 [thread overview]
Message-ID: <1447262079-2509-3-git-send-email-alex.aring@gmail.com> (raw)
In-Reply-To: <1447262079-2509-1-git-send-email-alex.aring@gmail.com>
This patch adds a check on reserved values for IPHC header. We should at
first check on these fields instead of doing parsing before. Afterwards
we can be sure there are no reserved values anymore. The reserved bits
doesn't contain reserved values for NHC headers. This need to be handled
inside the next layer.
Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
net/6lowpan/iphc.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/net/6lowpan/iphc.c b/net/6lowpan/iphc.c
index 346b5c1..13f5424 100644
--- a/net/6lowpan/iphc.c
+++ b/net/6lowpan/iphc.c
@@ -455,6 +455,20 @@ static const u8 lowpan_ttl_values[] = {
[LOWPAN_IPHC_HLIM_11] = 255,
};
+static inline bool lowpan_iphc_is_reserved(u8 iphc1)
+{
+ switch (iphc1 & (LOWPAN_IPHC_DAC | LOWPAN_IPHC_M |
+ LOWPAN_IPHC_DAM_MASK)) {
+ case LOWPAN_IPHC_DAC | LOWPAN_IPHC_DAM_00:
+ case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_01:
+ case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_10:
+ case LOWPAN_IPHC_DAC | LOWPAN_IPHC_M | LOWPAN_IPHC_DAM_11:
+ return true;
+ default:
+ return false;
+ }
+}
+
int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
const void *daddr, const void *saddr)
{
@@ -466,7 +480,8 @@ int lowpan_header_decompress(struct sk_buff *skb, const struct net_device *dev,
skb->data, skb->len);
if (lowpan_fetch_skb(skb, &iphc0, sizeof(iphc0)) ||
- lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1)))
+ lowpan_fetch_skb(skb, &iphc1, sizeof(iphc1)) ||
+ lowpan_iphc_is_reserved(iphc1))
return -EINVAL;
/* another if the CID flag is set */
--
2.6.1
next prev parent reply other threads:[~2015-11-11 17:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-11 17:14 [RFC bluetooth-next 0/4] 6lowpan: debugfs and stateful compression support Alexander Aring
2015-11-11 17:14 ` [RFC bluetooth-next 1/4] 6lowpan: add debugfs support Alexander Aring
2015-11-12 17:04 ` Alexander Aring
2015-11-11 17:14 ` Alexander Aring [this message]
2015-11-11 17:14 ` [RFC bluetooth-next 3/4] 6lowpan: iphc: remove handling when dam is zero Alexander Aring
2015-11-11 17:14 ` [RFC bluetooth-next 4/4] 6lowpan: iphc: add support for stateful compression Alexander Aring
2015-11-13 18:08 ` Michael Richardson
2015-11-14 9:20 ` Alexander Aring
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=1447262079-2509-3-git-send-email-alex.aring@gmail.com \
--to=alex.aring@gmail.com \
--cc=kernel@pengutronix.de \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-wpan@vger.kernel.org \
--cc=lukasz.duda@nordicsemi.no \
--cc=martin.gergeleit@hs-rm.de \
--cc=mcr@sandelman.ca \
/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).