<feed xmlns='http://www.w3.org/2005/Atom'>
<title>user/sven/linux.git/net/openvswitch, branch v4.14.266</title>
<subtitle>Linux Kernel
</subtitle>
<id>https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.14.266</id>
<link rel='self' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/atom?h=v4.14.266'/>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/'/>
<updated>2021-05-22T08:57:21Z</updated>
<entry>
<title>openvswitch: fix stack OOB read while fragmenting IPv4 packets</title>
<updated>2021-05-22T08:57:21Z</updated>
<author>
<name>Davide Caratti</name>
<email>dcaratti@redhat.com</email>
</author>
<published>2021-04-28T13:23:07Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=5a52fa8ad45b5a593ed416adf326538638454ff1'/>
<id>urn:sha1:5a52fa8ad45b5a593ed416adf326538638454ff1</id>
<content type='text'>
commit 7c0ea5930c1c211931819d83cfb157bff1539a4c upstream.

running openvswitch on kernels built with KASAN, it's possible to see the
following splat while testing fragmentation of IPv4 packets:

 BUG: KASAN: stack-out-of-bounds in ip_do_fragment+0x1b03/0x1f60
 Read of size 1 at addr ffff888112fc713c by task handler2/1367

 CPU: 0 PID: 1367 Comm: handler2 Not tainted 5.12.0-rc6+ #418
 Hardware name: Red Hat KVM, BIOS 1.11.1-4.module+el8.1.0+4066+0f1aadab 04/01/2014
 Call Trace:
  dump_stack+0x92/0xc1
  print_address_description.constprop.7+0x1a/0x150
  kasan_report.cold.13+0x7f/0x111
  ip_do_fragment+0x1b03/0x1f60
  ovs_fragment+0x5bf/0x840 [openvswitch]
  do_execute_actions+0x1bd5/0x2400 [openvswitch]
  ovs_execute_actions+0xc8/0x3d0 [openvswitch]
  ovs_packet_cmd_execute+0xa39/0x1150 [openvswitch]
  genl_family_rcv_msg_doit.isra.15+0x227/0x2d0
  genl_rcv_msg+0x287/0x490
  netlink_rcv_skb+0x120/0x380
  genl_rcv+0x24/0x40
  netlink_unicast+0x439/0x630
  netlink_sendmsg+0x719/0xbf0
  sock_sendmsg+0xe2/0x110
  ____sys_sendmsg+0x5ba/0x890
  ___sys_sendmsg+0xe9/0x160
  __sys_sendmsg+0xd3/0x170
  do_syscall_64+0x33/0x40
  entry_SYSCALL_64_after_hwframe+0x44/0xae
 RIP: 0033:0x7f957079db07
 Code: c3 66 90 41 54 41 89 d4 55 48 89 f5 53 89 fb 48 83 ec 10 e8 eb ec ff ff 44 89 e2 48 89 ee 89 df 41 89 c0 b8 2e 00 00 00 0f 05 &lt;48&gt; 3d 00 f0 ff ff 77 35 44 89 c7 48 89 44 24 08 e8 24 ed ff ff 48
 RSP: 002b:00007f956ce35a50 EFLAGS: 00000293 ORIG_RAX: 000000000000002e
 RAX: ffffffffffffffda RBX: 0000000000000019 RCX: 00007f957079db07
 RDX: 0000000000000000 RSI: 00007f956ce35ae0 RDI: 0000000000000019
 RBP: 00007f956ce35ae0 R08: 0000000000000000 R09: 00007f9558006730
 R10: 0000000000000000 R11: 0000000000000293 R12: 0000000000000000
 R13: 00007f956ce37308 R14: 00007f956ce35f80 R15: 00007f956ce35ae0

 The buggy address belongs to the page:
 page:00000000af2a1d93 refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x112fc7
 flags: 0x17ffffc0000000()
 raw: 0017ffffc0000000 0000000000000000 dead000000000122 0000000000000000
 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000
 page dumped because: kasan: bad access detected

 addr ffff888112fc713c is located in stack of task handler2/1367 at offset 180 in frame:
  ovs_fragment+0x0/0x840 [openvswitch]

 this frame has 2 objects:
  [32, 144) 'ovs_dst'
  [192, 424) 'ovs_rt'

 Memory state around the buggy address:
  ffff888112fc7000: f3 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  ffff888112fc7080: 00 f1 f1 f1 f1 00 00 00 00 00 00 00 00 00 00 00
 &gt;ffff888112fc7100: 00 00 00 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00
                                         ^
  ffff888112fc7180: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  ffff888112fc7200: 00 00 00 00 00 00 f2 f2 f2 00 00 00 00 00 00 00

