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 B055D145A16; Fri, 6 Dec 2024 15:18:40 +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=1733498320; cv=none; b=RCkMWpwquRG2I/Ad0ND7K50NXlLci2Dpd/yTuv3TAfoJLhTmWpYKNMbMMdOVTSyg4I9RYRwJeEF3FEGppMza00E967HKVkJZASdsaG76EViMZnnVwFR4/JF5PLgeJgceVzjSdpSlvV0RtNTLOrfZDvkBnLGhc1W2GO8jbRvTjA0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733498320; c=relaxed/simple; bh=A76Hlmj+OTCrSzqxlXwoWqF5wNEX0hIX/eE02ow2z1c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XAuVFUmmN2tYyjzeMkc/i3mu4OnzJFch9EnAjfdlr4LGfQmhLvvM9PLiIQZeHxS671K8P1+F2/DXPkqu2quK5eyjfE5LxFfEpXJSMJoGhR8LKo0SP1/NpnHzE5UTCGYm3xa9ddyos2FiAB/oxLsqSqHUIW+liV/P3nOlmgNrEi0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=K3O6UPc9; 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="K3O6UPc9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 317E4C4CED1; Fri, 6 Dec 2024 15:18:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1733498320; bh=A76Hlmj+OTCrSzqxlXwoWqF5wNEX0hIX/eE02ow2z1c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K3O6UPc9o5B0ycRAt45/19vSulpwrImIcMBvcOxnFL/JeqbbB5dBLLLTogJQSRHF0 2Rayz6bz74REtqYc/isE3CvOho6Fq1rdX/JpRmBLzXsdyTAX6YIBChMnqIl0I84DPJ 7gWoygptJuz8TSuvQ+A78MYvG6/Rfatuo5lYjRIQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Bartosz Golaszewski , Andy Shevchenko , "James E.J. Bottomley" , Kees Cook , Andrew Morton Subject: [PATCH 6.6 549/676] lib: string_helpers: silence snprintf() output truncation warning Date: Fri, 6 Dec 2024 15:36:08 +0100 Message-ID: <20241206143714.800682751@linuxfoundation.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241206143653.344873888@linuxfoundation.org> References: <20241206143653.344873888@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 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Bartosz Golaszewski commit a508ef4b1dcc82227edc594ffae583874dd425d7 upstream. The output of ".%03u" with the unsigned int in range [0, 4294966295] may get truncated if the target buffer is not 12 bytes. This can't really happen here as the 'remainder' variable cannot exceed 999 but the compiler doesn't know it. To make it happy just increase the buffer to where the warning goes away. Fixes: 3c9f3681d0b4 ("[SCSI] lib: add generic helper to print sizes rounded to the correct SI range") Signed-off-by: Bartosz Golaszewski Reviewed-by: Andy Shevchenko Cc: James E.J. Bottomley Cc: Kees Cook Cc: stable@vger.kernel.org Signed-off-by: Andrew Morton Link: https://lore.kernel.org/r/20241101205453.9353-1-brgl@bgdev.pl Signed-off-by: Kees Cook Signed-off-by: Greg Kroah-Hartman --- lib/string_helpers.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -52,7 +52,7 @@ void string_get_size(u64 size, u64 blk_s static const unsigned int rounding[] = { 500, 50, 5 }; int i = 0, j; u32 remainder = 0, sf_cap; - char tmp[8]; + char tmp[12]; const char *unit; tmp[0] = '\0';