* [PATCH] net: Make skb_seq_read unmap the last fragment
@ 2007-06-19 7:56 Olaf Kirch
2007-06-24 6:12 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Olaf Kirch @ 2007-06-19 7:56 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel
From: Olaf Kirch <olaf.kirch@oracle.com>
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: olaf.kirch@oracle.com
---
net/core/skbuff.c | 5 +++++
1 file changed, 5 insertions(+)
Index: build-2.6/net/core/skbuff.c
===================================================================
--- build-2.6.orig/net/core/skbuff.c
+++ 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;
--
Olaf Kirch | --- o --- Nous sommes du soleil we love when we play
okir@lst.de | / | \ sol.dhoop.naytheet.ah kin.ir.samse.qurax
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] net: Make skb_seq_read unmap the last fragment
2007-06-19 7:56 [PATCH] net: Make skb_seq_read unmap the last fragment Olaf Kirch
@ 2007-06-24 6:12 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-06-24 6:12 UTC (permalink / raw)
To: okir; +Cc: netdev, linux-kernel
From: Olaf Kirch <okir@lst.de>
Date: Tue, 19 Jun 2007 09:56:24 +0200
> From: Olaf Kirch <olaf.kirch@oracle.com>
>
> 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: olaf.kirch@oracle.com
Thanks for finding and fixing this bug.
Patch applied, thanks again Olaf.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-06-24 6:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 7:56 [PATCH] net: Make skb_seq_read unmap the last fragment Olaf Kirch
2007-06-24 6:12 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).