From: sashiko-bot@kernel.org
To: "Mostafa Amin" <mostafa.amin@windriver.com>
Cc: target-devel@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH] configfs: avoid root inode lock in configfs_depend_item_unlocked()
Date: Sat, 05 Dec 2026 02:13:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-250936@kernel.org> (raw)
In-Reply-To: <20261204-fix-krn-2026-0008-v1-1-6dabad0e1a40@windriver.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] configfs: unbounded recursive subsystem scan can overflow
kernel stack
- [Medium] configfs: global spinlock held across full multi-subsystem
DFS on depend
--
commit 6f55b77b8b9ee91025222b4609539b128dd1c300
Author: Mostafa Amin <mostafa.amin@windriver.com>
configfs: avoid root inode lock in configfs_depend_item_unlocked()
This commit removes the configfs root inode lock and target->ci_group
traversal from configfs_depend_item_unlocked(), replacing them with a scan
across caller_subsys and all other subsystems under configfs_dirent_lock.
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index 0c80feec5926b..582c43929c00d 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1223,73 +1223,70 @@ void configfs_undepend_item(struct config_item *target)
[ ... ]
> + spin_lock(&configfs_dirent_lock);
> +
> + if (!(caller_sd->s_type & (CONFIGFS_USET_DROPPING |
> + CONFIGFS_USET_CREATING)))
> + ret = configfs_depend_prep(caller_sd, target);
> +
> + if (ret) {
> + list_for_each_entry(subsys_sd, &root_sd->s_children,
> + s_sibling) {
> + if (subsys_sd == caller_sd)
> + continue;
> + if ((subsys_sd->s_type & CONFIGFS_DIR) &&
> + !(subsys_sd->s_type & (CONFIGFS_USET_DROPPING |
> + CONFIGFS_USET_CREATING))) {
> + ret = configfs_depend_prep(subsys_sd, target);
> + if (!ret)
> + break;
> + }
> + }
> }
[Severity: Medium]
Can scanning every registered subsystem with recursive
configfs_depend_prep() overflow the kernel stack?
Previously only target's subsystem was walked, but now any cross-subsystem
call (or -ENOENT miss) recurses into unrelated subsystems with no depth
limit.
In drivers/hwtracing/stm/policy.c, stp_policy_node_make() creates child
groups whose make_group callback points back to stp_policy_node_make(),
allowing arbitrarily deep directories. Walking a deep tree there overflows
the kernel stack while holding configfs_dirent_lock.
>
> + if (!ret) {
> + p = target->ci_dentry->d_fsdata;
> + p->s_dependent_count += 1;
> + }
>
> - if (target_subsys != caller_subsys)
> -out_root_unlock:
> - /*
> - * We were called from subsystem other than our target so we
> - * took some locks so now it's time to release them
> - */
> - inode_unlock(d_inode(root->cg_item.ci_dentry));
> + spin_unlock(&configfs_dirent_lock);
[Severity: Medium]
Does holding configfs_dirent_lock across the full multi-subsystem walk
introduce a lock-scalability regression?
Previously the spinlock was held only while scanning target's subsystem.
Now a cross-subsystem call like usbg_make_tpg() in f_tcm.c walks all of
caller_sd (the entire LIO target tree) and every preceding subsystem in
root_sd->s_children, visiting all attribute and directory dirents.
Because configfs_dirent_lock is a global spinlock serializing all configfs
lookup, readdir, mkdir, rmdir, and depend operations, holding it across
all mounted subsystems stalls unrelated configfs users and increases
scheduling latency as configfs trees grow.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-fix-krn-2026-0008-v1-1-6dabad0e1a40@windriver.com?part=1
prev parent reply other threads:[~2026-12-05 2:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-05 1:55 [PATCH] configfs: avoid root inode lock in configfs_depend_item_unlocked() Mostafa Amin
2026-12-05 1:55 ` Mostafa Amin via B4 Relay
2026-12-05 2:13 ` sashiko-bot [this message]
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=sashiko-outbox-250936@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mostafa.amin@windriver.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=target-devel@vger.kernel.org \
/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 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.