[CVE-2014-0131 2/3] skbuff: add an api to orphan frags
Luis Henriques
luis.henriques at canonical.com
Fri Jun 13 11:12:27 UTC 2014
From: "Michael S. Tsirkin" <mst at redhat.com>
Many places do
if ((skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY))
skb_copy_ubufs(skb, gfp_mask);
to copy and invoke frag destructors if necessary.
Add an inline helper for this.
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
Signed-off-by: David S. Miller <davem at davemloft.net>
(cherry picked from commit a353e0ce0fd42d8859260666d1e9b10f2abd4698)
CVE-2014-0131
BugLink: http://bugs.launchpad.net/bugs/1298119
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
---
include/linux/skbuff.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0f7fcc41d896..0233b69f309a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1682,6 +1682,22 @@ static inline void skb_orphan(struct sk_buff *skb)
}
/**
+ * skb_orphan_frags - orphan the frags contained in a buffer
+ * @skb: buffer to orphan frags from
+ * @gfp_mask: allocation mask for replacement pages
+ *
+ * For each frag in the SKB which needs a destructor (i.e. has an
+ * owner) create a copy of that frag and release the original
+ * page by calling the destructor.
+ */
+static inline int skb_orphan_frags(struct sk_buff *skb, gfp_t gfp_mask)
+{
+ if (likely(!(skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY)))
+ return 0;
+ return skb_copy_ubufs(skb, gfp_mask);
+}
+
+/**
* __skb_queue_purge - empty a list
* @list: list to empty
*
--
1.9.1
More information about the kernel-team
mailing list