From: Eric Blake <eblake@redhat.com>
To: qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>,
vsementsov@virtuozzo.com, qemu-block@nongnu.org,
xuwei@redhat.com, qemu-stable@nongnu.org,
Max Reitz <mreitz@redhat.com>,
ppandit@redhat.com
Subject: Re: [PATCH v2 2/2] block: Call attention to truncation of long NBD exports
Date: Mon, 15 Jun 2020 15:39:27 -0500 [thread overview]
Message-ID: <9b324e3e-8758-f8d9-7acc-50f118b289b4@redhat.com> (raw)
In-Reply-To: <20200610163741.3745251-3-eblake@redhat.com>
On 6/10/20 11:37 AM, Eric Blake wrote:
> Commit 93676c88 relaxed our NBD client code to request export names up
> to the NBD protocol maximum of 4096 bytes without NUL terminator, even
> though the block layer can't store anything longer than 4096 bytes
> including NUL terminator for display to the user. Since this means
> there are some export names where we have to truncate things, we can
> at least try to make the truncation a bit more obvious for the user.
> Note that in spite of the truncated display name, we can still
> communicate with an NBD server using such a long export name; this was
> deemed nicer than refusing to even connect to such a server (since the
> server may not be under our control, and since determining our actual
> length limits gets tricky when nbd://host:port/export and
> nbd+unix:///export?socket=/path are themselves variable-length
> expansions beyond the export name but count towards the block layer
> name length).
>
> +++ b/block/nbd.c
> } else if (host && !s->export) {
> - snprintf(bs->exact_filename, sizeof(bs->exact_filename),
> - "nbd://%s:%s", host, port);
> + len = snprintf(bs->exact_filename, sizeof(bs->exact_filename),
> + "nbd://%s:%s", host, port);
> + }
> + if (len > sizeof(bs->exact_filename)) {
Max pointed out off-list that this is off-by-one: by not using >=, I am
failing to detect overflow when exactly one byte is truncated.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
prev parent reply other threads:[~2020-06-15 20:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-10 16:37 [PATCH v2 0/2] Fix NBD CVE-2020-10761 Eric Blake
2020-06-10 16:37 ` [PATCH v2 1/2] nbd/server: Avoid long error message assertions CVE-2020-10761 Eric Blake
2020-06-10 17:17 ` Vladimir Sementsov-Ogievskiy
2020-06-15 20:38 ` Eric Blake
2020-06-10 16:37 ` [PATCH v2 2/2] block: Call attention to truncation of long NBD exports Eric Blake
2020-06-15 20:39 ` Eric Blake [this message]
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=9b324e3e-8758-f8d9-7acc-50f118b289b4@redhat.com \
--to=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=ppandit@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.org \
--cc=vsementsov@virtuozzo.com \
--cc=xuwei@redhat.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).