Skip to contentSkip to conversation

net: Make skb_seq_read unmap the last fragment

PATCH In review Olaf Kirch 2 participants 2 messages Jun 19, 2007 – Jun 24, 2007

Subsystems (2)
lore
Share & tools
lore

Olaf Kirch

author
#0 lore raw

PATCH 1/1 net: Make skb_seq_read unmap the last fragment

From: Olaf Kirch <[email protected]>

Make skb_seq_read unmap the last fragment

Having walked through the entire skbuff, skb_seq_read would leave the last fragment mapped. As a consequence, the unwary caller would leak kmaps, and proceed with preempt_count off by one. The only (kind of non-intuitive) workaround is to use skb_seq_read_abort.

This patch makes sure skb_seq_read always unmaps frag_data after having cycled through the skb's paged part.

Signed-off-by [email protected]
---
 net/core/skbuff.c |    5 +++++
 1 file changed, 5 insertions(+)
net/core/skbuff.c +5 -0
Index: build-2.6/net/core/skbuff.c
===================================================================
@@ -1706,6 +1706,11 @@ next_skb:
 		st->stepped_offset += frag->size;
 	}
 
+	if (st->frag_data) {
+		kunmap_skb_frag(st->frag_data);
+		st->frag_data = NULL;
+	}
+
 	if (st->cur_skb->next) {
 		st->cur_skb = st->cur_skb->next;
 		st->frag_idx = 0;
Signature · 2 lines
Olaf Kirch  |  --- o --- Nous sommes du soleil we love when we play
[email protected] |    / | \   sol.dhoop.naytheet.ah kin.ir.samse.qurax
maintainer
#1 lore raw

From: Olaf Kirch <[email protected]>
Date: Tue, 19 Jun 2007 09:56:24 +0200

Quoted 9 lines

From: Olaf Kirch <[email protected]>

Make skb_seq_read unmap the last fragment

Having walked through the entire skbuff, skb_seq_read would leave the last fragment mapped. As a consequence, the unwary caller would leak kmaps, and proceed with preempt_count off by one. The only (kind of non-intuitive) workaround is to use skb_seq_read_abort.

Quoted 4 lines

This patch makes sure skb_seq_read always unmaps frag_data after having cycled through the skb's paged part.

Signed-off-by [email protected]

Thanks for finding and fixing this bug.

Patch applied, thanks again Olaf.