Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for strict confinement of snaps #60

Closed
wants to merge 2 commits into from
Closed

Support for strict confinement of snaps #60

wants to merge 2 commits into from

Conversation

sirredbeard
Copy link

@sirredbeard sirredbeard commented Dec 4, 2019

These are proposed edits made by @diddlesnaps to enable strict confinement of snap packages on WSL2.

Post on Snapcraft forum: https://forum.snapcraft.io/t/running-snaps-on-wsl2-insiders-only-for-now/13033

Daniel Llewellyn added 2 commits November 1, 2019 21:32
Snapd strict confinement requires apparmor with a legacy patch applied
to the kernel.

* Add apparmor v1 (legacy) patch for snapd support
* Update config-wsl to enable apparmor by default

Signed-off-by: Daniel Llewellyn <[email protected]>
* Add AppArmor for arm64
* Change LOCALVERSION for snapd identification

Signed-off-by: Daniel Llewellyn <[email protected]>
@msftclas
Copy link

msftclas commented Dec 4, 2019

CLA assistant check
All CLA requirements met.

KangDroid pushed a commit to KangDroid/WSL2-Linux-Kernel that referenced this pull request May 26, 2020
commit bdcc5bc upstream.

Since mISDN_close() uses dev->pending to iterate over active
timers, there is a chance that one timer got removed from the
->pending list in dev_expire_timer() but that the thread
has not called yet wake_up_interruptible()

So mISDN_close() could miss this and free dev before
completion of at least one dev_expire_timer()

syzbot was able to catch this race :

BUG: KASAN: use-after-free in register_lock_class+0x140c/0x1bf0 kernel/locking/lockdep.c:827
Write of size 8 at addr ffff88809fc18948 by task syz-executor1/24769

CPU: 1 PID: 24769 Comm: syz-executor1 Not tainted 5.0.0-rc5 microsoft#60
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack+0x172/0x1f0 lib/dump_stack.c:113
 print_address_description.cold+0x7c/0x20d mm/kasan/report.c:187
 kasan_report.cold+0x1b/0x40 mm/kasan/report.c:317
 __asan_report_store8_noabort+0x17/0x20 mm/kasan/generic_report.c:140
 register_lock_class+0x140c/0x1bf0 kernel/locking/lockdep.c:827
 __lock_acquire+0x11f/0x4700 kernel/locking/lockdep.c:3224
 lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3841
 __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
 _raw_spin_lock_irqsave+0x95/0xcd kernel/locking/spinlock.c:152
 __wake_up_common_lock+0xc7/0x190 kernel/sched/wait.c:120
 __wake_up+0xe/0x10 kernel/sched/wait.c:145
 dev_expire_timer+0xe4/0x3b0 drivers/isdn/mISDN/timerdev.c:174
 call_timer_fn+0x190/0x720 kernel/time/timer.c:1325
protocol 88fb is buggy, dev hsr_slave_0
protocol 88fb is buggy, dev hsr_slave_1
 expire_timers kernel/time/timer.c:1362 [inline]
 __run_timers kernel/time/timer.c:1681 [inline]
 __run_timers kernel/time/timer.c:1649 [inline]
 run_timer_softirq+0x652/0x1700 kernel/time/timer.c:1694
 __do_softirq+0x266/0x95a kernel/softirq.c:292
 invoke_softirq kernel/softirq.c:373 [inline]
 irq_exit+0x180/0x1d0 kernel/softirq.c:413
 exiting_irq arch/x86/include/asm/apic.h:536 [inline]
 smp_apic_timer_interrupt+0x14a/0x570 arch/x86/kernel/apic/apic.c:1062
 apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:807
 </IRQ>
