From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796436790; b=TEiRFp055qqPC65Zee4vCgKmywed7WXlRFUpL/nD0JJlMfng/YzFVdmJbAtmroLuXnj1 AfDXqikNpmtWIXUb79Z5IED5JGmx9JQoY+oFoeMsH/G8ft2IJzyxIJfpaxfMHwvZNPvCM +KANXd9Z2+TTnkwsuQyK/T9q1iMbPqLlSgN061MJ9yNWb08qqPUj/ces7twdGjkaJRBOy ZGQJXgDuxTzbwq4ZG4i77/f5TQdSUS1kDcUjpudcD9Xt6RxUVZurYGCHzWwHOsmZ7YNzE dVQVlu7b8O6AzXG3O9K/4smGkKU76NZ+rGslq2Bb1Z2yZkxKykUSEzU8hIxBiVCHi0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796436790; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=oggpT4d94/z0xQdTHB3iaCU0UM0ZAUkTH1QnFIqiVQM=; b=QEFcgi7qMZc0168BeSix4/K5ryUGJuPQ3VnIdRWlo1dtx9DkZIbNuL+In+N9BAIsh7E3 JE/0rbvdrWgIkAn277iE5QEb7Ao8sjCWxRqo+G1zmPRJp56JYv0xU71uIjA4X8n03NxMa xGQG+9LtaT5WfeE2k+KWTRJiRaYpLrNjOVE/qNCqCSSvckyP7hYLJsqHWuFdFYC35Cgpy 9dYO+pBK+46da3INiUCkjIPvZxLn9l9qLdMVmM6E4QGCjqUhj6fAvuj4yUd12sJ83ZQ7F T/yIXp3aJJvA0VCCtd5uaPId0oTS1DKo10H4dQf+KVaYOXdsAZg1zGcbVIMU3qrTaYg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mEafcPmU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8450A606A322; Sat, 5 Dec 2026 02:13:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mEafcPmU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 002A31F0092B; Sat, 5 Dec 2026 02:13:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796436790; bh=oggpT4d94/z0xQdTHB3iaCU0UM0ZAUkTH1QnFIqiVQM=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=mEafcPmUGUgBqyR1BsLALTH4vRmvHydNQaBrUl3Bue0YSodjv9eqgukB7WZXBxXMm +a8hpghI8AO0yQjPasDONLEHeU1Da1PCVW2p1lxMq0UZ7/f4lJdLZfqSYR9PXgTRjC 4rsiO//0WR8PAIZ7bCKrhWgayfSuZFaFB2M+yiT/zCKhMG9RA/og0vu+4vorqDSplu yVO1n5v8kCEop8J/sV0alaiMjuP+ylPqQmYnrPAWZmmWHTv15/LzynR2Rl5IgSzbvc 3OiVI238degF1uTWTdWvykFpBrDd9+U/JqcudryI4ykVIAeIQL+PVlOYjL00Qumma4 o1bNDAg3TAeyg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH] configfs: avoid root inode lock in configfs_depend_item_unlocked() Reply-To: sashiko-reviews@lists.linux.dev To: "Mostafa Amin" Cc: target-devel@vger.kernel.org, linux-usb@vger.kernel.org In-Reply-To: <20261204-fix-krn-2026-0008-v1-1-6dabad0e1a40@windriver.com> References: <20261204-fix-krn-2026-0008-v1-1-6dabad0e1a40@windriver.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sat, 05 Dec 2026 02:13:09 +0000 X-Mailing-List: target-devel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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 *t= arget) [ ... ] > + spin_lock(&configfs_dirent_lock); > + > + if (!(caller_sd->s_type & (CONFIGFS_USET_DROPPING | > + CONFIGFS_USET_CREATING))) > + ret =3D configfs_depend_prep(caller_sd, target); > + > + if (ret) { > + list_for_each_entry(subsys_sd, &root_sd->s_children, > + s_sibling) { > + if (subsys_sd =3D=3D caller_sd) > + continue; > + if ((subsys_sd->s_type & CONFIGFS_DIR) && > + !(subsys_sd->s_type & (CONFIGFS_USET_DROPPING | > + CONFIGFS_USET_CREATING))) { > + ret =3D 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. > =20 > + if (!ret) { > + p =3D target->ci_dentry->d_fsdata; > + p->s_dependent_count +=3D 1; > + } > =20 > - if (target_subsys !=3D 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. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-fix-krn-20= 26-0008-v1-1-6dabad0e1a40@windriver.com?part=3D1