All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dima Stepanov <dimastep@yandex-team.ru>
To: qemu-devel@nongnu.org
Cc: wrfsh@yandex-team.ru, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH v1] qemu-pr-helper: garbage response structure can be used to write data
Date: Mon, 2 Jul 2018 11:52:08 +0300	[thread overview]
Message-ID: <20180702085207.GA6032@dimastep-nix> (raw)
In-Reply-To: <1529053904-12607-1-git-send-email-dimastep@yandex-team.ru>

Ping.

On Fri, Jun 15, 2018 at 12:11:44PM +0300, Dima Stepanov wrote:
> The prh_co_entry() routine handles requests. The first part is to read a
> request by calling the prh_read_request() routine, if:
>   1. scsi_cdb_xfer(req->cdb) call returns 0, and
>   2. req->cdb[0] == PERSISTENT_RESERVE_IN, then
> The resp->result field will be uninitialized. As a result the resp.sz
> field will be also uninitialized in the prh_co_entry() function.
> The second part is to send the response by calling the
> prh_write_response() routine:
>   1. For the PERSISTENT_RESERVE_IN command, and
>   2. resp->result == GOOD (previous successful reply or just luck), then
> There is a probability that the following assert will not be trigered:
>   assert(resp->sz <= req->sz && resp->sz <= sizeof(client->data));
> As a result some uninitialized response will be sent.
> 
> The fix is to initialize the response structure to CHECK_CONDITION and 0
> values before calling the prh_read_request() routine.
> 
> Signed-off-by: Dima Stepanov <dimastep@yandex-team.ru>
> ---
>  scsi/qemu-pr-helper.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/scsi/qemu-pr-helper.c b/scsi/qemu-pr-helper.c
> index d0f8317..85878c2 100644
> --- a/scsi/qemu-pr-helper.c
> +++ b/scsi/qemu-pr-helper.c
> @@ -768,6 +768,8 @@ static void coroutine_fn prh_co_entry(void *opaque)
>          PRHelperResponse resp;
>          int sz;
>  
> +        resp.result = CHECK_CONDITION;
> +        resp.sz = 0;
>          sz = prh_read_request(client, &req, &resp, &local_err);
>          if (sz < 0) {
>              break;
> -- 
> 2.7.4
> 
> 

  reply	other threads:[~2018-07-02  8:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-15  9:11 [Qemu-devel] [PATCH v1] qemu-pr-helper: garbage response structure can be used to write data Dima Stepanov
2018-07-02  8:52 ` Dima Stepanov [this message]
2018-07-02 12:21   ` Paolo Bonzini
2018-07-03  9:27     ` Dima Stepanov
2018-07-03  9:35       ` Paolo Bonzini
2018-07-02 10:38 ` Stefan Hajnoczi

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=20180702085207.GA6032@dimastep-nix \
    --to=dimastep@yandex-team.ru \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=wrfsh@yandex-team.ru \
    /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.