Skip to content

Commit

Permalink
[NET]: Make skb_seq_read unmap the last fragment
Browse files Browse the repository at this point in the history
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: Olaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Olaf Kirch authored and David S. Miller committed Jun 24, 2007
1 parent 515e06c commit 5b5a60d
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions net/core/skbuff.c
Original file line number Diff line number Diff line change
Expand Up @@ -1706,6 +1706,11 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
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;
Expand Down

0 comments on commit 5b5a60d

Please sign in to comment.