From: Vitaly Kuznetsov <vkuznets@redhat.com>
To: James Bottomley <jbottomley@odin.com>
Cc: "andy.shevchenko\@gmail.com" <andy.shevchenko@gmail.com>,
"ulf.hansson\@linaro.org" <ulf.hansson@linaro.org>,
"linux\@rasmusvillemoes.dk" <linux@rasmusvillemoes.dk>,
"andriy.shevchenko\@linux.intel.com"
<andriy.shevchenko@linux.intel.com>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm\@linux-foundation.org" <akpm@linux-foundation.org>,
"keescook\@chromium.org" <keescook@chromium.org>
Subject: Re: [PATCH v3 2/4] lib/string_helpers.c: protect string_get_size() against blk_size=0
Date: Fri, 30 Oct 2015 11:41:21 +0100 [thread overview]
Message-ID: <87h9l8skoe.fsf@vitty.brq.redhat.com> (raw)
In-Reply-To: <1446176044.25009.17.camel@Odin.com> (James Bottomley's message of "Fri, 30 Oct 2015 03:34:04 +0000")
James Bottomley <jbottomley@odin.com> writes:
> On Fri, 2015-10-30 at 01:32 +0200, Andy Shevchenko wrote:
>> On Fri, Oct 30, 2015 at 1:00 AM, James Bottomley <jbottomley@odin.com> wrote:
>> > On Thu, 2015-10-29 at 17:30 +0100, Vitaly Kuznetsov wrote:
>> >> Division by zero happens if blk_size=0 is supplied to string_get_size().
>> >> Add WARN_ON() and set size to 0 to report '0 B'.
>> >>
>> >> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
>> >> ---
>> >> lib/string_helpers.c | 5 +++++
>> >> 1 file changed, 5 insertions(+)
>> >>
>> >> diff --git a/lib/string_helpers.c b/lib/string_helpers.c
>> >> index f6c27dc..ff3575b 100644
>> >> --- a/lib/string_helpers.c
>> >> +++ b/lib/string_helpers.c
>> >> @@ -50,6 +50,11 @@ void string_get_size(u64 size, u32 blk_size, const enum string_size_units units,
>> >>
>> >> tmp[0] = '\0';
>> >> i = 0;
>> >> +
>> >> + /* Calling string_get_size() with blk_size=0 is wrong! */
>> >> + if (WARN_ON(!blk_size))
>> >
>> > Get rid of the WARN_ON; it's the standard thing to do for a partially
>> > connected device. Seeing zero is standard in a whole variety of
>> > situations. SCSI shims the zero but most other drivers don't.
>>
>> For *block* size? It will crash the kernel. I've checked, it wasn't
>> changed from the beginning (b9f28d863594).
>
> The standard signal for a drive error in capacity is zero size and zero
> block size. We have to take that case as standard without emitting
> scary warnings.
Ok, but what if size != 0? Is WARN_ON() justified in this case?
--
Vitaly
next prev parent reply other threads:[~2015-10-30 10:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-29 16:30 [PATCH v3 0/4] lib/string_helpers: fix precision issues and introduce tests Vitaly Kuznetsov
2015-10-29 16:30 ` [PATCH v3 1/4] lib/string_helpers: change blk_size to u32 for string_get_size() interface Vitaly Kuznetsov
2015-10-29 22:27 ` James Bottomley
2015-10-29 23:19 ` Rasmus Villemoes
2015-10-29 23:24 ` Rasmus Villemoes
2015-10-30 3:33 ` James Bottomley
2015-10-30 10:46 ` Vitaly Kuznetsov
2015-10-31 0:21 ` James Bottomley
2015-11-02 15:58 ` Vitaly Kuznetsov
2015-11-03 3:40 ` James Bottomley
2015-11-03 13:13 ` Vitaly Kuznetsov
2015-11-03 17:02 ` James Bottomley
2015-11-03 20:57 ` Rasmus Villemoes
2015-11-03 21:19 ` James Bottomley
2015-10-29 16:30 ` [PATCH v3 2/4] lib/string_helpers.c: protect string_get_size() against blk_size=0 Vitaly Kuznetsov
2015-10-29 21:24 ` Andy Shevchenko
2015-10-29 23:00 ` James Bottomley
2015-10-29 23:32 ` Andy Shevchenko
2015-10-30 3:34 ` James Bottomley
2015-10-30 10:41 ` Vitaly Kuznetsov [this message]
2015-10-31 0:07 ` James Bottomley
2015-10-29 16:30 ` [PATCH v3 3/4] lib/string_helpers.c: don't lose precision in string_get_size() Vitaly Kuznetsov
2015-10-29 21:22 ` Andy Shevchenko
2015-10-29 16:30 ` [PATCH v3 4/4] lib/test-string_helpers.c: add string_get_size() tests Vitaly Kuznetsov
2015-10-29 21:33 ` Andy Shevchenko
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=87h9l8skoe.fsf@vitty.brq.redhat.com \
--to=vkuznets@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=jbottomley@odin.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.