All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Beulich <jbeulich@suse.com>
To: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>
Cc: Juergen Gross <jgross@suse.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>, Wei Liu <wl@xen.org>,
	Konrad Wilk <konrad.wilk@oracle.com>,
	George Dunlap <George.Dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Ilja Van Sprundel <ivansprundel@ioactive.com>,
	Ian Jackson <ian.jackson@citrix.com>
Subject: [Xen-devel] [PATCH] console: avoid buffer overflow in guest_console_write()
Date: Fri, 29 Nov 2019 11:13:18 +0100	[thread overview]
Message-ID: <5766dd2b-2aa7-bafe-56ad-3ea33ddf4591@suse.com> (raw)

The switch of guest_console_write()'s second parameter from plain to
unsigned int has caused the function's main loop header to no longer
guard the min_t() use within the function against effectively negative
values, due to the casts hidden inside the macro. Replace by a plain
min(), converting one of the arguments suitably without involving any
cast.

Fixes: ea601ec9995b ("xen/console: Rework HYPERCALL_console_io interface")
Reported-by: Ilja Van Sprundel <ivansprundel@ioactive.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>

--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -538,7 +538,7 @@ static long guest_console_write(XEN_GUES
                 __HYPERVISOR_console_io, "iih",
                 CONSOLEIO_write, count, buffer);
 
-        kcount = min_t(int, count, sizeof(kbuf)-1);
+        kcount = min(count + sizeof(char[0]), sizeof(kbuf) - 1);
         if ( copy_from_guest(kbuf, buffer, kcount) )
             return -EFAULT;
 

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-11-29 10:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-29 10:13 Jan Beulich [this message]
2019-11-29 10:22 ` [Xen-devel] [PATCH] console: avoid buffer overflow in guest_console_write() Andrew Cooper
2019-11-29 10:27   ` Jan Beulich
2019-11-29 12:01     ` Ian Jackson
2019-11-29 12:04       ` Andrew Cooper
2019-11-29 12:13       ` Jan Beulich
2019-11-29 12:15         ` Andrew Cooper
2019-11-29 12:19           ` Jan Beulich
2019-11-29 12:37             ` Andrew Cooper
2019-11-29 13:26               ` Jan Beulich
2019-11-29 13:37                 ` Jürgen Groß
2019-11-29 13:55                   ` Jan Beulich
2019-11-29 13:57                     ` Andrew Cooper
2019-11-29 13:57                     ` Jürgen Groß
2019-11-29 10:39 ` Julien Grall
2019-11-29 11:59 ` Ian Jackson
2019-11-29 12:15   ` Jan Beulich
2019-11-29 12:17     ` Andrew Cooper
2019-11-29 12:02 ` Jürgen Groß
2019-11-29 14:35 ` [Xen-devel] [PATCH XTF] CONSOLEIO_write stack overflow PoC Andrew Cooper
2019-11-29 14:43   ` Jan Beulich
2019-11-29 14:45     ` Jan Beulich
2019-11-29 14:50       ` Andrew Cooper

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=5766dd2b-2aa7-bafe-56ad-3ea33ddf4591@suse.com \
    --to=jbeulich@suse.com \
    --cc=George.Dunlap@eu.citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=ian.jackson@citrix.com \
    --cc=ivansprundel@ioactive.com \
    --cc=jgross@suse.com \
    --cc=julien@xen.org \
    --cc=konrad.wilk@oracle.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.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.