Commit 8ca7971e authored by Daniil Dulov's avatar Daniil Dulov Committed by openeuler-sync-bot
Browse files

afs: Increase buffer size in afs_update_volume_status()

ainline inclusion
from mainline-v6.8-rc6
commit 6ea38e2aeb72349cad50e38899b0ba6fbcb2af3d
category: bugfix
bugzilla: https://gitee.com/src-openeuler/kernel/issues/I9E3E9
CVE: CVE-2024-26736

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=6ea38e2aeb72349cad50e38899b0ba6fbcb2af3d



--------------------------------

The max length of volume->vid value is 20 characters.
So increase idbuf[] size up to 24 to avoid overflow.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

[DH: Actually, it's 20 + NUL, so increase it to 24 and use snprintf()]

Fixes: d2ddc776 ("afs: Overhaul volume and server record caching and fileserver rotation")
Signed-off-by: default avatarDaniil Dulov <d.dulov@aladdin.ru>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20240211150442.3416-1-d.dulov@aladdin.ru/ # v1
Link: https://lore.kernel.org/r/20240212083347.10742-1-d.dulov@aladdin.ru/ # v2
Link: https://lore.kernel.org/r/20240219143906.138346-3-dhowells@redhat.com


Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
Signed-off-by: default avatarZhihao Cheng <chengzhihao1@huawei.com>
(cherry picked from commit 9ce3908d)
parent 4acbc73f
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -302,7 +302,7 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key)
{
	struct afs_server_list *new, *old, *discard;
	struct afs_vldb_entry *vldb;
	char idbuf[16];
	char idbuf[24];
	int ret, idsz;

	_enter("");
@@ -310,7 +310,7 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key)
	/* We look up an ID by passing it as a decimal string in the
	 * operation's name parameter.
	 */
	idsz = sprintf(idbuf, "%llu", volume->vid);
	idsz = snprintf(idbuf, sizeof(idbuf), "%llu", volume->vid);

	vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz);
	if (IS_ERR(vldb)) {