for IPv4 packets, ovs_fragment() uses a temporary struct dst_entry. Then,
in the following call graph:

  ip_do_fragment()
    ip_skb_dst_mtu()
      ip_dst_mtu_maybe_forward()
        ip_mtu_locked()

the pointer to struct dst_entry is used as pointer to struct rtable: this
turns the access to struct members like rt_mtu_locked into an OOB read in
the stack. Fix this changing the temporary variable used for IPv4 packets
in ovs_fragment(), similarly to what is done for IPv6 few lines below.

Fixes: d52e5a7e7ca4 ("ipv4: lock mtu in fnhe when received PMTU &lt; net.ipv4.route.min_pmt")
Cc: &lt;stable@vger.kernel.org&gt;
Acked-by: Eelco Chaudron &lt;echaudro@redhat.com&gt;
Signed-off-by: Davide Caratti &lt;dcaratti@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: handle DNAT tuple collision</title>
<updated>2020-10-14T07:51:12Z</updated>
<author>
<name>Dumitru Ceara</name>
<email>dceara@redhat.com</email>
</author>
<published>2020-10-07T15:48:03Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=4928ce41c884c36110d9e35317936bca6b2c1393'/>
<id>urn:sha1:4928ce41c884c36110d9e35317936bca6b2c1393</id>
<content type='text'>
commit 8aa7b526dc0b5dbf40c1b834d76a667ad672a410 upstream.

With multiple DNAT rules it's possible that after destination
translation the resulting tuples collide.

For example, two openvswitch flows:
nw_dst=10.0.0.10,tp_dst=10, actions=ct(commit,table=2,nat(dst=20.0.0.1:20))
nw_dst=10.0.0.20,tp_dst=10, actions=ct(commit,table=2,nat(dst=20.0.0.1:20))

Assuming two TCP clients initiating the following connections:
10.0.0.10:5000-&gt;10.0.0.10:10
10.0.0.10:5000-&gt;10.0.0.20:10

Both tuples would translate to 10.0.0.10:5000-&gt;20.0.0.1:20 causing
nf_conntrack_confirm() to fail because of tuple collision.

Netfilter handles this case by allocating a null binding for SNAT at
egress by default.  Perform the same operation in openvswitch for DNAT
if no explicit SNAT is requested by the user and allocate a null binding
for SNAT for packets in the "original" direction.

Reported-at: https://bugzilla.redhat.com/1877128
Suggested-by: Florian Westphal &lt;fw@strlen.de&gt;
Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
Signed-off-by: Dumitru Ceara &lt;dceara@redhat.com&gt;
Signed-off-by: Jakub Kicinski &lt;kuba@kernel.org&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;

</content>
</entry>
<entry>
<title>openvswitch: Prevent kernel-infoleak in ovs_ct_put_key()</title>
<updated>2020-08-21T07:48:01Z</updated>
<author>
<name>Peilin Ye</name>
<email>yepeilin.cs@gmail.com</email>
</author>
<published>2020-07-31T04:48:38Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=bf4c61248445f08fc0e778c1b14f396b1c689b2e'/>
<id>urn:sha1:bf4c61248445f08fc0e778c1b14f396b1c689b2e</id>
<content type='text'>
[ Upstream commit 9aba6c5b49254d5bee927d81593ed4429e91d4ae ]

