All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix an integer overflow check
Date: Mon, 27 Mar 2017 17:22:17 +0200	[thread overview]
Message-ID: <20170327152217.GG4781@twin.jikos.cz> (raw)
In-Reply-To: <20170317205120.GE16505@mwanda>

On Fri, Mar 17, 2017 at 11:51:20PM +0300, Dan Carpenter wrote:
> This isn't super serious because you need CAP_ADMIN to run this code.
> 
> I added this integer overflow check last year but apparently I am
> rubbish at writing integer overflow checks...  There are two issues.
> First, access_ok() works on unsigned long type and not u64 so on 32 bit
> systems the access_ok() could be checking a truncated size.  The other
> issue is that we should be using a stricter limit so we don't overflow
> the kzalloc() setting ctx->clone_roots later in the function after the
> access_ok():
> 
> 	alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
> 	sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN);
> 
> Fixes: f5ecec3ce21f ("btrfs: send: silence an integer overflow warning")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>

I'll copy parts of the changelog and add as comments, it's not obvious
what the check does.

WARNING: multiple messages have this Message-ID (diff)
From: David Sterba <dsterba@suse.cz>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Chris Mason <clm@fb.com>, Josef Bacik <jbacik@fb.com>,
	David Sterba <dsterba@suse.com>,
	linux-btrfs@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] Btrfs: fix an integer overflow check
Date: Mon, 27 Mar 2017 15:22:17 +0000	[thread overview]
Message-ID: <20170327152217.GG4781@twin.jikos.cz> (raw)
In-Reply-To: <20170317205120.GE16505@mwanda>

On Fri, Mar 17, 2017 at 11:51:20PM +0300, Dan Carpenter wrote:
> This isn't super serious because you need CAP_ADMIN to run this code.
> 
> I added this integer overflow check last year but apparently I am
> rubbish at writing integer overflow checks...  There are two issues.
> First, access_ok() works on unsigned long type and not u64 so on 32 bit
> systems the access_ok() could be checking a truncated size.  The other
> issue is that we should be using a stricter limit so we don't overflow
> the kzalloc() setting ctx->clone_roots later in the function after the
> access_ok():
> 
> 	alloc_size = sizeof(struct clone_root) * (arg->clone_sources_count + 1);
> 	sctx->clone_roots = kzalloc(alloc_size, GFP_KERNEL | __GFP_NOWARN);
> 
> Fixes: f5ecec3ce21f ("btrfs: send: silence an integer overflow warning")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Reviewed-by: David Sterba <dsterba@suse.com>

I'll copy parts of the changelog and add as comments, it's not obvious
what the check does.

  reply	other threads:[~2017-03-27 15:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 20:51 [PATCH] Btrfs: fix an integer overflow check Dan Carpenter
2017-03-17 20:51 ` Dan Carpenter
2017-03-27 15:22 ` David Sterba [this message]
2017-03-27 15:22   ` David Sterba

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=20170327152217.GG4781@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=clm@fb.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dsterba@suse.com \
    --cc=jbacik@fb.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.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.