Skip to content

Commit 6ea38e2

Browse files
Daniil Dulovbrauner
authored andcommitted
afs: Increase buffer size in afs_update_volume_status()
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: d2ddc77 ("afs: Overhaul volume and server record caching and fileserver rotation") Signed-off-by: Daniil Dulov <[email protected]> Signed-off-by: David Howells <[email protected]> Link: https://lore.kernel.org/r/[email protected]/ # v1 Link: https://lore.kernel.org/r/[email protected]/ # v2 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent bfacaf7 commit 6ea38e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/afs/volume.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,15 +353,15 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key)
353353
{
354354
struct afs_server_list *new, *old, *discard;
355355
struct afs_vldb_entry *vldb;
356-
char idbuf[16];
356+
char idbuf[24];
357357
int ret, idsz;
358358

359359
_enter("");
360360

361361
/* We look up an ID by passing it as a decimal string in the
362362
* operation's name parameter.
363363
*/
364-
idsz = sprintf(idbuf, "%llu", volume->vid);
364+
idsz = snprintf(idbuf, sizeof(idbuf), "%llu", volume->vid);
365365

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

0 commit comments

Comments
 (0)