lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 29 Nov 2021 22:23:16 +0800
From:   Nguyen Dinh Phi <phind.uet@...il.com>
To:     m.szyprowski@...sung.com
Cc:     gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
        minchan@...nel.org, tj@...nel.org
Subject: Re: [PATCH] kernfs: switch global kernfs_rwsem lock to per-fs lock

>This patch landed recently in linux-next (20211126) as commit 
>393c3714081a ("kernfs: switch global kernfs_rwsem lock to per-fs lock"). 
>In my tests I've found that it causes the following warning during the 
>system reboot:
>
>  =========================
>  WARNING: held lock freed!
>  5.16.0-rc2+ #10984 Not tainted
>  -------------------------
>  kworker/1:0/18 is freeing memory ffff00004034e200-ffff00004034e3ff, 
>with a lock still held there!
>  ffff00004034e348 (&root->kernfs_rwsem){++++}-{3:3}, at: 
>__kernfs_remove+0x310/0x37c
>  3 locks held by kworker/1:0/18:
>   #0: ffff000040107938 ((wq_completion)cgroup_destroy){+.+.}-{0:0}, at: 
>process_one_work+0x1f0/0x6f0
>   #1: ffff80000b55bdc0 
>((work_completion)(&(&css->destroy_rwork)->work)){+.+.}-{0:0}, at: 
>process_one_work+0x1f0/0x6f0
>   #2: ffff00004034e348 (&root->kernfs_rwsem){++++}-{3:3}, at: 
>__kernfs_remove+0x310/0x37c
>
>  stack backtrace:
>  CPU: 1 PID: 18 Comm: kworker/1:0 Not tainted 5.16.0-rc2+ #10984
>  Hardware name: Raspberry Pi 4 Model B (DT)
>  Workqueue: cgroup_destroy css_free_rwork_fn
>  Call trace:
>   dump_backtrace+0x0/0x1ac
>   show_stack+0x18/0x24
>   dump_stack_lvl+0x8c/0xb8
>   dump_stack+0x18/0x34
>   debug_check_no_locks_freed+0x124/0x140
>   kfree+0xf0/0x3a4
>   kernfs_put+0x1f8/0x224
>   __kernfs_remove+0x1b8/0x37c
>   kernfs_destroy_root+0x38/0x50
>   css_free_rwork_fn+0x288/0x3d4
>   process_one_work+0x288/0x6f0
>   worker_thread+0x74/0x470
>   kthread+0x188/0x194
>   ret_from_fork+0x10/0x20
>
>Let me know if you need more information or help in reproducing this issue.

This patch has a problem, in function kernfs_remove(), it call to 
__kernfs_remove(kn), which will free the related @root of @kn, it means the 
root->kernfs_rwsem will be freed too, but it is still being held by the call 
to down_write(&root->kernfs_rwsem) around line number 100.

BR

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