All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Juergen Gross <jgross@suse.com>, Nicolas Pitre <nico@linaro.org>,
	Andi Kleen <ak@linux.intel.com>, Jan Beulich <jbeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] xen: hypercall: fix out-of-bounds memcpy
Date: Fri, 2 Feb 2018 17:11:02 +0100	[thread overview]
Message-ID: <CAK8P3a0Z2PMP-=e2Ga8kw196vWeAz_HC02ABQmDB9W_0Cmmr-Q@mail.gmail.com> (raw)
In-Reply-To: <20180202155309.2xg2gjcp7wb7bbpe@mwanda>

On Fri, Feb 2, 2018 at 4:53 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> On Fri, Feb 02, 2018 at 04:32:31PM +0100, Arnd Bergmann wrote:

>> --- a/drivers/xen/fallback.c
>> +++ b/drivers/xen/fallback.c
>> @@ -7,75 +7,87 @@
>>
>>  int xen_event_channel_op_compat(int cmd, void *arg)
>>  {
>> -     struct evtchn_op op;
>> +     struct evtchn_op op = { .cmd = cmd, };
>> +     size_t len;
>>       int rc;
>>
>> -     op.cmd = cmd;
>> -     memcpy(&op.u, arg, sizeof(op.u));
>> -     rc = _hypercall1(int, event_channel_op_compat, &op);
>> -
>>       switch (cmd) {
>> +     case EVTCHNOP_bind_interdomain:
>> +             len = sizeof(struct evtchn_bind_interdomain);
>> +             break;
>
> This was in the original code, but I'm slightly surpprised that we're
> using a switch statement here instead of a table.  I would have thought
> this is a fast path but I don't know xen at all.

I thought about using a table, but figured the switch statement
had a lower risk of getting something slightly wrong during the
conversion.

I would expect gcc to turn this into a table lookup, since all the
constants are consecutive, but it should not really matter since
this is only the fallback path for ancient Xen releases. When Xen
guest support was first merged in 2007, it was already
deprecated.

      Arnd

  reply	other threads:[~2018-02-02 16:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 15:32 [PATCH] xen: hypercall: fix out-of-bounds memcpy Arnd Bergmann
2018-02-02 15:53 ` Dan Carpenter
2018-02-02 15:53 ` Dan Carpenter
2018-02-02 16:11   ` Arnd Bergmann [this message]
2018-02-02 16:34     ` Dan Carpenter
2018-02-02 16:34     ` Dan Carpenter
2018-02-02 16:11   ` Arnd Bergmann
2018-02-02 23:33 ` Boris Ostrovsky
2018-02-03 15:12   ` Arnd Bergmann
2018-02-03 15:12   ` Arnd Bergmann
2018-02-03 17:08     ` Boris Ostrovsky
2018-02-04 15:35       ` Arnd Bergmann
2018-02-04 18:55         ` Boris Ostrovsky
2018-02-04 18:55         ` Boris Ostrovsky
2018-02-04 15:35       ` Arnd Bergmann
2018-02-03 17:08     ` Boris Ostrovsky
2018-02-05 12:11   ` David Laight
2018-02-05 12:11   ` David Laight
2018-02-05 12:37     ` Arnd Bergmann
2018-02-05 12:37     ` Arnd Bergmann
2018-02-05 13:58       ` David Laight
2018-02-05 14:18         ` Arnd Bergmann
2018-02-05 14:18         ` Arnd Bergmann
2018-02-05 13:58       ` David Laight
2018-02-02 23:33 ` Boris Ostrovsky
2018-02-02 15:32 Arnd Bergmann

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='CAK8P3a0Z2PMP-=e2Ga8kw196vWeAz_HC02ABQmDB9W_0Cmmr-Q@mail.gmail.com' \
    --to=arnd@arndb.de \
    --cc=ak@linux.intel.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nico@linaro.org \
    --cc=xen-devel@lists.xenproject.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.