Skip to contentSkip to conversation

irda: validate peer name and attribute lengths

PATCH Applied Dan Rosenberg 2 participants 3 messages Mar 21, 2011 – Mar 28, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 irda: validate peer name and attribute lengths

Length fields provided by a peer for names and attributes may be longer than the destination array sizes. Validate lengths to prevent stack buffer overflows.

---
 net/irda/iriap.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
net/irda/iriap.c +6 -0
index 5b743bd..3647753 100644
@@ -656,10 +656,16 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
 	n = 1;
 
 	name_len = fp[n++];
+
+	IRDA_ASSERT(name_len < IAS_MAX_CLASSNAME + 1, return;);
+
 	memcpy(name, fp+n, name_len); n+=name_len;
 	name[name_len] = '\0';
 
 	attr_len = fp[n++];
+
+	IRDA_ASSERT(attr_len < IAS_MAX_ATTRIBNAME + 1, return;);
+
 	memcpy(attr, fp+n, attr_len); n+=attr_len;
 	attr[attr_len] = '\0';
 
#1 lore raw
Quoted 4 lines · Dan Rosenberg

Length fields provided by a peer for names and attributes may be longer than the destination array sizes. Validate lengths to prevent stack buffer overflows.

While this is the most serious bug I see, this function also seems to lack any validation against skb->len. If someone wants to take care of this, by all means...if not, I'll post a follow-up patch in the next day or so.

-Dan

Quoted 28 lines
---
 net/irda/iriap.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
net/irda/iriap.c +6 -0
index 5b743bd..3647753 100644
@@ -656,10 +656,16 @@ static void iriap_getvaluebyclass_indication(struct iriap_cb *self,
 	n = 1;
 
 	name_len = fp[n++];
+
+	IRDA_ASSERT(name_len < IAS_MAX_CLASSNAME + 1, return;);
+
 	memcpy(name, fp+n, name_len); n+=name_len;
 	name[name_len] = '\0';
 
 	attr_len = fp[n++];
+
+	IRDA_ASSERT(attr_len < IAS_MAX_ATTRIBNAME + 1, return;);
+
 	memcpy(attr, fp+n, attr_len); n+=attr_len;
 	attr[attr_len] = '\0';