From: Jiri Slaby <jirislaby@kernel.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>, Kees Cook <kees@kernel.org>,
Andy Shevchenko <andy@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
Greg KH <gregkh@linuxfoundation.org>
Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
stable@vger.kernel.org
Subject: Re: [PATCH] lib: string_helpers: fix potential snprintf() output truncation
Date: Tue, 22 Oct 2024 09:15:12 +0200 [thread overview]
Message-ID: <bb705eb7-c61c-4da9-816e-cbb46c0c16e4@kernel.org> (raw)
In-Reply-To: <20241021100421.41734-1-brgl@bgdev.pl>
On 21. 10. 24, 12:04, Bartosz Golaszewski wrote:
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> The output of ".%03u" with the unsigned int in range [0, 4294966295] may
> get truncated if the target buffer is not 12 bytes.
Perhaps, if you elaborate on how 'remainder' can become > 999?
> Fixes: 3c9f3681d0b4 ("[SCSI] lib: add generic helper to print sizes rounded to the correct SI range")
> Cc: stable@vger.kernel.org
> Reviewed-by: Andy Shevchenko <andy@kernel.org>
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
> lib/string_helpers.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
> index 4f887aa62fa0..91fa37b5c510 100644
> --- a/lib/string_helpers.c
> +++ b/lib/string_helpers.c
> @@ -57,7 +57,7 @@ int string_get_size(u64 size, u64 blk_size, const enum string_size_units units,
> 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';
--
js
suse labs
next prev parent reply other threads:[~2024-10-22 7:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-21 10:04 [PATCH] lib: string_helpers: fix potential snprintf() output truncation Bartosz Golaszewski
2024-10-21 10:05 ` Bartosz Golaszewski
2024-10-22 7:15 ` Jiri Slaby [this message]
2024-10-22 7:30 ` Bartosz Golaszewski
2024-10-22 9:18 ` Andy Shevchenko
2024-10-22 11:07 ` David Laight
2024-10-22 9:15 ` Andy Shevchenko
2024-10-22 13:46 ` Rasmus Villemoes
2024-10-22 14:30 ` James Bottomley
-- strict thread matches above, loose matches on Subject: below --
2024-10-21 9:14 Bartosz Golaszewski
2024-10-21 9:25 ` Andy Shevchenko
2024-10-21 9:34 ` Greg KH
2024-10-21 9:36 ` Bartosz Golaszewski
2024-10-21 9:50 ` Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bb705eb7-c61c-4da9-816e-cbb46c0c16e4@kernel.org \
--to=jirislaby@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=akpm@linux-foundation.org \
--cc=andy@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=brgl@bgdev.pl \
--cc=gregkh@linuxfoundation.org \
--cc=kees@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox