* + binfmt_misc-fix-crash-when-load-unload-module.patch added to -mm tree
@ 2022-01-24 23:19 akpm
0 siblings, 0 replies; 2+ messages in thread
From: akpm @ 2022-01-24 23:19 UTC (permalink / raw)
To: brauner, ebiederm, keescook, mcgrof, mm-commits, yzaikin, ztong0001
The patch titled
Subject: binfmt_misc: fix crash when load/unload module
has been added to the -mm tree. Its filename is
binfmt_misc-fix-crash-when-load-unload-module.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/binfmt_misc-fix-crash-when-load-unload-module.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/binfmt_misc-fix-crash-when-load-unload-module.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Tong Zhang <ztong0001@gmail.com>
Subject: binfmt_misc: fix crash when load/unload module
We should unregister the table upon module unload otherwise something
horrible will happen when we load binfmt_misc module again. Also note
that we should keep value returned by register_sysctl_mount_point() and
release it later, otherwise it will leak.
Also, per Christian's comment, to fully restore the old behavior that
won't break userspace the check(binfmt_misc_header) should be eliminated.
reproduce:
modprobe binfmt_misc
modprobe -r binfmt_misc
modprobe binfmt_misc
modprobe -r binfmt_misc
modprobe binfmt_misc
[ 18.032038] Call Trace:
[ 18.032108] <TASK>
[ 18.032169] dump_stack_lvl+0x34/0x44
[ 18.032273] __register_sysctl_table+0x6f4/0x720
[ 18.032397] ? preempt_count_sub+0xf/0xb0
[ 18.032508] ? 0xffffffffc0040000
[ 18.032600] init_misc_binfmt+0x2d/0x1000 [binfmt_misc]
[ 18.042520] binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
modprobe: can't load module binfmt_misc (kernel/fs/binfmt_misc.ko): Cannot allocate memory
[ 18.063549] binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
[ 18.204779] BUG: unable to handle page fault for address: fffffbfff8004802
Link: https://lkml.kernel.org/r/20220124181812.1869535-2-ztong0001@gmail.com
Fixes: 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file")
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Co-developed-by: Christian Brauner<brauner@kernel.org>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Iurii Zaikin <yzaikin@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/binfmt_misc.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/fs/binfmt_misc.c~binfmt_misc-fix-crash-when-load-unload-module
+++ a/fs/binfmt_misc.c
@@ -817,20 +817,20 @@ static struct file_system_type bm_fs_typ
};
MODULE_ALIAS_FS("binfmt_misc");
+static struct ctl_table_header *binfmt_misc_header;
+
static int __init init_misc_binfmt(void)
{
int err = register_filesystem(&bm_fs_type);
if (!err)
insert_binfmt(&misc_format);
- if (!register_sysctl_mount_point("fs/binfmt_misc")) {
- pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
- return -ENOMEM;
- }
+ binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
return 0;
}
static void __exit exit_misc_binfmt(void)
{
+ unregister_sysctl_table(binfmt_misc_header);
unregister_binfmt(&misc_format);
unregister_filesystem(&bm_fs_type);
}
_
Patches currently in -mm which might be from ztong0001@gmail.com are
binfmt_misc-fix-crash-when-load-unload-module.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
* + binfmt_misc-fix-crash-when-load-unload-module.patch added to -mm tree
@ 2022-01-24 2:43 akpm
0 siblings, 0 replies; 2+ messages in thread
From: akpm @ 2022-01-24 2:43 UTC (permalink / raw)
To: ebiederm, keescook, mcgrof, mm-commits, viro, ztong0001
The patch titled
Subject: binfmt_misc: fix crash when load/unload module
has been added to the -mm tree. Its filename is
binfmt_misc-fix-crash-when-load-unload-module.patch
This patch should soon appear at
https://ozlabs.org/~akpm/mmots/broken-out/binfmt_misc-fix-crash-when-load-unload-module.patch
and later at
https://ozlabs.org/~akpm/mmotm/broken-out/binfmt_misc-fix-crash-when-load-unload-module.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next and is updated
there every 3-4 working days
------------------------------------------------------
From: Tong Zhang <ztong0001@gmail.com>
Subject: binfmt_misc: fix crash when load/unload module
We should unregister the table upon module unload otherwise something
horrible will happen when we load binfmt_misc module again. Also note
that we should keep value returned by register_sysctl_mount_point() and
release it later, otherwise it will leak.
reproduce:
modprobe binfmt_misc
modprobe -r binfmt_misc
modprobe binfmt_misc
modprobe -r binfmt_misc
modprobe binfmt_misc
[ 18.032038] Call Trace:
[ 18.032108] <TASK>
[ 18.032169] dump_stack_lvl+0x34/0x44
[ 18.032273] __register_sysctl_table+0x6f4/0x720
[ 18.032397] ? preempt_count_sub+0xf/0xb0
[ 18.032508] ? 0xffffffffc0040000
[ 18.032600] init_misc_binfmt+0x2d/0x1000 [binfmt_misc]
[ 18.042520] binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
modprobe: can't load module binfmt_misc (kernel/fs/binfmt_misc.ko): Cannot allocate memory
[ 18.063549] binfmt_misc: Failed to create fs/binfmt_misc sysctl mount point
[ 18.204779] BUG: unable to handle page fault for address: fffffbfff8004802
Link: https://lkml.kernel.org/r/20220124003342.1457437-1-ztong0001@gmail.com
Fixes: 3ba442d5331f ("fs: move binfmt_misc sysctl to its own file")
Signed-off-by: Tong Zhang <ztong0001@gmail.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Eric Biederman <ebiederm@xmission.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
fs/binfmt_misc.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
--- a/fs/binfmt_misc.c~binfmt_misc-fix-crash-when-load-unload-module
+++ a/fs/binfmt_misc.c
@@ -817,12 +817,16 @@ static struct file_system_type bm_fs_typ
};
MODULE_ALIAS_FS("binfmt_misc");
+static struct ctl_table_header *binfmt_misc_header;
+
static int __init init_misc_binfmt(void)
{
int err = register_filesystem(&bm_fs_type);
if (!err)
insert_binfmt(&misc_format);
- if (!register_sysctl_mount_point("fs/binfmt_misc")) {
+
+ binfmt_misc_header = register_sysctl_mount_point("fs/binfmt_misc");
+ if (!binfmt_misc_header) {
pr_warn("Failed to create fs/binfmt_misc sysctl mount point");
return -ENOMEM;
}
@@ -831,6 +835,7 @@ static int __init init_misc_binfmt(void)
static void __exit exit_misc_binfmt(void)
{
+ unregister_sysctl_table(binfmt_misc_header);
unregister_binfmt(&misc_format);
unregister_filesystem(&bm_fs_type);
}
_
Patches currently in -mm which might be from ztong0001@gmail.com are
binfmt_misc-fix-crash-when-load-unload-module.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-25 4:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 23:19 + binfmt_misc-fix-crash-when-load-unload-module.patch added to -mm tree akpm
-- strict thread matches above, loose matches on Subject: below --
2022-01-24 2:43 akpm
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.