Commit 5b5a60da authored by Olaf Kirch's avatar Olaf Kirch Committed by David S. Miller

[NET]: 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: default avatarOlaf Kirch <olaf.kirch@oracle.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 515e06c4
...@@ -1706,6 +1706,11 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data, ...@@ -1706,6 +1706,11 @@ unsigned int skb_seq_read(unsigned int consumed, const u8 **data,
st->stepped_offset += frag->size; st->stepped_offset += frag->size;
} }
if (st->frag_data) {
kunmap_skb_frag(st->frag_data);
st->frag_data = NULL;
}
if (st->cur_skb->next) { if (st->cur_skb->next) {
st->cur_skb = st->cur_skb->next; st->cur_skb = st->cur_skb->next;
st->frag_idx = 0; st->frag_idx = 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment