Commit 84ec758
configfs: fix a race in configfs_{,un}register_subsystem()
When configfs_register_subsystem() or configfs_unregister_subsystem()
is executing link_group() or unlink_group(),
it is possible that two processes add or delete list concurrently.
Some unfortunate interleavings of them can cause kernel panic.
One of cases is:
A --> B --> C --> D
A <-- B <-- C <-- D
delete list_head *B | delete list_head *C
--------------------------------|-----------------------------------
configfs_unregister_subsystem | configfs_unregister_subsystem
unlink_group | unlink_group
unlink_obj | unlink_obj
list_del_init | list_del_init
__list_del_entry | __list_del_entry
__list_del | __list_del
// next == C |
next->prev = prev |
| next->prev = prev
prev->next = next |
| // prev == B
| prev->next = next
Fix this by adding mutex when calling link_group() or unlink_group(),
but parent configfs_subsystem is NULL when config_item is root.
So I create a mutex configfs_subsystem_mutex.
Fixes: 7063fbf ("[PATCH] configfs: User-driven configuration filesystem")
Signed-off-by: ChenXiaoSong <chenxiaosong2@huawei.com>
Signed-off-by: Laibin Qiu <qiulaibin@huawei.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>1 parent 038101e commit 84ec758
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
37 | 45 | | |
38 | 46 | | |
39 | 47 | | |
| |||
1859 | 1867 | | |
1860 | 1868 | | |
1861 | 1869 | | |
| 1870 | + | |
1862 | 1871 | | |
| 1872 | + | |
1863 | 1873 | | |
1864 | 1874 | | |
1865 | 1875 | | |
| |||
1884 | 1894 | | |
1885 | 1895 | | |
1886 | 1896 | | |
| 1897 | + | |
1887 | 1898 | | |
| 1899 | + | |
1888 | 1900 | | |
1889 | 1901 | | |
1890 | 1902 | | |
| |||
1931 | 1943 | | |
1932 | 1944 | | |
1933 | 1945 | | |
| 1946 | + | |
1934 | 1947 | | |
| 1948 | + | |
1935 | 1949 | | |
1936 | 1950 | | |
1937 | 1951 | | |
| |||
0 commit comments