ovs_ct_put_key() is potentially copying uninitialized kernel stack memory
into socket buffers, since the compiler may leave a 3-byte hole at the end
of `struct ovs_key_ct_tuple_ipv4` and `struct ovs_key_ct_tuple_ipv6`. Fix
it by initializing `orig` with memset().

Fixes: 9dd7f8907c37 ("openvswitch: Add original direction conntrack tuple to sw_flow_key.")
Suggested-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Peilin Ye &lt;yepeilin.cs@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: support asymmetric conntrack</title>
<updated>2019-12-21T09:47:34Z</updated>
<author>
<name>Aaron Conole</name>
<email>aconole@redhat.com</email>
</author>
<published>2019-12-03T21:34:13Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=22f73f807e3dce32313ae7c87d81c95d4d8e7b66'/>
<id>urn:sha1:22f73f807e3dce32313ae7c87d81c95d4d8e7b66</id>
<content type='text'>
[ Upstream commit 5d50aa83e2c8e91ced2cca77c198b468ca9210f4 ]

The openvswitch module shares a common conntrack and NAT infrastructure
exposed via netfilter.  It's possible that a packet needs both SNAT and
DNAT manipulation, due to e.g. tuple collision.  Netfilter can support
this because it runs through the NAT table twice - once on ingress and
again after egress.  The openvswitch module doesn't have such capability.

Like netfilter hook infrastructure, we should run through NAT twice to
keep the symmetry.

Fixes: 05752523e565 ("openvswitch: Interface with NAT.")
Signed-off-by: Aaron Conole &lt;aconole@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: remove another BUG_ON()</title>
<updated>2019-12-05T14:38:17Z</updated>
<author>
<name>Paolo Abeni</name>
<email>pabeni@redhat.com</email>
</author>
<published>2019-12-01T17:41:25Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=796c569498e1ce5159f070c142ba1bfebd33cc18'/>
<id>urn:sha1:796c569498e1ce5159f070c142ba1bfebd33cc18</id>
<content type='text'>
[ Upstream commit 8a574f86652a4540a2433946ba826ccb87f398cc ]

If we can't build the flow del notification, we can simply delete
the flow, no need to crash the kernel. Still keep a WARN_ON to
preserve debuggability.

Note: the BUG_ON() predates the Fixes tag, but this change
can be applied only after the mentioned commit.

v1 -&gt; v2:
 - do not leak an skb on error

Fixes: aed067783e50 ("openvswitch: Minimize ovs_flow_cmd_del critical section.")
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: drop unneeded BUG_ON() in ovs_flow_cmd_build_info()</title>
<updated>2019-12-05T14:38:16Z</updated>
<author>
<name>Paolo Abeni</name>
<email>pabeni@redhat.com</email>
</author>
<published>2019-12-01T17:41:24Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=2356f0b95fc04f37a028e4f67ef7812aacd2e30c'/>
<id>urn:sha1:2356f0b95fc04f37a028e4f67ef7812aacd2e30c</id>
<content type='text'>
[ Upstream commit 8ffeb03fbba3b599690b361467bfd2373e8c450f ]

All the callers of ovs_flow_cmd_build_info() already deal with
error return code correctly, so we can handle the error condition
in a more gracefull way. Still dump a warning to preserve
debuggability.

v1 -&gt; v2:
 - clarify the commit message
 - clean the skb and report the error (DaveM)

Fixes: ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: fix flow command message size</title>
<updated>2019-12-05T14:38:16Z</updated>
<author>
<name>Paolo Abeni</name>
<email>pabeni@redhat.com</email>
</author>
<published>2019-11-26T11:55:50Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=0e32df103ca66a9efce43c6100bb0f8d973f24b6'/>
<id>urn:sha1:0e32df103ca66a9efce43c6100bb0f8d973f24b6</id>
<content type='text'>
[ Upstream commit 4e81c0b3fa93d07653e2415fa71656b080a112fd ]