RIP: 0010:__sanitizer_cov_trace_pc+0x26/0x50 kernel/kcov.c:101
Code: 90 90 90 90 55 48 89 e5 48 8b 75 08 65 48 8b 04 25 40 ee 01 00 65 8b 15 98 12 92 7e 81 e2 00 01 1f 00 75 2b 8b 90 d8 12 00 00 <83> fa 02 75 20 48 8b 88 e0 12 00 00 8b 80 dc 12 00 00 48 8b 11 48
RSP: 0018:ffff8880589b7a60 EFLAGS: 00000246 ORIG_RAX: ffffffffffffff13
RAX: ffff888087ce25c0 RBX: 0000000000000001 RCX: ffffffff818f8ca3
RDX: 0000000000000000 RSI: ffffffff818f8b48 RDI: 0000000000000001
RBP: ffff8880589b7a60 R08: ffff888087ce25c0 R09: ffffed1015d25bd0
R10: ffffed1015d25bcf R11: ffff8880ae92de7b R12: ffffea0001ae4680
R13: ffffea0001ae4688 R14: 0000000000000000 R15: ffffea0001b41648
 PageIdle include/linux/page-flags.h:398 [inline]
 page_is_idle include/linux/page_idle.h:29 [inline]
 mark_page_accessed+0x618/0x1140 mm/swap.c:398
 touch_buffer fs/buffer.c:59 [inline]
 __find_get_block+0x312/0xcc0 fs/buffer.c:1298
 sb_find_get_block include/linux/buffer_head.h:338 [inline]
 recently_deleted fs/ext4/ialloc.c:682 [inline]
 find_inode_bit.isra.0+0x202/0x510 fs/ext4/ialloc.c:722
 __ext4_new_inode+0x14ad/0x52c0 fs/ext4/ialloc.c:914
 ext4_symlink+0x3f8/0xbe0 fs/ext4/namei.c:3096
 vfs_symlink fs/namei.c:4126 [inline]
 vfs_symlink+0x378/0x5d0 fs/namei.c:4112
 do_symlinkat+0x22b/0x290 fs/namei.c:4153
 __do_sys_symlink fs/namei.c:4172 [inline]
 __se_sys_symlink fs/namei.c:4170 [inline]
 __x64_sys_symlink+0x59/0x80 fs/namei.c:4170
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x457b67
Code: 0f 1f 00 b8 5c 00 00 00 0f 05 48 3d 01 f0 ff ff 0f 83 6d bb fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 b8 58 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 4d bb fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007fff045ce0f8 EFLAGS: 00000202 ORIG_RAX: 0000000000000058
RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 0000000000457b67
RDX: 00007fff045ce173 RSI: 00000000004bd63f RDI: 00007fff045ce160
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000013
R10: 0000000000000075 R11: 0000000000000202 R12: 0000000000000000
R13: 0000000000000001 R14: 000000000000029b R15: 0000000000000001

Allocated by task 24763:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_kmalloc mm/kasan/common.c:496 [inline]
 __kasan_kmalloc.constprop.0+0xcf/0xe0 mm/kasan/common.c:469
 kasan_kmalloc+0x9/0x10 mm/kasan/common.c:504
 kmem_cache_alloc_trace+0x151/0x760 mm/slab.c:3609
 kmalloc include/linux/slab.h:545 [inline]
 mISDN_open+0x9a/0x270 drivers/isdn/mISDN/timerdev.c:59
 misc_open+0x398/0x4c0 drivers/char/misc.c:141
 chrdev_open+0x247/0x6b0 fs/char_dev.c:417
 do_dentry_open+0x47d/0x1130 fs/open.c:771
 vfs_open+0xa0/0xd0 fs/open.c:880
 do_last fs/namei.c:3418 [inline]
 path_openat+0x10d7/0x4690 fs/namei.c:3534
 do_filp_open+0x1a1/0x280 fs/namei.c:3564
 do_sys_open+0x3fe/0x5d0 fs/open.c:1063
 __do_sys_openat fs/open.c:1090 [inline]
 __se_sys_openat fs/open.c:1084 [inline]
 __x64_sys_openat+0x9d/0x100 fs/open.c:1084
 do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Freed by task 24762:
 save_stack+0x45/0xd0 mm/kasan/common.c:73
 set_track mm/kasan/common.c:85 [inline]
 __kasan_slab_free+0x102/0x150 mm/kasan/common.c:458
 kasan_slab_free+0xe/0x10 mm/kasan/common.c:466
 __cache_free mm/slab.c:3487 [inline]
 kfree+0xcf/0x230 mm/slab.c:3806
 mISDN_close+0x2a1/0x390 drivers/isdn/mISDN/timerdev.c:97
 __fput+0x2df/0x8d0 fs/file_table.c:278
 ____fput+0x16/0x20 fs/file_table.c:309
 task_work_run+0x14a/0x1c0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x273/0x2c0 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x52d/0x610 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

The buggy address belongs to the object at ffff88809fc18900
 which belongs to the cache kmalloc-192 of size 192
The buggy address is located 72 bytes inside of
 192-byte region [ffff88809fc18900, ffff88809fc189c0)
The buggy address belongs to the page:
page:ffffea00027f0600 count:1 mapcount:0 mapping:ffff88812c3f0040 index:0xffff88809fc18000
flags: 0x1fffc0000000200(slab)
raw: 01fffc0000000200 ffffea000269f648 ffffea00029f7408 ffff88812c3f0040
raw: ffff88809fc18000 ffff88809fc18000 000000010000000b 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff88809fc18800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 ffff88809fc18880: 00 fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff88809fc18900: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                              ^
 ffff88809fc18980: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
 ffff88809fc18a00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

Signed-off-by: Eric Dumazet <[email protected]>
Cc: Karsten Keil <[email protected]>
Reported-by: syzbot <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
@WSLUser
Copy link

