[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20120421.152345.290988116097275353.davem@davemloft.net>
Date: Sat, 21 Apr 2012 15:23:45 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: tom.leiming@...il.com
Cc: huajun.li.lee@...il.com, oneukum@...e.de,
stern@...land.harvard.edu, davej@...hat.com,
netdev@...r.kernel.org, linux-usb@...r.kernel.org,
kernel-team@...oraproject.org
Subject: Re: use-after-free in usbnet
From: Ming Lei <tom.leiming@...il.com>
Date: Sat, 21 Apr 2012 09:49:51 +0800
> I see the problem, so looks skb_queue_walk_safe is not safe.
> I don' know why the 2nd ' tmp = skb->next' in skb_queue_walk_safe
> is needed and it may become unsafe if skb is freed during current loop.
I can't see what the problem is, skb_queue_walk_safe() is perfect
and does exactly what it advertises to do.
If 'skb' is unlinked inside of an skb_queue_walk_safe() loop, that's
fine, because we won't touch 'skb' in the loop iteration tail code.
Instead, before the loop contents, we pre-fetch skb->next into 'tmp'
and then at the end we move 'skb' forward by simply assigning 'tmp'.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists