From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v2 1/2] btrfs: Fix superblock csum type check.
Date: Mon, 27 Apr 2015 12:59:29 +0200 [thread overview]
Message-ID: <20150427105929.GT4996@suse.cz> (raw)
In-Reply-To: <553D8216.8090503@cn.fujitsu.com>
On Mon, Apr 27, 2015 at 08:25:58AM +0800, Qu Wenruo wrote:
>
>
> -------- Original Message --------
> Subject: Re: [PATCH v2 1/2] btrfs: Fix superblock csum type check.
> From: David Sterba <dsterba@suse.cz>
> To: Qu Wenruo <quwenruo@cn.fujitsu.com>
> Date: 2015年04月24日 23:05
>
> > On Fri, Apr 24, 2015 at 09:12:40AM +0800, Qu Wenruo wrote:
> >> --- a/fs/btrfs/ctree.h
> >> +++ b/fs/btrfs/ctree.h
> >> @@ -173,6 +173,7 @@ struct btrfs_ordered_sum;
> >>
> >> /* csum types */
> >> #define BTRFS_CSUM_TYPE_CRC32 0
> >> +#define BTRFS_CSUM_LAST_TYPE 0
> >>
> >> static int btrfs_csum_sizes[] = { 4, 0 };
> >
> > I'd prefer to fix it by removing the 0 from btrfs_csum_sizes instead of
> > introducing a define.
> >
>
> Removing the zero seems not help for this case, as some one can still
> craft a strange csum_type to access outside the array.
The ARRAY_SIZE will be 1, so if a crafted csum will be anything than 0,
then the check will catch it, no?
> So I introduce the new macro and use the new macro to compare with
> csum_type without acess the array.
The macro serves the same purpose as the ARRAY_SIZE macro and is always
in sync with the btrfs_csum_size.
next prev parent reply other threads:[~2015-04-27 10:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 1:12 [PATCH v2 1/2] btrfs: Fix superblock csum type check Qu Wenruo
2015-04-24 1:12 ` [PATCH v2 2/2] btrfs: Add extra check for sub_stripes to avoid hostile 0 division attack Qu Wenruo
2015-04-24 15:05 ` David Sterba
2015-04-24 15:05 ` [PATCH v2 1/2] btrfs: Fix superblock csum type check David Sterba
2015-04-27 0:25 ` Qu Wenruo
2015-04-27 10:59 ` David Sterba [this message]
2015-04-28 0:57 ` Qu Wenruo
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=20150427105929.GT4996@suse.cz \
--to=dsterba@suse.cz \
--cc=linux-btrfs@vger.kernel.org \
--cc=quwenruo@cn.fujitsu.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;
as well as URLs for NNTP newsgroup(s).