From: Kent Overstreet <kent.overstreet@gmail.com>
To: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Petr Mladek <pmladek@suse.com>, Jia He <justin.he@arm.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFCv4 3/4] lib/test_printf.c: split write-beyond-buffer check in two
Date: Fri, 17 Jun 2022 12:41:11 -0400 [thread overview]
Message-ID: <1856d213-6119-74f1-f768-6ff05ba8f03b@gmail.com> (raw)
In-Reply-To: <d0798b26-9c77-7209-8c16-0d067ea5720c@rasmusvillemoes.dk>
On 6/17/22 03:15, Rasmus Villemoes wrote:
> On 17/06/2021 16.17, Petr Mladek wrote:
>> On Tue 2021-06-15 23:49:51, Jia He wrote:
>>> From: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>>>
>>> Before each invocation of vsnprintf(), do_test() memsets the entire
>>> allocated buffer to a sentinel value. That buffer includes leading and
>>> trailing padding which is never included in the buffer area handed to
>>> vsnprintf (spaces merely for clarity):
>>>
>>> pad test_buffer pad
>>> **** **************** ****
>>>
>>> Then vsnprintf() is invoked with a bufsize argument <=
>>> BUF_SIZE. Suppose bufsize=10, then we'd have e.g.
>>>
>>> |pad | test_buffer |pad |
>>> **** pizza0 **** ****** ****
>>> A B C D E
>>>
>>> where vsnprintf() was given the area from B to D.
>>>
>>> It is obviously a bug for vsnprintf to touch anything between A and B
>>> or between D and E. The former is checked for as one would expect. But
>>> for the latter, we are actually a little stricter in that we check the
>>> area between C and E.
>>>
>>> Split that check in two, providing a clearer error message in case it
>>> was a genuine buffer overrun and not merely a write within the
>>> provided buffer, but after the end of the generated string.
>>>
>>> So far, no part of the vsnprintf() implementation has had any use for
>>> using the whole buffer as scratch space, but it's not unreasonable to
>>> allow that, as long as the result is properly nul-terminated and the
>>> return value is the right one. However, it is somewhat unusual, and
>>> most %<something> won't need this, so keep the [C,D] check, but make
>>> it easy for a later patch to make that part opt-out for certain tests.
>>
>> Excellent commit message.
>>
>>> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
>>> Tested-by: Jia He <justin.he@arm.com>
>>> Signed-off-by: Jia He <justin.he@arm.com>
>>
>> Reviewed-by: Petr Mladek <pmladek@suse.com>
>
> Hi Petr
>
> It seems Justin's series got stalled, but I still think this patch makes
> sense on its own (especially since another series in flight mucks about
> in this area), so can you please pick it up directly?
>
> The lore link for the above is
> https://lore.kernel.org/lkml/20210615154952.2744-4-justin.he@arm.com/ ,
> while my original submission is at
> https://lore.kernel.org/lkml/20210615085044.1923788-1-linux@rasmusvillemoes.dk/
That patch definitely clarifies things, feel free to add my reviewed-by tag
next prev parent reply other threads:[~2022-06-17 16:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-15 15:49 [PATCH RFCv4 0/4] make '%pD' print full path for file Jia He
2021-06-15 15:49 ` [PATCH RFCv4 1/4] fs: introduce helper d_path_unsafe() Jia He
2021-06-15 20:40 ` Andy Shevchenko
2021-06-16 0:54 ` Justin He
2021-06-15 15:49 ` [PATCH RFCv4 2/4] lib/vsprintf.c: make '%pD' print full path for file Jia He
2021-06-15 20:44 ` Andy Shevchenko
2021-06-17 14:09 ` Petr Mladek
2021-06-22 2:20 ` Justin He
2021-06-15 15:49 ` [PATCH RFCv4 3/4] lib/test_printf.c: split write-beyond-buffer check in two Jia He
2021-06-17 14:17 ` Petr Mladek
2022-06-17 7:15 ` Rasmus Villemoes
2022-06-17 16:41 ` Kent Overstreet [this message]
2022-07-11 13:08 ` Petr Mladek
2021-06-15 15:49 ` [PATCH RFCv4 4/4] lib/test_printf.c: add test cases for '%pD' Jia He
2021-06-15 20:47 ` Andy Shevchenko
2021-06-17 14:52 ` Petr Mladek
2021-06-22 2:21 ` Justin He
2021-06-15 20:42 ` [PATCH RFCv4 0/4] make '%pD' print full path for file Andy Shevchenko
2021-06-16 5:09 ` Christoph Hellwig
2021-06-16 5:16 ` Justin He
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=1856d213-6119-74f1-f768-6ff05ba8f03b@gmail.com \
--to=kent.overstreet@gmail.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=justin.he@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=pmladek@suse.com \
/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
all inboxes | Powered by JetHome®