From: Yuichiro Goto <goto@k-tech.co.jp>
To: a.hindborg@kernel.org
Cc: leitao@debian.org, viro@zeniv.linux.org.uk,
linux-kernel@vger.kernel.org, Yuichiro Goto <goto@k-tech.co.jp>,
stable@vger.kernel.org
Subject: [PATCH] configfs: wait for pending RCU callbacks on module exit
Date: Fri, 13 Nov 2026 12:38:33 +0900 [thread overview]
Message-ID: <20261113033833.124797-1-goto@k-tech.co.jp> (raw)
configfs inodes are freed from an RCU callback: destroy_inode() queues
i_callback() with call_rcu(), and i_callback() then calls the
->free_inode() of the super block, configfs_free_inode(). Nothing in
configfs_exit() waits for these callbacks, so the module can go away
while some of them are still pending, and they later jump into freed
module text.
USB gadget hits this easily. libcomposite pins configfs with
simple_pin_fs() when it registers its subsystem and drops the internal
mount on unregister, which frees the root inode. Unloading the modules
right after that, e.g.
modprobe usb_f_rndis
modprobe -r usb_f_rndis
oopses a few seconds later with CONFIG_RCU_LAZY=y, which batches
call_rcu() callbacks for up to 10 seconds:
Unable to handle kernel paging request at virtual address bf17e810 when execute
Internal error: Oops: 80000007 [#1] SMP ARM
Modules linked in: ... [last unloaded: configfs]
CPU: 0 UID: 0 PID: 16 Comm: rcuos/0 Not tainted 6.18.63 #4 VOLUNTARY
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
PC is at 0xbf17e810
LR is at rcu_do_batch+0x190/0x510
...
Call trace:
rcu_do_batch from rcu_nocb_cb_kthread+0xc8/0x310
rcu_nocb_cb_kthread from kthread+0xe8/0x248
kthread from ret_from_fork+0x14/0x28
RCU_LAZY only widens the window. The same oops also happens on a
v5.4-based kernel, which has no RCU_LAZY, with the same two commands.
Call rcu_barrier() in configfs_exit() once the file system is
unregistered, so that no new inodes can be created and all pending
configfs_free_inode() calls have finished before the module is freed.
Fixes: e9c03af21cc7 ("configfs: calculate the symlink target only once")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Yuichiro Goto <goto@k-tech.co.jp>
---
fs/configfs/mount.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index d8cac1cbf3bd..c65d8ff419b2 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -164,6 +164,8 @@ static void __exit configfs_exit(void)
{
unregister_filesystem(&configfs_fs_type);
sysfs_remove_mount_point(kernel_kobj, "config");
+ /* Pending RCU callbacks may still call configfs_free_inode() */
+ rcu_barrier();
kmem_cache_destroy(configfs_dir_cachep);
configfs_dir_cachep = NULL;
}
--
2.47.3
next reply other threads:[~2026-11-13 3:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 3:38 Yuichiro Goto [this message]
2026-11-13 11:33 ` Breno Leitao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261113033833.124797-1-goto@k-tech.co.jp \
--to=goto@k-tech.co.jp \
--cc=a.hindborg@kernel.org \
--cc=leitao@debian.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®