WSLUser commented Jun 9, 2020

Can you update your PR with mine as base? Many of the config options are included but looks like not all of them (specifically the AppArmor stuff) I also suggest pushing the other changes back to upstream kernel under an if/def for WSL.

nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Jul 11, 2020
Depending on the workloads, the following circular locking dependency
warning between sb_internal (a percpu rwsem) and fs_reclaim (a pseudo
lock) may show up:

======================================================
WARNING: possible circular locking dependency detected
5.0.0-rc1+ microsoft#60 Tainted: G        W
------------------------------------------------------
fsfreeze/4346 is trying to acquire lock:
0000000026f1d784 (fs_reclaim){+.+.}, at:
fs_reclaim_acquire.part.19+0x5/0x30

but task is already holding lock:
0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650

which lock already depends on the new lock.
  :
 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(sb_internal);
                               lock(fs_reclaim);
                               lock(sb_internal);
  lock(fs_reclaim);

 *** DEADLOCK ***

4 locks held by fsfreeze/4346:
 #0: 00000000b478ef56 (sb_writers#8){++++}, at: percpu_down_write+0xb4/0x650
 #1: 000000001ec487a9 (&type->s_umount_key#28){++++}, at: freeze_super+0xda/0x290
 #2: 000000003edbd5a0 (sb_pagefaults){++++}, at: percpu_down_write+0xb4/0x650
 #3: 0000000072bfc54b (sb_internal){++++}, at: percpu_down_write+0xb4/0x650

stack backtrace:
Call Trace:
 dump_stack+0xe0/0x19a
 print_circular_bug.isra.10.cold.34+0x2f4/0x435
 check_prev_add.constprop.19+0xca1/0x15f0
 validate_chain.isra.14+0x11af/0x3b50
 __lock_acquire+0x728/0x1200
 lock_acquire+0x269/0x5a0
 fs_reclaim_acquire.part.19+0x29/0x30
 fs_reclaim_acquire+0x19/0x20
 kmem_cache_alloc+0x3e/0x3f0
 kmem_zone_alloc+0x79/0x150
 xfs_trans_alloc+0xfa/0x9d0
 xfs_sync_sb+0x86/0x170
 xfs_log_sbcount+0x10f/0x140
 xfs_quiesce_attr+0x134/0x270
 xfs_fs_freeze+0x4a/0x70
 freeze_super+0x1af/0x290
 do_vfs_ioctl+0xedc/0x16c0
 ksys_ioctl+0x41/0x80
 __x64_sys_ioctl+0x73/0xa9
 do_syscall_64+0x18f/0xd23
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

This is a false positive as all the dirty pages are flushed out before
the filesystem can be frozen.

One way to avoid this splat is to add GFP_NOFS to the affected allocation
calls by using the memalloc_nofs_save()/memalloc_nofs_restore() pair.
This shouldn't matter unless the system is really running out of memory.
In that particular case, the filesystem freeze operation may fail while
it was succeeding previously.

Without this patch, the command sequence below will show that the lock
dependency chain sb_internal -> fs_reclaim exists.

 # fsfreeze -f /home
 # fsfreeze --unfreeze /home
 # grep -i fs_reclaim -C 3 /proc/lockdep_chains | grep -C 5 sb_internal

After applying the patch, such sb_internal -> fs_reclaim lock dependency
chain can no longer be found. Because of that, the locking dependency
warning will not be shown.

Suggested-by: Dave Chinner <[email protected]>
Signed-off-by: Waiman Long <[email protected]>
Reviewed-by: Darrick J. Wong <[email protected]>
Signed-off-by: Darrick J. Wong <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
@jiayali-ms
Copy link
Contributor

Thank you for your contribution. The WSL team has discussed and decided that the WSL 2 Linux kernel GitHub repo is not taking pull requests. The WSL 2 Linux kernel repo was always intended to provide the additional infrastructure necessary to build and release the kernel component of WSL 2. It was never designed to replace the current existing community and feedback channels for WSL, especially through https://github.com/microsoft/WSL. This is why we are not accepting issues or pull requests through this repository.

We understand that this should have been better communicated and implemented from the beginning. While we understand that it is frustrating to have a PR closed, it is never our intention to ignore feedback or stifle community discussions. We are taking this opportunity to increase transparency on how we work with the WSL community and ensure all members are routed to the appropriate resources.

If you would like contribute to, discuss, or report an issue relating to WSL, or the WSL 2 Linux kernel configuration, please do so at the WSL GitHub. The team is actively monitoring and responding to user feedback there: https://github.com/microsoft/WSL.

The WSL 2 Linux kernel is based on the Linux version from https://www.kernel.org/. If you would like to contribute to or report an issue on the Linux kernel in general, please do so on the upstream Linux GitHub: https://www.kernel.org/doc/html/latest/process/submitting-patches.html.

@jiayali-ms jiayali-ms closed this Jun 22, 2021
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Jul 17, 2021
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 26, 2021
Commit 4dfb998 ("tsn:  Fix build.") fixed compilation with const
dev_addr. In tsnep_netdev_set_mac_address() the call of ether_addr_copy()
was replaced with dev_set_mac_address(), which calls
ndo_set_mac_address(). This results in an endless recursive loop because
ndo_set_mac_address is set to tsnep_netdev_set_mac_address.

Call eth_hw_addr_set() instead of dev_set_mac_address() in
ndo_set_mac_address()/tsnep_netdev_set_mac_address() to copy the address
as intended.

[   26.563303] Insufficient stack space to handle exception!
[   26.563312] ESR: 0x96000047 -- DABT (current EL)
[   26.563317] FAR: 0xffff80000a507fc0
[   26.563320] Task stack:     [0xffff80000a508000..0xffff80000a50c000]
[   26.563324] IRQ stack:      [0xffff80000a0c0000..0xffff80000a0c4000]
[   26.563327] Overflow stack: [0xffff00007fbaf2b0..0xffff00007fbb02b0]
[   26.563333] CPU: 3 PID: 381 Comm: ifconfig Not tainted 5.16.0-rc1-zynqmp microsoft#60
[   26.563340] Hardware name: TSN endpoint (DT)
[   26.563343] pstate: a0000005 (NzCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[   26.563351] pc : inetdev_event+0x4/0x560
[   26.563364] lr : raw_notifier_call_chain+0x54/0x78
[   26.563372] sp : ffff80000a508040
[   26.563374] x29: ffff80000a508040 x28: ffff00000132b800 x27: 0000000000000000
[   26.563386] x26: 0000000000000000 x25: ffff800000ea5058 x24: 0904030201020001
[   26.563396] x23: ffff800000ea5058 x22: ffff80000a5080e0 x21: 0000000000000009
[   26.563405] x20: 00000000fffffffa x19: ffff80000a009510 x18: 0000000000000000
[   26.563414] x17: 0000000000000000 x16: 0000000000000000 x15: 0000ffffd1341030
[   26.563422] x14: ffffffffffffffff x13: 0000000000000020 x12: 0101010101010101
[   26.563432] x11: 0000000000000020 x10: 0101010101010101 x9 : 7f7f7f7f7f7f7f7f
[   26.563441] x8 : 7f7f7f7f7f7f7f7f x7 : fefefeff30677364 x6 : 0000000080808080
[   26.563450] x5 : 0000000000000000 x4 : ffff800008dee170 x3 : ffff80000a50bd42
[   26.563459] x2 : ffff80000a5080e0 x1 : 0000000000000009 x0 : ffff80000a0092d0
[   26.563470] Kernel panic - not syncing: kernel stack overflow
[   26.563474] CPU: 3 PID: 381 Comm: ifconfig Not tainted 5.16.0-rc1-zynqmp microsoft#60
[   26.563481] Hardware name: TSN endpoint (DT)
[   26.563484] Call trace:
[   26.563486]  dump_backtrace+0x0/0x1b0
[   26.563497]  show_stack+0x18/0x68
[   26.563504]  dump_stack_lvl+0x68/0x84
[   26.563513]  dump_stack+0x18/0x34
[   26.563519]  panic+0x164/0x324
[   26.563524]  nmi_panic+0x64/0x98
[   26.563533]  panic_bad_stack+0x108/0x128
[   2k6.563539]  handle_bad_stack+0x38/0x68
[   26.563548]  __bad_stack+0x88/0x8c
[   26.563553]  inetdev_event+0x4/0x560
[   26.563560]  call_netdevice_notifiers_info+0x58/0xa8
[   26.563569]  dev_set_mac_address+0x78/0x110
[   26.563576]  tsnep_netdev_set_mac_address+0x38/0x60 [tsnep]
[   26.563591]  dev_set_mac_address+0xc4/0x110
[   26.563599]  tsnep_netdev_set_mac_address+0x38/0x60 [tsnep]
...
[   26.565444]  dev_set_mac_address+0xc4/0x110
[   26.565452]  tsnep_netdev_set_mac_address+0x38/0x60 [tsnep]
[   26.565462]  dev_set_mac_address+0xc4/0x110
[   26.565469]  dev_set_mac_address_user+0x44/0x68
[   26.565477]  dev_ifsioc+0x30c/0x568
[   26.565483]  dev_ioctl+0x124/0x3f0
[   26.565489]  sock_do_ioctl+0xb4/0xf8
[   26.565497]  sock_ioctl+0x2f4/0x398
[   26.565503]  __arm64_sys_ioctl+0xa8/0xe8
[   26.565511]  invoke_syscall+0x44/0x108
[   26.565520]  el0_svc_common.constprop.3+0x94/0xf8
[   26.565527]  do_el0_svc+0x24/0x88
[   26.565534]  el0_svc+0x20/0x50
[   26.565541]  el0t_64_sync_handler+0x90/0xb8
[   26.565548]  el0t_64_sync+0x180/0x184
[   26.565556] SMP: stopping secondary CPUs
[   26.565622] Kernel Offset: disabled
[   26.565624] CPU features: 0x0,00004002,00000846
[   26.565628] Memory Limit: none
[   27.843428] ---[ end Kernel panic - not syncing: kernel stack overflow ]---

Fixes: 4dfb998 ("tsn:  Fix build.")
Signed-off-by: Gerhard Engleder <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 30, 2021
Currently, with an unknown recv_type, mwifiex_usb_recv
just return -1 without restoring the skb. Next time
mwifiex_usb_rx_complete is invoked with the same skb,
calling skb_put causes skb_over_panic.

The bug is triggerable with a compromised/malfunctioning
usb device. After applying the patch, skb_over_panic
no longer shows up with the same input.

Attached is the panic report from fuzzing.
skbuff: skb_over_panic: text:000000003bf1b5fa
 len:2048 put:4 head:00000000dd6a115b data:000000000a9445d8
 tail:0x844 end:0x840 dev:<NULL>
kernel BUG at net/core/skbuff.c:109!
invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 PID: 198 Comm: in:imklog Not tainted 5.6.0 microsoft#60
RIP: 0010:skb_panic+0x15f/0x161
Call Trace:
 <IRQ>
 ? mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb]
 skb_put.cold+0x24/0x24
 mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb]
 __usb_hcd_giveback_urb+0x1e4/0x380
 usb_giveback_urb_bh+0x241/0x4f0
 ? __hrtimer_run_queues+0x316/0x740
 ? __usb_hcd_giveback_urb+0x380/0x380
 tasklet_action_common.isra.0+0x135/0x330
 __do_softirq+0x18c/0x634
 irq_exit+0x114/0x140
 smp_apic_timer_interrupt+0xde/0x380
 apic_timer_interrupt+0xf/0x20
 </IRQ>

Reported-by: Brendan Dolan-Gavitt <[email protected]>
Signed-off-by: Zekun Shen <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Jan 20, 2022
arm32 uses software to simulate the instruction replaced
by kprobe. some instructions may be simulated by constructing
assembly functions. therefore, before executing instruction
simulation, it is necessary to construct assembly function
execution environment in C language through binding registers.
after kasan is enabled, the register binding relationship will
be destroyed, resulting in instruction simulation errors and
causing kernel panic.

the kprobe emulate instruction function is distributed in three
files: actions-common.c actions-arm.c actions-thumb.c, so disable
KASAN when compiling these files.

for example, use kprobe insert on cap_capable+20 after kasan
enabled, the cap_capable assembly code is as follows:
<cap_capable>:
e92d47f0	push	{r4, r5, r6, r7, r8, r9, sl, lr}
e1a05000	mov	r5, r0
e280006c	add	r0, r0, #108    ; 0x6c
e1a04001	mov	r4, r1
e1a06002	mov	r6, r2
e59fa090	ldr	sl, [pc, #144]  ;
ebfc7bf8	bl	c03aa4b4 <__asan_load4>
e595706c	ldr	r7, [r5, #108]  ; 0x6c
e2859014	add	r9, r5, #20
......
The emulate_ldr assembly code after enabling kasan is as follows:
c06f1384 <emulate_ldr>:
e92d47f0	push	{r4, r5, r6, r7, r8, r9, sl, lr}
e282803c	add	r8, r2, microsoft#60     ; 0x3c
e1a05000	mov	r5, r0
e7e37855	ubfx	r7, r5, #16, #4
e1a00008	mov	r0, r8
e1a09001	mov	r9, r1
e1a04002	mov	r4, r2
ebf35462	bl	c03c6530 <__asan_load4>
e357000f	cmp	r7, #15
e7e36655	ubfx	r6, r5, #12, #4
e205a00f	and	sl, r5, #15
0a000001	beq	c06f13bc <emulate_ldr+0x38>
e0840107	add	r0, r4, r7, lsl #2
ebf3545c	bl	c03c6530 <__asan_load4>
e084010a	add	r0, r4, sl, lsl #2
ebf3545a	bl	c03c6530 <__asan_load4>
e2890010	add	r0, r9, #16
ebf35458	bl	c03c6530 <__asan_load4>
e5990010	ldr	r0, [r9, #16]
e12fff30	blx	r0
e356000f	cm	r6, #15
1a000014	bne	c06f1430 <emulate_ldr+0xac>
e1a06000	mov	r6, r0
e2840040	add	r0, r4, #64     ; 0x40
......

when running in emulate_ldr to simulate the ldr instruction, panic
occurred, and the log is as follows:
Unable to handle kernel NULL pointer dereference at virtual address
00000090
pgd = ecb46400
[00000090] *pgd=2e0fa003, *pmd=00000000
Internal error: Oops: 206 [#1] SMP ARM
PC is at cap_capable+0x14/0xb0
LR is at emulate_ldr+0x50/0xc0
psr: 600d0293 sp : ecd63af8  ip : 00000004  fp : c0a7c30c
r10: 00000000  r9 : c30897f4  r8 : ecd63cd4
r7 : 0000000f  r6 : 0000000a  r5 : e59fa090  r4 : ecd63c98
r3 : c06ae294  r2 : 00000000  r1 : b7611300  r0 : bf4ec008
Flags: nZCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment user
Control: 32c5387d  Table: 2d546400  DAC: 55555555
Process bash (pid: 1643, stack limit = 0xecd60190)
(cap_capable) from (kprobe_handler+0x218/0x340)
(kprobe_handler) from (kprobe_trap_handler+0x24/0x48)
(kprobe_trap_handler) from (do_undefinstr+0x13c/0x364)
(do_undefinstr) from (__und_svc_finish+0x0/0x30)
(__und_svc_finish) from (cap_capable+0x18/0xb0)
(cap_capable) from (cap_vm_enough_memory+0x38/0x48)
(cap_vm_enough_memory) from
(security_vm_enough_memory_mm+0x48/0x6c)
(security_vm_enough_memory_mm) from
(copy_process.constprop.5+0x16b4/0x25c8)
(copy_process.constprop.5) from (_do_fork+0xe8/0x55c)
(_do_fork) from (SyS_clone+0x1c/0x24)
(SyS_clone) from (__sys_trace_return+0x0/0x10)
Code: 0050a0e1 6c0080e2 0140a0e1 0260a0e1 (f801f0e7)

Fixes: 35aa1df ("ARM kprobes: instruction single-stepping support")
Fixes: 4210157 ("ARM: 9017/2: Enable KASan for ARM")
Signed-off-by: huangshaobo <[email protected]>
Acked-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Russell King (Oracle) <[email protected]>
sileshn pushed a commit to sileshn/WSL2-Linux-Kernel that referenced this pull request Jan 27, 2022
[ Upstream commit 04d8066 ]

Currently, with an unknown recv_type, mwifiex_usb_recv
just return -1 without restoring the skb. Next time
mwifiex_usb_rx_complete is invoked with the same skb,
calling skb_put causes skb_over_panic.

The bug is triggerable with a compromised/malfunctioning
usb device. After applying the patch, skb_over_panic
no longer shows up with the same input.

Attached is the panic report from fuzzing.
skbuff: skb_over_panic: text:000000003bf1b5fa
 len:2048 put:4 head:00000000dd6a115b data:000000000a9445d8
 tail:0x844 end:0x840 dev:<NULL>
kernel BUG at net/core/skbuff.c:109!
invalid opcode: 0000 [#1] SMP KASAN NOPTI
CPU: 0 PID: 198 Comm: in:imklog Not tainted 5.6.0 microsoft#60
RIP: 0010:skb_panic+0x15f/0x161
Call Trace:
 <IRQ>
 ? mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb]
 skb_put.cold+0x24/0x24
 mwifiex_usb_rx_complete+0x26b/0xfcd [mwifiex_usb]
 __usb_hcd_giveback_urb+0x1e4/0x380
 usb_giveback_urb_bh+0x241/0x4f0
 ? __hrtimer_run_queues+0x316/0x740
 ? __usb_hcd_giveback_urb+0x380/0x380
 tasklet_action_common.isra.0+0x135/0x330
 __do_softirq+0x18c/0x634
 irq_exit+0x114/0x140
 smp_apic_timer_interrupt+0xde/0x380
 apic_timer_interrupt+0xf/0x20
 </IRQ>

Reported-by: Brendan Dolan-Gavitt <[email protected]>
Signed-off-by: Zekun Shen <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Sasha Levin <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Aug 24, 2022
Since priv->rx_mapping[i] is maped in moxart_mac_open(), we
should unmap it from moxart_mac_stop(). Fixes 2 warnings.

1. During error unwinding in moxart_mac_probe(): "goto init_fail;",
then moxart_mac_free_memory() calls dma_unmap_single() with
priv->rx_mapping[i] pointers zeroed.

WARNING: CPU: 0 PID: 1 at kernel/dma/debug.c:963 check_unmap+0x704/0x980
DMA-API: moxart-ethernet 92000000.mac: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=1600 bytes]
CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0+ microsoft#60
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x34/0x44
 dump_stack_lvl from __warn+0xbc/0x1f0
 __warn from warn_slowpath_fmt+0x94/0xc8
 warn_slowpath_fmt from check_unmap+0x704/0x980
 check_unmap from debug_dma_unmap_page+0x8c/0x9c
 debug_dma_unmap_page from moxart_mac_free_memory+0x3c/0xa8
 moxart_mac_free_memory from moxart_mac_probe+0x190/0x218
 moxart_mac_probe from platform_probe+0x48/0x88
 platform_probe from really_probe+0xc0/0x2e4

2. After commands:
 ip link set dev eth0 down
 ip link set dev eth0 up

WARNING: CPU: 0 PID: 55 at kernel/dma/debug.c:570 add_dma_entry+0x204/0x2ec
DMA-API: moxart-ethernet 92000000.mac: cacheline tracking EEXIST, overlapping mappings aren't supported
CPU: 0 PID: 55 Comm: ip Not tainted 5.19.0+ #57
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x34/0x44
 dump_stack_lvl from __warn+0xbc/0x1f0
 __warn from warn_slowpath_fmt+0x94/0xc8
 warn_slowpath_fmt from add_dma_entry+0x204/0x2ec
 add_dma_entry from dma_map_page_attrs+0x110/0x328
 dma_map_page_attrs from moxart_mac_open+0x134/0x320
 moxart_mac_open from __dev_open+0x11c/0x1ec
 __dev_open from __dev_change_flags+0x194/0x22c
 __dev_change_flags from dev_change_flags+0x14/0x44
 dev_change_flags from devinet_ioctl+0x6d4/0x93c
 devinet_ioctl from inet_ioctl+0x1ac/0x25c

v1 -> v2:
Extraneous change removed.

Fixes: 6c821bd ("net: Add MOXA ART SoCs ethernet driver")
Signed-off-by: Sergei Antonov <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
sileshn pushed a commit to sileshn/WSL2-Linux-Kernel that referenced this pull request Sep 1, 2022
[ Upstream commit 0ee7828 ]

Since priv->rx_mapping[i] is maped in moxart_mac_open(), we
should unmap it from moxart_mac_stop(). Fixes 2 warnings.

1. During error unwinding in moxart_mac_probe(): "goto init_fail;",
then moxart_mac_free_memory() calls dma_unmap_single() with
priv->rx_mapping[i] pointers zeroed.

WARNING: CPU: 0 PID: 1 at kernel/dma/debug.c:963 check_unmap+0x704/0x980
DMA-API: moxart-ethernet 92000000.mac: device driver tries to free DMA memory it has not allocated [device address=0x0000000000000000] [size=1600 bytes]
CPU: 0 PID: 1 Comm: swapper Not tainted 5.19.0+ microsoft#60
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x34/0x44
 dump_stack_lvl from __warn+0xbc/0x1f0
 __warn from warn_slowpath_fmt+0x94/0xc8
 warn_slowpath_fmt from check_unmap+0x704/0x980
 check_unmap from debug_dma_unmap_page+0x8c/0x9c
 debug_dma_unmap_page from moxart_mac_free_memory+0x3c/0xa8
 moxart_mac_free_memory from moxart_mac_probe+0x190/0x218
 moxart_mac_probe from platform_probe+0x48/0x88
 platform_probe from really_probe+0xc0/0x2e4

2. After commands:
 ip link set dev eth0 down
 ip link set dev eth0 up

WARNING: CPU: 0 PID: 55 at kernel/dma/debug.c:570 add_dma_entry+0x204/0x2ec
DMA-API: moxart-ethernet 92000000.mac: cacheline tracking EEXIST, overlapping mappings aren't supported
CPU: 0 PID: 55 Comm: ip Not tainted 5.19.0+ #57
Hardware name: Generic DT based system
 unwind_backtrace from show_stack+0x10/0x14
 show_stack from dump_stack_lvl+0x34/0x44
 dump_stack_lvl from __warn+0xbc/0x1f0
 __warn from warn_slowpath_fmt+0x94/0xc8
 warn_slowpath_fmt from add_dma_entry+0x204/0x2ec
 add_dma_entry from dma_map_page_attrs+0x110/0x328
 dma_map_page_attrs from moxart_mac_open+0x134/0x320
 moxart_mac_open from __dev_open+0x11c/0x1ec
 __dev_open from __dev_change_flags+0x194/0x22c
 __dev_change_flags from dev_change_flags+0x14/0x44
 dev_change_flags from devinet_ioctl+0x6d4/0x93c
 devinet_ioctl from inet_ioctl+0x1ac/0x25c

v1 -> v2:
Extraneous change removed.

Fixes: 6c821bd ("net: Add MOXA ART SoCs ethernet driver")
Signed-off-by: Sergei Antonov <[email protected]>
Reviewed-by: Andrew Lunn <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Oct 28, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Oct 31, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 1, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 2, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 3, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 7, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 8, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 9, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 10, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 14, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 15, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 16, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 17, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
nathanchance pushed a commit to nathanchance/WSL2-Linux-Kernel that referenced this pull request Nov 18, 2022
WARNING: please, no spaces at the start of a line
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {$

WARNING: suspect code indent for conditional statements (7, 15)
#59: FILE: mm/kmemleak.c:362:
+       for (i = 0; i < nr_entries; i++) {
+               void *ptr = (void *)entries[i];

ERROR: code indent should use tabs where possible
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

WARNING: please, no spaces at the start of a line
microsoft#60: FILE: mm/kmemleak.c:363:
+               void *ptr = (void *)entries[i];$

ERROR: code indent should use tabs where possible
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: Missing a blank line after declarations
#61: FILE: mm/kmemleak.c:364:
+               void *ptr = (void *)entries[i];
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);

WARNING: please, no spaces at the start of a line
#61: FILE: mm/kmemleak.c:364:
+               warn_or_seq_printf(seq, "    [<%p>] %pS\n", ptr, ptr);$

WARNING: please, no spaces at the start of a line
#62: FILE: mm/kmemleak.c:365:
+       }$

ERROR: space required before the open parenthesis '('
#71: FILE: mm/kmemleak.c:384:
+	if(object->trace_handle)

total: 3 errors, 6 warnings, 107 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

NOTE: Whitespace errors detected.
      You may wish to use scripts/cleanpatch or scripts/cleanfile

./patches/mm-use-stack_depot-for-recording-kmemleaks-backtrace.patch has style problems, please review.

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.

Please run checkpatch prior to sending patches

Cc: Catalin Marinas <[email protected]>
Cc: ke.wang <[email protected]>
Cc: Matthew Wilcox (Oracle) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Cc: Zhaoyang Huang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
sileshn pushed a commit to sileshn/WSL2-Linux-Kernel that referenced this pull request Aug 24, 2023
[ Upstream commit 90e5b34 ]

When flushing, individual set elements are disabled in the next
generation via the ->flush callback.

Catchall elements are not disabled.  This is incorrect and may lead to
double-deactivations of catchall elements which then results in memory
leaks:

WARNING: CPU: 1 PID: 3300 at include/net/netfilter/nf_tables.h:1172 nft_map_deactivate+0x549/0x730
CPU: 1 PID: 3300 Comm: nft Not tainted 6.5.0-rc5+ microsoft#60
RIP: 0010:nft_map_deactivate+0x549/0x730
 [..]
 ? nft_map_deactivate+0x549/0x730
 nf_tables_delset+0xb66/0xeb0

(the warn is due to nft_use_dec() detecting underflow).

Fixes: aaa3104 ("netfilter: nftables: add catch-all set element support")
Reported-by: lonial con <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
0wnerDied pushed a commit to 0wnerDied/WSL2-Linux-Kernel that referenced this pull request Aug 25, 2023
[ Upstream commit 90e5b34 ]

When flushing, individual set elements are disabled in the next
generation via the ->flush callback.

Catchall elements are not disabled.  This is incorrect and may lead to
double-deactivations of catchall elements which then results in memory
leaks:

WARNING: CPU: 1 PID: 3300 at include/net/netfilter/nf_tables.h:1172 nft_map_deactivate+0x549/0x730
CPU: 1 PID: 3300 Comm: nft Not tainted 6.5.0-rc5+ microsoft#60
RIP: 0010:nft_map_deactivate+0x549/0x730
 [..]
 ? nft_map_deactivate+0x549/0x730
 nf_tables_delset+0xb66/0xeb0

(the warn is due to nft_use_dec() detecting underflow).

Fixes: aaa3104 ("netfilter: nftables: add catch-all set element support")
Reported-by: lonial con <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
kelsey-steele pushed a commit that referenced this pull request Oct 6, 2023
[ Upstream commit 90e5b34 ]

When flushing, individual set elements are disabled in the next
generation via the ->flush callback.

Catchall elements are not disabled.  This is incorrect and may lead to
double-deactivations of catchall elements which then results in memory
leaks:

WARNING: CPU: 1 PID: 3300 at include/net/netfilter/nf_tables.h:1172 nft_map_deactivate+0x549/0x730
CPU: 1 PID: 3300 Comm: nft Not tainted 6.5.0-rc5+ #60
RIP: 0010:nft_map_deactivate+0x549/0x730
 [..]
 ? nft_map_deactivate+0x549/0x730
 nf_tables_delset+0xb66/0xeb0

(the warn is due to nft_use_dec() detecting underflow).

Fixes: aaa3104 ("netfilter: nftables: add catch-all set element support")
Reported-by: lonial con <[email protected]>
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants