From: Josef Bacik <josef@redhat.com>
To: Sergei Trofimovich <slyich@gmail.com>
Cc: chris.mason@oracle.com, linux-btrfs@vger.kernel.org,
cwillu <cwillu@cwillu.com>
Subject: Re: [PATCH v2] Re: btrfs does not work on usermode linux
Date: Mon, 11 Apr 2011 11:37:57 -0400 [thread overview]
Message-ID: <4DA32055.2030104@redhat.com> (raw)
In-Reply-To: <20110410235846.135e801e@sf>
On 04/10/2011 04:58 PM, Sergei Trofimovich wrote:
> On Sun, 10 Apr 2011 23:24:03 +0300
> Sergei Trofimovich<slyich@gmail.com> wrote:
>
>> Fix data corruption caused by memcpy() usage on overlapping data.
>> I've observed it first when found out usermode linux crash on btrfs.
>
> Changes since v1:
>
>> else
>> src_kaddr = dst_kaddr;
>>
>> + BUG_ON(abs(src_off - dst_off)< len);
>> memcpy(dst_kaddr + dst_off, src_kaddr + src_off, len);
>
> Too eager BUG_ON. Now used only for src_page == dst_page.
>
>> - if (dst_offset< src_offset) {
>> + if (abs(dst_offset - src_offset)>= len) {
>
> abs() is not a good thing to use un unsigned values. aded helper overlapping_areas.
>
Very nice catch, one nit
if (dst_page != src_page)
src_kaddr = kmap_atomic(src_page, KM_USER1);
else
+ {
src_kaddr = dst_kaddr;
+ BUG_ON(areas_overlap(src_off, dst_off, len));
+ }
you will want to turn that into
if (dst_page != src_page) {
src_kaddr = kmap_atomic(src_page, KM_USER1);
} else {
src_kaddr = dst_kaddr;
BUG_ON(areas_overlap(src_off, dst_off, len));
}
Also maybe BUG_ON() is a little strong, since the kernel will do this
right, it just screws up UML. So maybe just do a WARN_ON() so we notice
it. Thanks,
Josef
next prev parent reply other threads:[~2011-04-11 15:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-10 10:37 btrfs does not work on usermode linux Sergei Trofimovich
2011-04-10 15:42 ` Sergei Trofimovich
2011-04-10 20:06 ` Sergei Trofimovich
2011-04-10 20:24 ` [PATCH] " Sergei Trofimovich
2011-04-10 20:58 ` [PATCH v2] " Sergei Trofimovich
2011-04-11 15:37 ` Josef Bacik [this message]
2011-04-11 19:44 ` [PATCH v3] " Sergei Trofimovich
2011-04-11 19:49 ` Niklas Schnelle
2011-04-11 19:50 ` Josef Bacik
2011-04-12 21:23 ` Sergei Trofimovich
2011-04-13 11:32 ` Chris Mason
2011-04-13 20:12 ` Sergei Trofimovich
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=4DA32055.2030104@redhat.com \
--to=josef@redhat.com \
--cc=chris.mason@oracle.com \
--cc=cwillu@cwillu.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=slyich@gmail.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 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.