Wang Yufen
1118b2049d
net: tun: Fix memory leaks of napi_get_frags
kmemleak reports after running test_progs:
unreferenced object 0xffff8881b1672dc0 (size 232):
comm "test_progs", pid 394388, jiffies 4354712116 (age 841.975s)
hex dump (first 32 bytes):
e0 84 d7 a8 81 88 ff ff 80 2c 67 b1 81 88 ff ff .........,g.....
00 40 c5 9b 81 88 ff ff 00 00 00 00 00 00 00 00 .@..............
backtrace:
[<00000000c8f01748>] napi_skb_cache_get+0xd4/0x150
[<0000000041c7fc09>] __napi_build_skb+0x15/0x50
[<00000000431c7079>] __napi_alloc_skb+0x26e/0x540
[<000000003ecfa30e>] napi_get_frags+0x59/0x140
[<0000000099b2199e>] tun_get_user+0x183d/0x3bb0 [tun]
[<000000008a5adef0>] tun_chr_write_iter+0xc0/0x1b1 [tun]
[<0000000049993ff4>] do_iter_readv_writev+0x19f/0x320
[<000000008f338ea2>] do_iter_write+0x135/0x630
[<000000008a3377a4>] vfs_writev+0x12e/0x440
[<00000000a6b5639a>] do_writev+0x104/0x280
[<00000000ccf065d8>] do_syscall_64+0x3b/0x90
[<00000000d776e329>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
The issue occurs in the following scenarios:
tun_get_user()
napi_gro_frags()
napi_frags_finish()
case GRO_NORMAL:
gro_normal_one()
list_add_tail(&skb->list, &napi->rx_list);
<-- While napi->rx_count < READ_ONCE(gro_normal_batch),
<-- gro_normal_list() is not called, napi->rx_list is not empty
<-- not ask to complete the gro work, will cause memory leaks in
<-- following tun_napi_del()
...
tun_napi_del()
netif_napi_del()
__netif_napi_del()
<-- &napi->rx_list is not empty, which caused memory leaks
To fix, add napi_complete() after napi_gro_frags().
Fixes: 90e33d4594 ("tun: enable napi_gro_frags() for TUN/TAP driver")
Signed-off-by: Wang Yufen <wangyufen@huawei.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2022-11-04 10:56:22 +00:00
..
2022-10-28 16:48:29 -07:00
2022-10-10 09:10:28 -07:00
2022-10-18 08:02:14 +09:00
2022-10-28 16:48:29 -07:00
2022-10-12 10:23:24 -07:00
2022-10-29 18:06:52 -07:00
2022-11-02 14:15:42 -07:00
2022-10-08 08:56:37 -07:00
2022-10-29 00:24:03 +02:00
2022-10-16 11:08:19 -07:00
2022-10-10 10:16:00 -07:00
2022-10-23 20:39:26 -04:00
2022-10-25 15:09:23 +02:00
2022-10-09 13:24:01 -07:00
2022-10-10 13:04:25 -07:00
2022-10-14 18:41:41 -07:00
2022-09-26 03:59:43 +09:00
2022-10-11 17:42:58 -06:00
2022-10-06 17:22:11 -07:00
2022-10-13 11:07:13 -07:00
2022-10-08 08:56:37 -07:00
2022-10-21 11:09:41 +02:00
2022-10-08 08:56:37 -07:00
2022-09-28 21:10:57 +09:30
2022-10-20 13:47:54 +02:00
2022-10-28 13:00:15 +10:00
2022-10-21 17:41:57 -07:00
2022-10-10 13:59:01 -07:00
2022-10-23 10:01:34 -07:00
2022-10-25 19:08:07 +02:00
2022-10-21 07:59:35 +02:00
2022-10-12 23:45:29 +02:00
2022-10-17 08:51:26 +01:00
2022-10-28 12:59:40 -03:00
2022-10-11 10:53:25 -07:00
2022-10-21 10:49:35 +02:00
2022-10-08 08:56:37 -07:00
2022-10-12 10:23:24 -07:00
2022-11-02 12:34:48 +00:00
2022-10-24 11:32:10 +02:00
2022-10-09 14:05:15 -07:00
2022-10-05 21:51:58 -05:00
2022-10-18 17:17:48 -04:00
2022-10-25 16:43:34 +01:00
2022-10-23 12:04:56 -07:00
2022-10-25 19:12:10 +02:00
2022-10-26 11:48:03 +02:00
2022-10-18 11:20:12 +02:00
2022-11-04 10:56:22 +00:00
2022-10-30 21:43:26 +00:00
2022-10-14 18:41:41 -07:00
2022-10-29 18:06:52 -07:00
2022-09-24 14:56:37 +02:00
2022-10-10 13:13:51 -07:00
2022-10-27 09:12:05 +02:00
2022-10-17 12:11:09 -05:00
2022-09-27 08:12:16 +02:00
2022-10-14 12:38:03 -07:00
2022-10-11 11:08:18 -07:00
2022-10-18 10:42:10 +02:00
2022-10-30 09:44:06 -07:00
2022-10-10 18:11:11 +02:00
2022-10-07 11:48:30 -07:00
2022-10-10 09:10:28 -07:00
2022-10-10 08:37:24 +01:00
2022-10-07 11:32:10 -07:00
2022-10-07 11:24:20 -07:00
2022-10-05 09:20:44 -06:00
2022-10-08 10:06:48 -07:00
2022-10-18 22:36:54 +02:00
2022-10-26 14:47:31 +02:00
2022-10-29 18:12:45 -07:00
2022-09-24 14:53:06 +02:00
2022-10-13 11:07:13 -07:00
2022-10-07 16:13:55 -07:00
2022-10-26 17:38:46 -07:00
2022-09-30 14:33:23 +02:00
2022-10-22 15:30:15 -07:00
2022-10-21 01:10:34 +00:00
2022-10-10 17:53:04 -07:00
2022-10-15 19:33:57 +02:00
2022-10-11 17:42:58 -06:00
2022-10-21 08:10:46 +02:00
2022-10-22 03:29:32 +00:00
2022-10-30 11:31:14 -07:00
2022-10-10 14:02:53 -07:00
2022-10-12 14:46:48 -07:00
2022-10-10 14:02:53 -07:00
2022-10-30 11:31:14 -07:00
2022-10-08 08:56:37 -07:00
2022-10-13 09:33:03 -04:00
2022-10-08 08:56:37 -07:00
2022-11-01 12:21:53 -07:00
2022-10-21 14:43:09 -07:00