[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [qemu-xen-traditional stable-4.6] xen: fix ioreq handling
commit 470c00e3b6982cef06a491f7991f2021c7be00c7 Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Tue Nov 29 16:36:38 2016 +0000 Commit: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx> CommitDate: Tue Nov 29 18:38:00 2016 +0000 xen: fix ioreq handling Avoid double fetches and bounds check size to avoid overflowing internal variables. This is XSA-197. Reported-by: yanghongke <yanghongke@xxxxxxxxxx> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> (cherry picked from commit 89c4cbe8d234049b0145e4dc5e5d19d626250b57) (cherry picked from commit 02a1797276642b9ba4f43c919da49767428877e7) --- i386-dm/helper2.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/i386-dm/helper2.c b/i386-dm/helper2.c index ede3105..a3fdbe3 100644 --- a/i386-dm/helper2.c +++ b/i386-dm/helper2.c @@ -374,6 +374,11 @@ static void cpu_ioreq_pio(CPUState *env, ioreq_t *req) { uint32_t i; + if (req->size > sizeof(unsigned long)) { + fprintf(stderr, "PIO: bad size (%u)\n", req->size); + exit(-1); + } + if (req->dir == IOREQ_READ) { if (!req->data_is_ptr) { req->data = do_inp(env, req->addr, req->size); @@ -403,6 +408,11 @@ static void cpu_ioreq_move(CPUState *env, ioreq_t *req) { uint32_t i; + if (req->size > sizeof(req->data)) { + fprintf(stderr, "MMIO: bad size (%u)\n", req->size); + exit(-1); + } + if (!req->data_is_ptr) { if (req->dir == IOREQ_READ) { for (i = 0; i < req->count; i++) { @@ -515,11 +525,13 @@ static int __handle_buffered_iopage(CPUState *env) req.df = 1; req.type = buf_req->type; req.data_is_ptr = 0; + xen_rmb(); qw = (req.size == 8); if (qw) { buf_req = &buffered_io_page->buf_ioreq[(rdptr + 1) % IOREQ_BUFFER_SLOT_NUM]; req.data |= ((uint64_t)buf_req->data) << 32; + xen_rmb(); } __handle_ioreq(env, &req); @@ -551,7 +563,11 @@ static void cpu_handle_ioreq(void *opaque) __handle_buffered_iopage(env); if (req) { - __handle_ioreq(env, req); + ioreq_t copy = *req; + + xen_rmb(); + __handle_ioreq(env, ©); + req->data = copy.data; if (req->state != STATE_IOREQ_INPROCESS) { fprintf(logfile, "Badness in I/O request ... not in service?!: " -- generated by git-patchbot for /home/xen/git/qemu-xen-traditional.git#stable-4.6 _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |