]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.19-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Nov 2020 09:33:27 +0000 (10:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Nov 2020 09:33:27 +0000 (10:33 +0100)
added patches:
ipv6-set-sit-tunnel-hard_header_len-to-zero.patch
net-af_iucv-fix-null-pointer-dereference-on-shutdown.patch
net-update-window_clamp-if-sock_rcvbuf-is-set.patch
net-x25-fix-null-ptr-deref-in-x25_connect.patch
r8169-fix-potential-skb-double-free-in-an-error-path.patch
tipc-fix-memory-leak-in-tipc_topsrv_start.patch
vrf-fix-fast-path-output-packet-handling-with-async-netfilter-rules.patch

queue-4.19/ipv6-set-sit-tunnel-hard_header_len-to-zero.patch [new file with mode: 0644]
queue-4.19/net-af_iucv-fix-null-pointer-dereference-on-shutdown.patch [new file with mode: 0644]
queue-4.19/net-update-window_clamp-if-sock_rcvbuf-is-set.patch [new file with mode: 0644]
queue-4.19/net-x25-fix-null-ptr-deref-in-x25_connect.patch [new file with mode: 0644]
queue-4.19/r8169-fix-potential-skb-double-free-in-an-error-path.patch [new file with mode: 0644]
queue-4.19/series
queue-4.19/tipc-fix-memory-leak-in-tipc_topsrv_start.patch [new file with mode: 0644]
queue-4.19/vrf-fix-fast-path-output-packet-handling-with-async-netfilter-rules.patch [new file with mode: 0644]

diff --git a/queue-4.19/ipv6-set-sit-tunnel-hard_header_len-to-zero.patch b/queue-4.19/ipv6-set-sit-tunnel-hard_header_len-to-zero.patch
new file mode 100644 (file)
index 0000000..511681f
--- /dev/null
@@ -0,0 +1,52 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Oliver Herms <oliver.peter.herms@gmail.com>
+Date: Tue, 3 Nov 2020 11:41:33 +0100
+Subject: IPv6: Set SIT tunnel hard_header_len to zero
+
+From: Oliver Herms <oliver.peter.herms@gmail.com>
+
+[ Upstream commit 8ef9ba4d666614497a057d09b0a6eafc1e34eadf ]
+
+Due to the legacy usage of hard_header_len for SIT tunnels while
+already using infrastructure from net/ipv4/ip_tunnel.c the
+calculation of the path MTU in tnl_update_pmtu is incorrect.
+This leads to unnecessary creation of MTU exceptions for any
+flow going over a SIT tunnel.
+
+As SIT tunnels do not have a header themsevles other than their
+transport (L3, L2) headers we're leaving hard_header_len set to zero
+as tnl_update_pmtu is already taking care of the transport headers
+sizes.
+
+This will also help avoiding unnecessary IPv6 GC runs and spinlock
+contention seen when using SIT tunnels and for more than
+net.ipv6.route.gc_thresh flows.
+
+Fixes: c54419321455 ("GRE: Refactor GRE tunneling code.")
+Signed-off-by: Oliver Herms <oliver.peter.herms@gmail.com>
+Acked-by: Willem de Bruijn <willemb@google.com>
+Link: https://lore.kernel.org/r/20201103104133.GA1573211@tws
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/ipv6/sit.c |    2 --
+ 1 file changed, 2 deletions(-)
+
+--- a/net/ipv6/sit.c
++++ b/net/ipv6/sit.c
+@@ -1087,7 +1087,6 @@ static void ipip6_tunnel_bind_dev(struct
+       if (tdev && !netif_is_l3_master(tdev)) {
+               int t_hlen = tunnel->hlen + sizeof(struct iphdr);
+-              dev->hard_header_len = tdev->hard_header_len + sizeof(struct iphdr);
+               dev->mtu = tdev->mtu - t_hlen;
+               if (dev->mtu < IPV6_MIN_MTU)
+                       dev->mtu = IPV6_MIN_MTU;
+@@ -1377,7 +1376,6 @@ static void ipip6_tunnel_setup(struct ne
+       dev->priv_destructor    = ipip6_dev_free;
+       dev->type               = ARPHRD_SIT;
+-      dev->hard_header_len    = LL_MAX_HEADER + t_hlen;
+       dev->mtu                = ETH_DATA_LEN - t_hlen;
+       dev->min_mtu            = IPV6_MIN_MTU;
+       dev->max_mtu            = IP6_MAX_MTU - t_hlen;
diff --git a/queue-4.19/net-af_iucv-fix-null-pointer-dereference-on-shutdown.patch b/queue-4.19/net-af_iucv-fix-null-pointer-dereference-on-shutdown.patch
new file mode 100644 (file)
index 0000000..d7aaf39
--- /dev/null
@@ -0,0 +1,61 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Ursula Braun <ubraun@linux.ibm.com>
+Date: Mon, 9 Nov 2020 08:57:05 +0100
+Subject: net/af_iucv: fix null pointer dereference on shutdown
+
+From: Ursula Braun <ubraun@linux.ibm.com>
+
+[ Upstream commit 4031eeafa71eaf22ae40a15606a134ae86345daf ]
+
+syzbot reported the following KASAN finding:
+
+BUG: KASAN: nullptr-dereference in iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
+Read of size 2 at addr 000000000000021e by task syz-executor907/519
+
+CPU: 0 PID: 519 Comm: syz-executor907 Not tainted 5.9.0-syzkaller-07043-gbcf9877ad213 #0
+Hardware name: IBM 3906 M04 701 (KVM/Linux)
+Call Trace:
+ [<00000000c576af60>] unwind_start arch/s390/include/asm/unwind.h:65 [inline]
+ [<00000000c576af60>] show_stack+0x180/0x228 arch/s390/kernel/dumpstack.c:135
+ [<00000000c9dcd1f8>] __dump_stack lib/dump_stack.c:77 [inline]
+ [<00000000c9dcd1f8>] dump_stack+0x268/0x2f0 lib/dump_stack.c:118
+ [<00000000c5fed016>] print_address_description.constprop.0+0x5e/0x218 mm/kasan/report.c:383
+ [<00000000c5fec82a>] __kasan_report mm/kasan/report.c:517 [inline]
+ [<00000000c5fec82a>] kasan_report+0x11a/0x168 mm/kasan/report.c:534
+ [<00000000c98b5b60>] iucv_send_ctrl+0x390/0x3f0 net/iucv/af_iucv.c:385
+ [<00000000c98b6262>] iucv_sock_shutdown+0x44a/0x4c0 net/iucv/af_iucv.c:1457
+ [<00000000c89d3a54>] __sys_shutdown+0x12c/0x1c8 net/socket.c:2204
+ [<00000000c89d3b70>] __do_sys_shutdown net/socket.c:2212 [inline]
+ [<00000000c89d3b70>] __s390x_sys_shutdown+0x38/0x48 net/socket.c:2210
+ [<00000000c9e36eac>] system_call+0xe0/0x28c arch/s390/kernel/entry.S:415
+
+There is nothing to shutdown if a connection has never been established.
+Besides that iucv->hs_dev is not yet initialized if a socket is in
+IUCV_OPEN state and iucv->path is not yet initialized if socket is in
+IUCV_BOUND state.
+So, just skip the shutdown calls for a socket in these states.
+
+Fixes: eac3731bd04c ("[S390]: Add AF_IUCV socket support")
+Fixes: 82492a355fac ("af_iucv: add shutdown for HS transport")
+Reviewed-by: Vasily Gorbik <gor@linux.ibm.com>
+Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
+[jwi: correct one Fixes tag]
+Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/iucv/af_iucv.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/net/iucv/af_iucv.c
++++ b/net/iucv/af_iucv.c
+@@ -1571,7 +1571,8 @@ static int iucv_sock_shutdown(struct soc
+               break;
+       }
+-      if (how == SEND_SHUTDOWN || how == SHUTDOWN_MASK) {
++      if ((how == SEND_SHUTDOWN || how == SHUTDOWN_MASK) &&
++          sk->sk_state == IUCV_CONNECTED) {
+               if (iucv->transport == AF_IUCV_TRANS_IUCV) {
+                       txmsg.class = 0;
+                       txmsg.tag = 0;
diff --git a/queue-4.19/net-update-window_clamp-if-sock_rcvbuf-is-set.patch b/queue-4.19/net-update-window_clamp-if-sock_rcvbuf-is-set.patch
new file mode 100644 (file)
index 0000000..86ed110
--- /dev/null
@@ -0,0 +1,82 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Mao Wenan <wenan.mao@linux.alibaba.com>
+Date: Tue, 10 Nov 2020 08:16:31 +0800
+Subject: net: Update window_clamp if SOCK_RCVBUF is set
+
+From: Mao Wenan <wenan.mao@linux.alibaba.com>
+
+[ Upstream commit 909172a149749242990a6e64cb55d55460d4e417 ]
+
+When net.ipv4.tcp_syncookies=1 and syn flood is happened,
+cookie_v4_check or cookie_v6_check tries to redo what
+tcp_v4_send_synack or tcp_v6_send_synack did,
+rsk_window_clamp will be changed if SOCK_RCVBUF is set,
+which will make rcv_wscale is different, the client
+still operates with initial window scale and can overshot
+granted window, the client use the initial scale but local
+server use new scale to advertise window value, and session
+work abnormally.
+
+Fixes: e88c64f0a425 ("tcp: allow effective reduction of TCP's rcv-buffer via setsockopt")
+Signed-off-by: Mao Wenan <wenan.mao@linux.alibaba.com>
+Signed-off-by: Eric Dumazet <edumazet@google.com>
+Link: https://lore.kernel.org/r/1604967391-123737-1-git-send-email-wenan.mao@linux.alibaba.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/ipv4/syncookies.c |    9 +++++++--
+ net/ipv6/syncookies.c |   10 ++++++++--
+ 2 files changed, 15 insertions(+), 4 deletions(-)
+
+--- a/net/ipv4/syncookies.c
++++ b/net/ipv4/syncookies.c
+@@ -296,7 +296,7 @@ struct sock *cookie_v4_check(struct sock
+       __u32 cookie = ntohl(th->ack_seq) - 1;
+       struct sock *ret = sk;
+       struct request_sock *req;
+-      int mss;
++      int full_space, mss;
+       struct rtable *rt;
+       __u8 rcv_wscale;
+       struct flowi4 fl4;
+@@ -391,8 +391,13 @@ struct sock *cookie_v4_check(struct sock
+       /* Try to redo what tcp_v4_send_synack did. */
+       req->rsk_window_clamp = tp->window_clamp ? :dst_metric(&rt->dst, RTAX_WINDOW);
++      /* limit the window selection if the user enforce a smaller rx buffer */
++      full_space = tcp_full_space(sk);
++      if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
++          (req->rsk_window_clamp > full_space || req->rsk_window_clamp == 0))
++              req->rsk_window_clamp = full_space;
+-      tcp_select_initial_window(sk, tcp_full_space(sk), req->mss,
++      tcp_select_initial_window(sk, full_space, req->mss,
+                                 &req->rsk_rcv_wnd, &req->rsk_window_clamp,
+                                 ireq->wscale_ok, &rcv_wscale,
+                                 dst_metric(&rt->dst, RTAX_INITRWND));
+--- a/net/ipv6/syncookies.c
++++ b/net/ipv6/syncookies.c
+@@ -141,7 +141,7 @@ struct sock *cookie_v6_check(struct sock
+       __u32 cookie = ntohl(th->ack_seq) - 1;
+       struct sock *ret = sk;
+       struct request_sock *req;
+-      int mss;
++      int full_space, mss;
+       struct dst_entry *dst;
+       __u8 rcv_wscale;
+       u32 tsoff = 0;
+@@ -246,7 +246,13 @@ struct sock *cookie_v6_check(struct sock
+       }
+       req->rsk_window_clamp = tp->window_clamp ? :dst_metric(dst, RTAX_WINDOW);
+-      tcp_select_initial_window(sk, tcp_full_space(sk), req->mss,
++      /* limit the window selection if the user enforce a smaller rx buffer */
++      full_space = tcp_full_space(sk);
++      if (sk->sk_userlocks & SOCK_RCVBUF_LOCK &&
++          (req->rsk_window_clamp > full_space || req->rsk_window_clamp == 0))
++              req->rsk_window_clamp = full_space;
++
++      tcp_select_initial_window(sk, full_space, req->mss,
+                                 &req->rsk_rcv_wnd, &req->rsk_window_clamp,
+                                 ireq->wscale_ok, &rcv_wscale,
+                                 dst_metric(dst, RTAX_INITRWND));
diff --git a/queue-4.19/net-x25-fix-null-ptr-deref-in-x25_connect.patch b/queue-4.19/net-x25-fix-null-ptr-deref-in-x25_connect.patch
new file mode 100644 (file)
index 0000000..cc113ff
--- /dev/null
@@ -0,0 +1,39 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Martin Schiller <ms@dev.tdt.de>
+Date: Mon, 9 Nov 2020 07:54:49 +0100
+Subject: net/x25: Fix null-ptr-deref in x25_connect
+
+From: Martin Schiller <ms@dev.tdt.de>
+
+[ Upstream commit 361182308766a265b6c521879b34302617a8c209 ]
+
+This fixes a regression for blocking connects introduced by commit
+4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect").
+
+The x25->neighbour is already set to "NULL" by x25_disconnect() now,
+while a blocking connect is waiting in
+x25_wait_for_connection_establishment(). Therefore x25->neighbour must
+not be accessed here again and x25->state is also already set to
+X25_STATE_0 by x25_disconnect().
+
+Fixes: 4becb7ee5b3d ("net/x25: Fix x25_neigh refcnt leak when x25 disconnect")
+Signed-off-by: Martin Schiller <ms@dev.tdt.de>
+Reviewed-by: Xie He <xie.he.0141@gmail.com>
+Link: https://lore.kernel.org/r/20201109065449.9014-1-ms@dev.tdt.de
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/x25/af_x25.c |    2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/net/x25/af_x25.c
++++ b/net/x25/af_x25.c
+@@ -824,7 +824,7 @@ static int x25_connect(struct socket *so
+       sock->state = SS_CONNECTED;
+       rc = 0;
+ out_put_neigh:
+-      if (rc) {
++      if (rc && x25->neighbour) {
+               read_lock_bh(&x25_list_lock);
+               x25_neigh_put(x25->neighbour);
+               x25->neighbour = NULL;
diff --git a/queue-4.19/r8169-fix-potential-skb-double-free-in-an-error-path.patch b/queue-4.19/r8169-fix-potential-skb-double-free-in-an-error-path.patch
new file mode 100644 (file)
index 0000000..55e93d4
--- /dev/null
@@ -0,0 +1,36 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Heiner Kallweit <hkallweit1@gmail.com>
+Date: Thu, 5 Nov 2020 15:28:42 +0100
+Subject: r8169: fix potential skb double free in an error path
+
+From: Heiner Kallweit <hkallweit1@gmail.com>
+
+[ Upstream commit cc6528bc9a0c901c83b8220a2e2617f3354d6dd9 ]
+
+The caller of rtl8169_tso_csum_v2() frees the skb if false is returned.
+eth_skb_pad() internally frees the skb on error what would result in a
+double free. Therefore use __skb_put_padto() directly and instruct it
+to not free the skb on error.
+
+Fixes: b423e9ae49d7 ("r8169: fix offloaded tx checksum for small packets.")
+Reported-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
+Link: https://lore.kernel.org/r/f7e68191-acff-9ded-4263-c016428a8762@gmail.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/ethernet/realtek/r8169.c |    3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/ethernet/realtek/r8169.c
++++ b/drivers/net/ethernet/realtek/r8169.c
+@@ -6274,7 +6274,8 @@ static bool rtl8169_tso_csum_v2(struct r
+               opts[1] |= transport_offset << TCPHO_SHIFT;
+       } else {
+               if (unlikely(rtl_test_hw_pad_bug(tp, skb)))
+-                      return !eth_skb_pad(skb);
++                      /* eth_skb_pad would free the skb on error */
++                      return !__skb_put_padto(skb, ETH_ZLEN, false);
+       }
+       return true;
index 990eec922371322bc8dd20993339a614c2fa6346..3ebc6358db4e18cbe695dde6ada21656dc67a0db 100644 (file)
@@ -84,3 +84,10 @@ pinctrl-amd-use-higher-precision-for-512-rtcclk.patch
 pinctrl-amd-fix-incorrect-way-to-disable-debounce-filter.patch
 erofs-derive-atime-instead-of-leaving-it-empty.patch
 swiotlb-fix-x86-don-t-panic-if-can-not-alloc-buffer-for-swiotlb.patch
+ipv6-set-sit-tunnel-hard_header_len-to-zero.patch
+net-af_iucv-fix-null-pointer-dereference-on-shutdown.patch
+net-update-window_clamp-if-sock_rcvbuf-is-set.patch
+net-x25-fix-null-ptr-deref-in-x25_connect.patch
+tipc-fix-memory-leak-in-tipc_topsrv_start.patch
+vrf-fix-fast-path-output-packet-handling-with-async-netfilter-rules.patch
+r8169-fix-potential-skb-double-free-in-an-error-path.patch
diff --git a/queue-4.19/tipc-fix-memory-leak-in-tipc_topsrv_start.patch b/queue-4.19/tipc-fix-memory-leak-in-tipc_topsrv_start.patch
new file mode 100644 (file)
index 0000000..bb8485d
--- /dev/null
@@ -0,0 +1,64 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Wang Hai <wanghai38@huawei.com>
+Date: Mon, 9 Nov 2020 22:09:13 +0800
+Subject: tipc: fix memory leak in tipc_topsrv_start()
+
+From: Wang Hai <wanghai38@huawei.com>
+
+[ Upstream commit fa6882c63621821f73cc806f291208e1c6ea6187 ]
+
+kmemleak report a memory leak as follows:
+
+unreferenced object 0xffff88810a596800 (size 512):
+  comm "ip", pid 21558, jiffies 4297568990 (age 112.120s)
+  hex dump (first 32 bytes):
+    00 00 00 00 ad 4e ad de ff ff ff ff 00 00 00 00  .....N..........
+    ff ff ff ff ff ff ff ff 00 83 60 b0 ff ff ff ff  ..........`.....
+  backtrace:
+    [<0000000022bbe21f>] tipc_topsrv_init_net+0x1f3/0xa70
+    [<00000000fe15ddf7>] ops_init+0xa8/0x3c0
+    [<00000000138af6f2>] setup_net+0x2de/0x7e0
+    [<000000008c6807a3>] copy_net_ns+0x27d/0x530
+    [<000000006b21adbd>] create_new_namespaces+0x382/0xa30
+    [<00000000bb169746>] unshare_nsproxy_namespaces+0xa1/0x1d0
+    [<00000000fe2e42bc>] ksys_unshare+0x39c/0x780
+    [<0000000009ba3b19>] __x64_sys_unshare+0x2d/0x40
+    [<00000000614ad866>] do_syscall_64+0x56/0xa0
+    [<00000000a1b5ca3c>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
+
+'srv' is malloced in tipc_topsrv_start() but not free before
+leaving from the error handling cases. We need to free it.
+
+Fixes: 5c45ab24ac77 ("tipc: make struct tipc_server private for server.c")
+Reported-by: Hulk Robot <hulkci@huawei.com>
+Signed-off-by: Wang Hai <wanghai38@huawei.com>
+Link: https://lore.kernel.org/r/20201109140913.47370-1-wanghai38@huawei.com
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ net/tipc/topsrv.c |   10 ++++++++--
+ 1 file changed, 8 insertions(+), 2 deletions(-)
+
+--- a/net/tipc/topsrv.c
++++ b/net/tipc/topsrv.c
+@@ -671,12 +671,18 @@ static int tipc_topsrv_start(struct net
+       ret = tipc_topsrv_work_start(srv);
+       if (ret < 0)
+-              return ret;
++              goto err_start;
+       ret = tipc_topsrv_create_listener(srv);
+       if (ret < 0)
+-              tipc_topsrv_work_stop(srv);
++              goto err_create;
++      return 0;
++
++err_create:
++      tipc_topsrv_work_stop(srv);
++err_start:
++      kfree(srv);
+       return ret;
+ }
diff --git a/queue-4.19/vrf-fix-fast-path-output-packet-handling-with-async-netfilter-rules.patch b/queue-4.19/vrf-fix-fast-path-output-packet-handling-with-async-netfilter-rules.patch
new file mode 100644 (file)
index 0000000..0ee5686
--- /dev/null
@@ -0,0 +1,192 @@
+From foo@baz Tue Nov 17 10:23:12 AM CET 2020
+From: Martin Willi <martin@strongswan.org>
+Date: Fri, 6 Nov 2020 08:30:30 +0100
+Subject: vrf: Fix fast path output packet handling with async Netfilter rules
+
+From: Martin Willi <martin@strongswan.org>
+
+[ Upstream commit 9e2b7fa2df4365e99934901da4fb4af52d81e820 ]
+
+VRF devices use an optimized direct path on output if a default qdisc
+is involved, calling Netfilter hooks directly. This path, however, does
+not consider Netfilter rules completing asynchronously, such as with
+NFQUEUE. The Netfilter okfn() is called for asynchronously accepted
+packets, but the VRF never passes that packet down the stack to send
+it out over the slave device. Using the slower redirect path for this
+seems not feasible, as we do not know beforehand if a Netfilter hook
+has asynchronously completing rules.
+
+Fix the use of asynchronously completing Netfilter rules in OUTPUT and
+POSTROUTING by using a special completion function that additionally
+calls dst_output() to pass the packet down the stack. Also, slightly
+adjust the use of nf_reset_ct() so that is called in the asynchronous
+case, too.
+
+Fixes: dcdd43c41e60 ("net: vrf: performance improvements for IPv4")
+Fixes: a9ec54d1b0cd ("net: vrf: performance improvements for IPv6")
+Signed-off-by: Martin Willi <martin@strongswan.org>
+Link: https://lore.kernel.org/r/20201106073030.3974927-1-martin@strongswan.org
+Signed-off-by: Jakub Kicinski <kuba@kernel.org>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ drivers/net/vrf.c |   92 ++++++++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 69 insertions(+), 23 deletions(-)
+
+--- a/drivers/net/vrf.c
++++ b/drivers/net/vrf.c
+@@ -336,8 +336,7 @@ static netdev_tx_t vrf_xmit(struct sk_bu
+       return ret;
+ }
+-static int vrf_finish_direct(struct net *net, struct sock *sk,
+-                           struct sk_buff *skb)
++static void vrf_finish_direct(struct sk_buff *skb)
+ {
+       struct net_device *vrf_dev = skb->dev;
+@@ -356,7 +355,8 @@ static int vrf_finish_direct(struct net
+               skb_pull(skb, ETH_HLEN);
+       }
+-      return 1;
++      /* reset skb device */
++      nf_reset(skb);
+ }
+ #if IS_ENABLED(CONFIG_IPV6)
+@@ -435,15 +435,41 @@ static struct sk_buff *vrf_ip6_out_redir
+       return skb;
+ }
++static int vrf_output6_direct_finish(struct net *net, struct sock *sk,
++                                   struct sk_buff *skb)
++{
++      vrf_finish_direct(skb);
++
++      return vrf_ip6_local_out(net, sk, skb);
++}
++
+ static int vrf_output6_direct(struct net *net, struct sock *sk,
+                             struct sk_buff *skb)
+ {
++      int err = 1;
++
+       skb->protocol = htons(ETH_P_IPV6);
+-      return NF_HOOK_COND(NFPROTO_IPV6, NF_INET_POST_ROUTING,
+-                          net, sk, skb, NULL, skb->dev,
+-                          vrf_finish_direct,
+-                          !(IPCB(skb)->flags & IPSKB_REROUTED));
++      if (!(IPCB(skb)->flags & IPSKB_REROUTED))
++              err = nf_hook(NFPROTO_IPV6, NF_INET_POST_ROUTING, net, sk, skb,
++                            NULL, skb->dev, vrf_output6_direct_finish);
++
++      if (likely(err == 1))
++              vrf_finish_direct(skb);
++
++      return err;
++}
++
++static int vrf_ip6_out_direct_finish(struct net *net, struct sock *sk,
++                                   struct sk_buff *skb)
++{
++      int err;
++
++      err = vrf_output6_direct(net, sk, skb);
++      if (likely(err == 1))
++              err = vrf_ip6_local_out(net, sk, skb);
++
++      return err;
+ }
+ static struct sk_buff *vrf_ip6_out_direct(struct net_device *vrf_dev,
+@@ -456,18 +482,15 @@ static struct sk_buff *vrf_ip6_out_direc
+       skb->dev = vrf_dev;
+       err = nf_hook(NFPROTO_IPV6, NF_INET_LOCAL_OUT, net, sk,
+-                    skb, NULL, vrf_dev, vrf_output6_direct);
++                    skb, NULL, vrf_dev, vrf_ip6_out_direct_finish);
+       if (likely(err == 1))
+               err = vrf_output6_direct(net, sk, skb);
+-      /* reset skb device */
+       if (likely(err == 1))
+-              nf_reset(skb);
+-      else
+-              skb = NULL;
++              return skb;
+-      return skb;
++      return NULL;
+ }
+ static struct sk_buff *vrf_ip6_out(struct net_device *vrf_dev,
+@@ -649,15 +672,41 @@ static struct sk_buff *vrf_ip_out_redire
+       return skb;
+ }
++static int vrf_output_direct_finish(struct net *net, struct sock *sk,
++                                  struct sk_buff *skb)
++{
++      vrf_finish_direct(skb);
++
++      return vrf_ip_local_out(net, sk, skb);
++}
++
+ static int vrf_output_direct(struct net *net, struct sock *sk,
+                            struct sk_buff *skb)
+ {
++      int err = 1;
++
+       skb->protocol = htons(ETH_P_IP);
+-      return NF_HOOK_COND(NFPROTO_IPV4, NF_INET_POST_ROUTING,
+-                          net, sk, skb, NULL, skb->dev,
+-                          vrf_finish_direct,
+-                          !(IPCB(skb)->flags & IPSKB_REROUTED));
++      if (!(IPCB(skb)->flags & IPSKB_REROUTED))
++              err = nf_hook(NFPROTO_IPV4, NF_INET_POST_ROUTING, net, sk, skb,
++                            NULL, skb->dev, vrf_output_direct_finish);
++
++      if (likely(err == 1))
++              vrf_finish_direct(skb);
++
++      return err;
++}
++
++static int vrf_ip_out_direct_finish(struct net *net, struct sock *sk,
++                                  struct sk_buff *skb)
++{
++      int err;
++
++      err = vrf_output_direct(net, sk, skb);
++      if (likely(err == 1))
++              err = vrf_ip_local_out(net, sk, skb);
++
++      return err;
+ }
+ static struct sk_buff *vrf_ip_out_direct(struct net_device *vrf_dev,
+@@ -670,18 +719,15 @@ static struct sk_buff *vrf_ip_out_direct
+       skb->dev = vrf_dev;
+       err = nf_hook(NFPROTO_IPV4, NF_INET_LOCAL_OUT, net, sk,
+-                    skb, NULL, vrf_dev, vrf_output_direct);
++                    skb, NULL, vrf_dev, vrf_ip_out_direct_finish);
+       if (likely(err == 1))
+               err = vrf_output_direct(net, sk, skb);
+-      /* reset skb device */
+       if (likely(err == 1))
+-              nf_reset(skb);
+-      else
+-              skb = NULL;
++              return skb;
+-      return skb;
++      return NULL;
+ }
+ static struct sk_buff *vrf_ip_out(struct net_device *vrf_dev,