All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jes Sorensen <Jes.Sorensen@redhat.com>
To: Adam Goryachev <mailinglists@websitemanagers.com.au>
Cc: Thomas Fjellstrom <thomas@fjellstrom.ca>, linux-raid@vger.kernel.org
Subject: Re: [PATCH] mdadm: replace hard coded string length
Date: Fri, 16 Sep 2016 08:38:34 -0400	[thread overview]
Message-ID: <wrfjlgysqat1.fsf@redhat.com> (raw)
In-Reply-To: <4115566d-9994-b90a-12cb-83e54c01baba@websitemanagers.com.au> (Adam Goryachev's message of "Fri, 16 Sep 2016 09:34:32 +1000")

Adam Goryachev <mailinglists@websitemanagers.com.au> writes:
> On 16/09/16 04:10, Thomas Fjellstrom wrote:
>> On Thursday, September 15, 2016 12:15:30 PM MDT Jes Sorensen wrote:
>>> I was about to apply this, but this is actually wrong. You need to use
>>> the size of the destination, not of the source as the limit.
>>>
>>> Sorry for the hassle.
>> I'm not aware of the full details, but either they are the same size, or they
>> aren't, and you need to use the minimum size of both to avoid any kind of
>> overflow (source or dest, read and write). I presume the destination is
>> smaller?
> I'm not a programmer, but I think the size of the source is
> irrelevant. If the source is 10 bytes, you can safely copy that to a
> destination of 30 bytes. The only problem is if the source content is
> bigger than the destination. Hence, you should copy only based on the
> destination size.
>
> I'm not sure, but it may be a good idea to confirm that all of the
> source content has been copied, or else there may be unexpected
> results when operating on a truncated value.  I'm sure someone else
> who is an actual programmer can jump in and advise...

Technically you are correct. However if we start adding such checks,
there's a full time job running through the code fixing up cases like
these. This for cases where we know it won't go wrong. It would also be
a large amount of patch churn for no gain.

Cheers,
Jes

  reply	other threads:[~2016-09-16 12:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-15  0:13 [PATCH] mdadm: replace hard coded string length Song Liu
2016-09-15 16:15 ` Jes Sorensen
2016-09-15 18:10   ` Thomas Fjellstrom
2016-09-15 23:34     ` Adam Goryachev
2016-09-16 12:38       ` Jes Sorensen [this message]
2016-09-16 12:34     ` Jes Sorensen
2016-09-20 18:03       ` Thomas Fjellstrom

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=wrfjlgysqat1.fsf@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=linux-raid@vger.kernel.org \
    --cc=mailinglists@websitemanagers.com.au \
    --cc=thomas@fjellstrom.ca \
    /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.