]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
9p: fix /sys/fs/9p/caches overwriting itself
authorRandall P. Embry <rpembry@gmail.com>
Fri, 26 Sep 2025 09:27:30 +0000 (18:27 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 13 Nov 2025 20:34:34 +0000 (15:34 -0500)
[ Upstream commit 86db0c32f16c5538ddb740f54669ace8f3a1f3d7 ]

caches_show() overwrote its buffer on each iteration,
so only the last cache tag was visible in sysfs output.

Properly append with snprintf(buf + count, …).

Signed-off-by: Randall P. Embry <rpembry@gmail.com>
Message-ID: <20250926-v9fs_misc-v1-2-a8b3907fc04d@codewreck.org>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/9p/v9fs.c

index 281a1ed03a04162eadb7a2f5bcd44b28728ed81d..e35b30534787dcf3b0c8c5210ebf344e97cb1fac 100644 (file)
@@ -561,7 +561,7 @@ static ssize_t caches_show(struct kobject *kobj,
        spin_lock(&v9fs_sessionlist_lock);
        list_for_each_entry(v9ses, &v9fs_sessionlist, slist) {
                if (v9ses->cachetag) {
-                       n = snprintf(buf, limit, "%s\n", v9ses->cachetag);
+                       n = snprintf(buf + count, limit, "%s\n", v9ses->cachetag);
                        if (n < 0) {
                                count = n;
                                break;