When user-space sets the OVS_UFID_F_OMIT_* flags, and the relevant
flow has no UFID, we can exceed the computed size, as
ovs_nla_put_identifier() will always dump an OVS_FLOW_ATTR_KEY
attribute.
Take the above in account when computing the flow command message
size.

Fixes: 74ed7ab9264c ("openvswitch: Add support for unique flow IDs.")
Reported-by: Qi Jun Ding &lt;qding@redhat.com&gt;
Signed-off-by: Paolo Abeni &lt;pabeni@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>openvswitch: fix linking without CONFIG_NF_CONNTRACK_LABELS</title>
<updated>2019-12-01T08:14:02Z</updated>
<author>
<name>Arnd Bergmann</name>
<email>arnd@arndb.de</email>
</author>
<published>2018-11-02T15:36:55Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=c4509088acdfc8d1018e97ad0350f5edabada984'/>
<id>urn:sha1:c4509088acdfc8d1018e97ad0350f5edabada984</id>
<content type='text'>
[ Upstream commit a277d516de5f498c91d91189717ef7e01102ad27 ]

When CONFIG_CC_OPTIMIZE_FOR_DEBUGGING is enabled, the compiler
fails to optimize out a dead code path, which leads to a link failure:

net/openvswitch/conntrack.o: In function `ovs_ct_set_labels':
conntrack.c:(.text+0x2e60): undefined reference to `nf_connlabels_replace'

In this configuration, we can take a shortcut, and completely
remove the contrack label code. This may also help the regular
optimization.

Signed-off-by: Arnd Bergmann &lt;arnd@arndb.de&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: ovs: fix return type of ndo_start_xmit function</title>
<updated>2019-11-24T07:22:48Z</updated>
<author>
<name>YueHaibing</name>
<email>yuehaibing@huawei.com</email>
</author>
<published>2018-09-26T09:15:38Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=7af18b25bce0827335ab8b70b6887fb325c6fb76'/>
<id>urn:sha1:7af18b25bce0827335ab8b70b6887fb325c6fb76</id>
<content type='text'>
[ Upstream commit eddf11e18dff0e8671e06ce54e64cfc843303ab9 ]

The method ndo_start_xmit() is defined as returning an 'netdev_tx_t',
which is a typedef for an enum type, so make sure the implementation in
this driver has returns 'netdev_tx_t' value, and change the function
return type to netdev_tx_t.

Found by coccinelle.

Signed-off-by: YueHaibing &lt;yuehaibing@huawei.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>net: openvswitch: free vport unless register_netdevice() succeeds</title>
<updated>2019-11-12T18:18:37Z</updated>
<author>
<name>Hillf Danton</name>
<email>hdanton@sina.com</email>
</author>
<published>2019-10-21T10:01:57Z</published>
<link rel='alternate' type='text/html' href='https://git.stealer.net/cgit.cgi/user/sven/linux.git/commit/?id=107e5b0b9ed11d99e409e4a3e120237710c39e95'/>
<id>urn:sha1:107e5b0b9ed11d99e409e4a3e120237710c39e95</id>
<content type='text'>
[ Upstream commit 9464cc37f3671ee69cb1c00662b5e1f113a96b23 ]

syzbot found the following crash on:

HEAD commit:    1e78030e Merge tag 'mmc-v5.3-rc1' of git://git.kernel.org/..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=148d3d1a600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=30cef20daf3e9977
dashboard link: https://syzkaller.appspot.com/bug?extid=13210896153522fe1ee5
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=136aa8c4600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=109ba792600000

