Skip to contentSkip to conversation

: Buffer overflow

PATCH Applied Roel Kluin 3 participants 4 messages Jul 29, 2009 – Jul 30, 2009

Subsystems (3)
lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 : Buffer overflow

If arp_format_neigh_entry() can be called with n->dev->addr_len == 0, then a write to hbuffer[-1] occurs.

---
Found with Parfait, http://research.sun.com/projects/parfait/

It's not clear whether this can happen or not.

net/ipv4/arp.c +2 -1
index c29d75d..252336f 100644
@@ -1304,7 +1304,8 @@ static void arp_format_neigh_entry(struct seq_file *seq,
 		hbuffer[k++] = hex_asc_lo(n->ha[j]);
 		hbuffer[k++] = ':';
 	}
-	hbuffer[--k] = 0;
+	if (k != 0)
+		hbuffer[--k] = 0;
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	}
 #endif
#1 lore raw

Roel Kluin wrote, On 07/29/2009 12:52 PM:

Quoted 14 lines

If arp_format_neigh_entry() can be called with n->dev->addr_len == 0, then a write to hbuffer[-1] occurs.

---
Found with Parfait, http://research.sun.com/projects/parfait/

It's not clear whether this can happen or not.

net/ipv4/arp.c +0 -0
index c29d75d..252336f 100644

net/ipv4/arp.c static void arp_format_neigh_entry(struct seq_file *seq, · line 1308

Quoted 6 lines
net/ipv4/arp.c +2 -1
@@ -1304,7 +1304,8 @@ static void arp_format_neigh_entry(struct seq_file *seq,
 		hbuffer[k++] = hex_asc_lo(n->ha[j]);
 		hbuffer[k++] = ':';
 	}
-	hbuffer[--k] = 0;
+	if (k != 0)
+		hbuffer[--k] = 0;

I guess for k == 0 we need hbuffer[0] = 0 too.

Jarek P.

Quoted 8 lines
net/ipv4/arp.c +0 -1
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	}
 #endif
--

To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#2 lore raw

If arp_format_neigh_entry() can be called with n->dev->addr_len == 0, then a write to hbuffer[-1] occurs.

---
Op 30-07-09 00:02, Jarek Poplawski schreef:

Quoted 10 lines

Roel Kluin wrote, On 07/29/2009 12:52 PM:

Review

Quoted 3 lines
(quoted diff) +2 -1
-	hbuffer[--k] = 0;
+	if (k != 0)
+		hbuffer[--k] = 0;

I guess for k == 0 we need hbuffer[0] = 0 too.

Jarek P.

Thanks, updated patch below.

net/ipv4/arp.c +3 -1
index c29d75d..090e999 100644
@@ -1304,7 +1304,9 @@ static void arp_format_neigh_entry(struct seq_file *seq,
 		hbuffer[k++] = hex_asc_lo(n->ha[j]);
 		hbuffer[k++] = ':';
 	}
-	hbuffer[--k] = 0;
+	if (k != 0)
+		--k;
+	hbuffer[k] = 0;
 #if defined(CONFIG_AX25) || defined(CONFIG_AX25_MODULE)
 	}
 #endif