All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: Fix skb_network_offset in neigh_resolve_output and neigh_connected_output
@ 2016-06-16  6:50 Abdelrhman Ahmed
  0 siblings, 0 replies; only message in thread
From: Abdelrhman Ahmed @ 2016-06-16  6:50 UTC (permalink / raw)
  To: netdev

Commit e1f165032c8bade3a6bdf546f8faf61fda4dd01c ("net: Fix 
skb_under_panic oops in neigh_resolve_output") resets the skb to 
network_header, but this will discard header or data which is inserted 
by netfilter hooks (e.g. POSTROUTING) between network layer and hardware 
header only for the first packet(s) before using cached hardware header 
and this will lead to inconsistent behavior for outgoing packets.
The fix is to reset with reference to skb's data pointer before loop 
instead of network header.

Signed-off-by: Abdelrhman Ahmed <ab@abahmed.com>
--- net/core/neighbour.c.orig    2016-06-16 05:52:26.521301488 +0200
+++ net/core/neighbour.c    2016-06-16 08:09:54.577222828 +0200
@@ -1293,15 +1293,19 @@ int neigh_resolve_output(struct neighbou
      int rc = 0;

      if (!neigh_event_send(neigh, skb)) {
-        int err;
+        int err, offset;
          struct net_device *dev = neigh->dev;
+        unsigned char *data;
          unsigned int seq;

          if (dev->header_ops->cache && !neigh->hh.hh_len)
              neigh_hh_init(neigh);

+        data = skb->data;
+
          do {
-            __skb_pull(skb, skb_network_offset(skb));
+            offset = data - skb->data;
+            __skb_pull(skb, offset);
              seq = read_seqbegin(&neigh->ha_lock);
              err = dev_hard_header(skb, dev, ntohs(skb->protocol),
                            neigh->ha, NULL, skb->len);
@@ -1326,11 +1330,15 @@ EXPORT_SYMBOL(neigh_resolve_output);
  int neigh_connected_output(struct neighbour *neigh, struct sk_buff *skb)
  {
      struct net_device *dev = neigh->dev;
+    unsigned char *data;
      unsigned int seq;
-    int err;
+    int err, offset;
+
+    data = skb->data;

      do {
-        __skb_pull(skb, skb_network_offset(skb));
+        offset = data - skb->data;
+        __skb_pull(skb, offset);
          seq = read_seqbegin(&neigh->ha_lock);
          err = dev_hard_header(skb, dev, ntohs(skb->protocol),
                        neigh->ha, NULL, skb->len);

-- 
Regards,
Abdelrhman

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-16  6:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-16  6:50 [PATCH] net: Fix skb_network_offset in neigh_resolve_output and neigh_connected_output Abdelrhman Ahmed

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.