From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, mreitz@redhat.com, berrange@redhat.com,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 4/6] luks: Turn invalid assertion into check
Date: Fri, 9 Mar 2018 22:55:12 +0100 [thread overview]
Message-ID: <20180309215512.GA8198@localhost.localdomain> (raw)
In-Reply-To: <07d06226-dd95-268f-fcba-f7245ee68683@redhat.com>
Am 09.03.2018 um 21:19 hat Eric Blake geschrieben:
> On 03/09/2018 11:27 AM, Kevin Wolf wrote:
> > The .bdrv_getlength implementation of the crypto block driver asserted
> > that the payload offset isn't after EOF. This is an invalid assertion to
> > make as the image file could be corrupted. Instead, check it and return
> > -EIO if the file is too small for the payload offset.
>
> Good catch. Probably not a CVE (unless someone can argue some way that
> causing a crash on an attempt to load a maliciously corrupted file can be
> used as a denial of service across a privilege boundary), but definitely
> needs fixing.
>
> >
> > Zero length images are fine, so trigger -EIO only on offset > len, not
> > on offset >= len as the assertion did before.
> >
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> > block/crypto.c | 5 ++++-
> > 1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/block/crypto.c b/block/crypto.c
> > index 2035f9ab13..4908d8627f 100644
> > --- a/block/crypto.c
> > +++ b/block/crypto.c
> > @@ -518,7 +518,10 @@ static int64_t block_crypto_getlength(BlockDriverState *bs)
> > uint64_t offset = qcrypto_block_get_payload_offset(crypto->block);
> > assert(offset < INT64_MAX);
>
> Umm, if the file can be corrupted, what's to prevent someone from sticking
> in a negative size that fails this assertion?
In qcrypto_block_luks_open():
block->sector_size = QCRYPTO_BLOCK_LUKS_SECTOR_SIZE;
block->payload_offset = luks->header.payload_offset *
block->sector_size
The sector size is 512LL, and luks->header.payload_offset is 32 bit.
But I just saw that block_crypto_truncate() has another wrong assertion.
Maybe I should fix that and write a test case for it. Not sure if I'll
add it to this series or as a follow-up during the freeze.
Kevin
next prev parent reply other threads:[~2018-03-09 21:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-09 17:27 [Qemu-devel] [PATCH 0/6] luks: Implement .bdrv_co_create Kevin Wolf
2018-03-09 17:27 ` [Qemu-devel] [PATCH 1/6] luks: Separate image file creation from formatting Kevin Wolf
2018-03-09 19:40 ` Eric Blake
2018-03-12 11:35 ` Daniel P. Berrangé
2018-03-12 11:43 ` Kevin Wolf
2018-03-12 11:46 ` Daniel P. Berrangé
2018-03-09 17:27 ` [Qemu-devel] [PATCH 2/6] luks: Create block_crypto_co_create_generic() Kevin Wolf
2018-03-09 20:06 ` Eric Blake
2018-03-12 11:48 ` Daniel P. Berrangé
2018-03-09 17:27 ` [Qemu-devel] [PATCH 3/6] luks: Support .bdrv_co_create Kevin Wolf
2018-03-09 20:15 ` Eric Blake
2018-03-12 11:40 ` Daniel P. Berrangé
2018-03-12 11:47 ` Kevin Wolf
2018-03-12 11:50 ` Daniel P. Berrangé
2018-03-12 12:14 ` Kevin Wolf
2018-03-12 13:07 ` Eric Blake
2018-03-09 17:27 ` [Qemu-devel] [PATCH 4/6] luks: Turn invalid assertion into check Kevin Wolf
2018-03-09 20:19 ` Eric Blake
2018-03-09 21:55 ` Kevin Wolf [this message]
2018-03-12 11:41 ` Daniel P. Berrangé
2018-03-09 17:27 ` [Qemu-devel] [PATCH 5/6] luks: Catch integer overflow for huge sizes Kevin Wolf
2018-03-09 20:21 ` Eric Blake
2018-03-12 11:42 ` Daniel P. Berrangé
2018-03-09 17:27 ` [Qemu-devel] [PATCH 6/6] qemu-iotests: Test luks QMP image creation Kevin Wolf
2018-03-09 20:26 ` Eric Blake
2018-03-12 11:45 ` Daniel P. Berrangé
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=20180309215512.GA8198@localhost.localdomain \
--to=kwolf@redhat.com \
--cc=berrange@redhat.com \
--cc=eblake@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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 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).