From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D86D213B797; Tue, 27 Feb 2024 14:25:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043928; cv=none; b=Pque/HEkAWLQIpB8oQWRiGXiSsTzsN9oDBZtoBB/mpBATG2B80x/D6PUXCGx6B/Wrl88IfhwVmtA5UesDACXCYsu4tN4zzsEdEQY9BFPVH8fFTJ9NbxASk3yef4pp8xYzdeLZUvBKibiy84OmsxelgoBvTkHdGROyOnEtg+IQz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043928; c=relaxed/simple; bh=yt6bHw7nWcMtCQPihxV/1uYPw0T5XbXxc3Q4pAHNy1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oNXGfCtHkRxnM6omJVzcZCZ0h8l6SgVWOHiSl3gNnItoDtJq1kWvzAT2KzXFRoX8ZllbmbfrK1BlhdD1OtBf3iyWuIHK7UTdSXetbX4+nbQw+fFt0jnthTaSVb8qVBhqjTd+HsRyNOiugjr45yotZrvr1Cy2PR0ENFCpW6oQPpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=yU0yBBPE; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="yU0yBBPE" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 65129C433F1; Tue, 27 Feb 2024 14:25:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709043928; bh=yt6bHw7nWcMtCQPihxV/1uYPw0T5XbXxc3Q4pAHNy1o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yU0yBBPELGbwdKHGFwg0yUFRla49FS/V/4P1P6giElZigCBk6q7aGYLyICLQs3pCJ wN7d2HJSVrDBfHAqzKBDktuRunM4NN+a6m90QNo7SgBRAQftxqJvSy0EJT1+aVWZia PSQlIJDTChNG9fhCW5nUekVAXSP17VQFaGrKRzMA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Daniil Dulov , David Howells , Christian Brauner , Sasha Levin Subject: [PATCH 5.4 73/84] afs: Increase buffer size in afs_update_volume_status() Date: Tue, 27 Feb 2024 14:27:40 +0100 Message-ID: <20240227131555.244829070@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131552.864701583@linuxfoundation.org> References: <20240227131552.864701583@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Daniil Dulov [ Upstream commit 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: d2ddc776a458 ("afs: Overhaul volume and server record caching and fileserver rotation") Signed-off-by: Daniil Dulov Signed-off-by: David Howells 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: Christian Brauner Signed-off-by: Sasha Levin --- fs/afs/volume.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 4310336b9bb8c..4225bc766d464 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -221,7 +221,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(""); @@ -229,7 +229,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)) { -- 2.43.0