=====================================================================
BUG: memory leak
unreferenced object 0xffff8881207e4100 (size 128):
   comm "syz-executor032", pid 7014, jiffies 4294944027 (age 13.830s)
   hex dump (first 32 bytes):
     00 70 16 18 81 88 ff ff 80 af 8c 22 81 88 ff ff  .p........."....
     00 b6 23 17 81 88 ff ff 00 00 00 00 00 00 00 00  ..#.............
   backtrace:
     [&lt;000000000eb78212&gt;] kmemleak_alloc_recursive  include/linux/kmemleak.h:43 [inline]
     [&lt;000000000eb78212&gt;] slab_post_alloc_hook mm/slab.h:522 [inline]
     [&lt;000000000eb78212&gt;] slab_alloc mm/slab.c:3319 [inline]
     [&lt;000000000eb78212&gt;] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [&lt;00000000006ea6c6&gt;] kmalloc include/linux/slab.h:552 [inline]
     [&lt;00000000006ea6c6&gt;] kzalloc include/linux/slab.h:748 [inline]
     [&lt;00000000006ea6c6&gt;] ovs_vport_alloc+0x37/0xf0  net/openvswitch/vport.c:130
     [&lt;00000000f9a04a7d&gt;] internal_dev_create+0x24/0x1d0  net/openvswitch/vport-internal_dev.c:164
     [&lt;0000000056ee7c13&gt;] ovs_vport_add+0x81/0x190  net/openvswitch/vport.c:199
     [&lt;000000005434efc7&gt;] new_vport+0x19/0x80 net/openvswitch/datapath.c:194
     [&lt;00000000b7b253f1&gt;] ovs_dp_cmd_new+0x22f/0x410  net/openvswitch/datapath.c:1614
     [&lt;00000000e0988518&gt;] genl_family_rcv_msg+0x2ab/0x5b0  net/netlink/genetlink.c:629
     [&lt;00000000d0cc9347&gt;] genl_rcv_msg+0x54/0x9c net/netlink/genetlink.c:654
     [&lt;000000006694b647&gt;] netlink_rcv_skb+0x61/0x170  net/netlink/af_netlink.c:2477
     [&lt;0000000088381f37&gt;] genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
     [&lt;00000000dad42a47&gt;] netlink_unicast_kernel  net/netlink/af_netlink.c:1302 [inline]
     [&lt;00000000dad42a47&gt;] netlink_unicast+0x1ec/0x2d0  net/netlink/af_netlink.c:1328
     [&lt;0000000067e6b079&gt;] netlink_sendmsg+0x270/0x480  net/netlink/af_netlink.c:1917
     [&lt;00000000aab08a47&gt;] sock_sendmsg_nosec net/socket.c:637 [inline]
     [&lt;00000000aab08a47&gt;] sock_sendmsg+0x54/0x70 net/socket.c:657
     [&lt;000000004cb7c11d&gt;] ___sys_sendmsg+0x393/0x3c0 net/socket.c:2311
     [&lt;00000000c4901c63&gt;] __sys_sendmsg+0x80/0xf0 net/socket.c:2356
     [&lt;00000000c10abb2d&gt;] __do_sys_sendmsg net/socket.c:2365 [inline]
     [&lt;00000000c10abb2d&gt;] __se_sys_sendmsg net/socket.c:2363 [inline]
     [&lt;00000000c10abb2d&gt;] __x64_sys_sendmsg+0x23/0x30 net/socket.c:2363

BUG: memory leak
unreferenced object 0xffff88811723b600 (size 64):
   comm "syz-executor032", pid 7014, jiffies 4294944027 (age 13.830s)
   hex dump (first 32 bytes):
     01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
     00 00 00 00 00 00 00 00 02 00 00 00 05 35 82 c1  .............5..
   backtrace:
     [&lt;00000000352f46d8&gt;] kmemleak_alloc_recursive  include/linux/kmemleak.h:43 [inline]
     [&lt;00000000352f46d8&gt;] slab_post_alloc_hook mm/slab.h:522 [inline]
     [&lt;00000000352f46d8&gt;] slab_alloc mm/slab.c:3319 [inline]
     [&lt;00000000352f46d8&gt;] __do_kmalloc mm/slab.c:3653 [inline]
     [&lt;00000000352f46d8&gt;] __kmalloc+0x169/0x300 mm/slab.c:3664
     [&lt;000000008e48f3d1&gt;] kmalloc include/linux/slab.h:557 [inline]
     [&lt;000000008e48f3d1&gt;] ovs_vport_set_upcall_portids+0x54/0xd0  net/openvswitch/vport.c:343
     [&lt;00000000541e4f4a&gt;] ovs_vport_alloc+0x7f/0xf0  net/openvswitch/vport.c:139
     [&lt;00000000f9a04a7d&gt;] internal_dev_create+0x24/0x1d0  net/openvswitch/vport-internal_dev.c:164
     [&lt;0000000056ee7c13&gt;] ovs_vport_add+0x81/0x190  net/openvswitch/vport.c:199
     [&lt;000000005434efc7&gt;] new_vport+0x19/0x80 net/openvswitch/datapath.c:194
     [&lt;00000000b7b253f1&gt;] ovs_dp_cmd_new+0x22f/0x410  net/openvswitch/datapath.c:1614
     [&lt;00000000e0988518&gt;] genl_family_rcv_msg+0x2ab/0x5b0  net/netlink/genetlink.c:629
     [&lt;00000000d0cc9347&gt;] genl_rcv_msg+0x54/0x9c net/netlink/genetlink.c:654
     [&lt;000000006694b647&gt;] netlink_rcv_skb+0x61/0x170  net/netlink/af_netlink.c:2477
     [&lt;0000000088381f37&gt;] genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
     [&lt;00000000dad42a47&gt;] netlink_unicast_kernel  net/netlink/af_netlink.c:1302 [inline]
     [&lt;00000000dad42a47&gt;] netlink_unicast+0x1ec/0x2d0  net/netlink/af_netlink.c:1328
     [&lt;0000000067e6b079&gt;] netlink_sendmsg+0x270/0x480  net/netlink/af_netlink.c:1917
     [&lt;00000000aab08a47&gt;] sock_sendmsg_nosec net/socket.c:637 [inline]
     [&lt;00000000aab08a47&gt;] sock_sendmsg+0x54/0x70 net/socket.c:657
     [&lt;000000004cb7c11d&gt;] ___sys_sendmsg+0x393/0x3c0 net/socket.c:2311
     [&lt;00000000c4901c63&gt;] __sys_sendmsg+0x80/0xf0 net/socket.c:2356

BUG: memory leak
unreferenced object 0xffff8881228ca500 (size 128):
   comm "syz-executor032", pid 7015, jiffies 4294944622 (age 7.880s)
   hex dump (first 32 bytes):
     00 f0 27 18 81 88 ff ff 80 ac 8c 22 81 88 ff ff  ..'........"....
     40 b7 23 17 81 88 ff ff 00 00 00 00 00 00 00 00  @.#.............
   backtrace:
     [&lt;000000000eb78212&gt;] kmemleak_alloc_recursive  include/linux/kmemleak.h:43 [inline]
     [&lt;000000000eb78212&gt;] slab_post_alloc_hook mm/slab.h:522 [inline]
     [&lt;000000000eb78212&gt;] slab_alloc mm/slab.c:3319 [inline]
     [&lt;000000000eb78212&gt;] kmem_cache_alloc_trace+0x145/0x2c0 mm/slab.c:3548
     [&lt;00000000006ea6c6&gt;] kmalloc include/linux/slab.h:552 [inline]
     [&lt;00000000006ea6c6&gt;] kzalloc include/linux/slab.h:748 [inline]
     [&lt;00000000006ea6c6&gt;] ovs_vport_alloc+0x37/0xf0  net/openvswitch/vport.c:130
     [&lt;00000000f9a04a7d&gt;] internal_dev_create+0x24/0x1d0  net/openvswitch/vport-internal_dev.c:164
     [&lt;0000000056ee7c13&gt;] ovs_vport_add+0x81/0x190  net/openvswitch/vport.c:199
     [&lt;000000005434efc7&gt;] new_vport+0x19/0x80 net/openvswitch/datapath.c:194
     [&lt;00000000b7b253f1&gt;] ovs_dp_cmd_new+0x22f/0x410  net/openvswitch/datapath.c:1614
     [&lt;00000000e0988518&gt;] genl_family_rcv_msg+0x2ab/0x5b0  net/netlink/genetlink.c:629
     [&lt;00000000d0cc9347&gt;] genl_rcv_msg+0x54/0x9c net/netlink/genetlink.c:654
     [&lt;000000006694b647&gt;] netlink_rcv_skb+0x61/0x170  net/netlink/af_netlink.c:2477
     [&lt;0000000088381f37&gt;] genl_rcv+0x29/0x40 net/netlink/genetlink.c:665
     [&lt;00000000dad42a47&gt;] netlink_unicast_kernel  net/netlink/af_netlink.c:1302 [inline]
     [&lt;00000000dad42a47&gt;] netlink_unicast+0x1ec/0x2d0  net/netlink/af_netlink.c:1328
     [&lt;0000000067e6b079&gt;] netlink_sendmsg+0x270/0x480  net/netlink/af_netlink.c:1917
     [&lt;00000000aab08a47&gt;] sock_sendmsg_nosec net/socket.c:637 [inline]
     [&lt;00000000aab08a47&gt;] sock_sendmsg+0x54/0x70 net/socket.c:657
     [&lt;000000004cb7c11d&gt;] ___sys_sendmsg+0x393/0x3c0 net/socket.c:2311
     [&lt;00000000c4901c63&gt;] __sys_sendmsg+0x80/0xf0 net/socket.c:2356
     [&lt;00000000c10abb2d&gt;] __do_sys_sendmsg net/socket.c:2365 [inline]
     [&lt;00000000c10abb2d&gt;] __se_sys_sendmsg net/socket.c:2363 [inline]
     [&lt;00000000c10abb2d&gt;] __x64_sys_sendmsg+0x23/0x30 net/socket.c:2363
=====================================================================

The function in net core, register_netdevice(), may fail with vport's
destruction callback either invoked or not. After commit 309b66970ee2
("net: openvswitch: do not free vport if register_netdevice() is failed."),
the duty to destroy vport is offloaded from the driver OTOH, which ends
up in the memory leak reported.

It is fixed by releasing vport unless device is registered successfully.
To do that, the callback assignment is defered until device is registered.

Reported-by: syzbot+13210896153522fe1ee5@syzkaller.appspotmail.com
Fixes: 309b66970ee2 ("net: openvswitch: do not free vport if register_netdevice() is failed.")
Cc: Taehee Yoo &lt;ap420073@gmail.com&gt;
Cc: Greg Rose &lt;gvrose8192@gmail.com&gt;
Cc: Eric Dumazet &lt;eric.dumazet@gmail.com&gt;
Cc: Marcelo Ricardo Leitner &lt;marcelo.leitner@gmail.com&gt;
Cc: Ying Xue &lt;ying.xue@windriver.com&gt;
Cc: Andrey Konovalov &lt;andreyknvl@google.com&gt;
Signed-off-by: Hillf Danton &lt;hdanton@sina.com&gt;
Acked-by: Pravin B Shelar &lt;pshelar@ovn.org&gt;
[sbrivio: this was sent to dev@openvswitch.org and never made its way
 to netdev -- resending original patch]
Signed-off-by: Stefano Brivio &lt;sbrivio@redhat.com&gt;
Reviewed-by: Greg Rose &lt;gvrose8192@gmail.com&gt;
Signed-off-by: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
</feed>
