linux/drivers/xen
Joao Martins 29fee6eed2 xenbus: track caller request id
Commit fd8aa9095a ("xen: optimize xenbus driver for multiple concurrent
xenstore accesses") optimized xenbus concurrent accesses but in doing so
broke UABI of /dev/xen/xenbus. Through /dev/xen/xenbus applications are in
charge of xenbus message exchange with the correct header and body. Now,
after the mentioned commit the replies received by application will no
longer have the header req_id echoed back as it was on request (see
specification below for reference), because that particular field is being
overwritten by kernel.

struct xsd_sockmsg
{
  uint32_t type;  /* XS_??? */
  uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
  uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
  uint32_t len;   /* Length of data following this. */

  /* Generally followed by nul-terminated string(s). */
};

Before there was only one request at a time so req_id could simply be
forwarded back and forth. To allow simultaneous requests we need a
different req_id for each message thus kernel keeps a monotonic increasing
counter for this field and is written on every request irrespective of
userspace value.

Forwarding again the req_id on userspace requests is not a solution because
we would open the possibility of userspace-generated req_id colliding with
kernel ones. So this patch instead takes another route which is to
artificially keep user req_id while keeping the xenbus logic as is. We do
that by saving the original req_id before xs_send(), use the private kernel
counter as req_id and then once reply comes and was validated, we restore
back the original req_id.

Cc: <stable@vger.kernel.org> # 4.11
Fixes: fd8aa9095a ("xen: optimize xenbus driver for multiple concurrent xenstore accesses")
Reported-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
2018-02-17 09:40:33 +01:00
..
events License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xen-pciback License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xenbus xenbus: track caller request id 2018-02-17 09:40:33 +01:00
xenfs License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
acpi.c xen: rename dom0_op to platform_op 2015-12-21 14:40:55 +00:00
arm-device.c Xen: ARM: Zero reserved fields of xatp before making hypervisor call 2017-01-03 10:06:13 -08:00
balloon.c xen/balloon: Mark unallocated host memory as UNUSABLE 2017-12-20 13:16:20 -05:00
biomerge.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
cpu_hotplug.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dbgp.c
efi.c xen: Implement EFI reset_system callback 2017-05-02 12:06:50 +02:00
evtchn.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
fallback.c
features.c xen: audit usages of module.h ; remove unnecessary instances 2016-03-21 15:13:32 +00:00
gntalloc.c mm: treewide: remove GFP_TEMPORARY allocation flag 2017-09-13 18:53:16 -07:00
gntdev.c xen/gntdev: Fix partial gntdev_mmap() cleanup 2018-01-10 08:38:44 -05:00
grant-table.c xen/grant-table: Use put_page instead of free_page 2018-02-06 09:55:37 +01:00
Kconfig xen: XEN_ACPI_PROCESSOR is Dom0-only 2017-12-12 09:39:43 -05:00
Makefile xen: features and fixes for v4.15-rc1 2017-11-16 13:06:27 -08:00
manage.c xen/time: do not decrease steal time after live migration on xen 2017-11-02 16:49:41 -04:00
mcelog.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
pci.c
pcpu.c xen: rename dom0_op to platform_op 2015-12-21 14:40:55 +00:00
platform-pci.c xen-platform: constify pci_device_id. 2017-08-31 09:45:55 -04:00
preempt.c xen/preempt: use need_resched() instead of should_resched() 2015-08-20 12:24:14 +01:00
privcmd.c xen/privcmd: remove unused variable pageidx 2017-11-08 09:15:28 -05:00
privcmd.h
pvcalls-back.c pvcalls-back: do not return error on inet_accept EAGAIN 2018-02-06 15:50:52 +01:00
pvcalls-front.c vfs: do bulk POLL* -> EPOLL* replacement 2018-02-11 14:34:03 -08:00
pvcalls-front.h xen: fix poll misannotation 2018-02-01 10:07:32 -05:00
swiotlb-xen.c dma-mapping: move swiotlb arch helpers to a new header 2018-01-10 16:40:54 +01:00
sys-hypervisor.c xen: add sysfs node for hypervisor build id 2017-06-15 08:50:37 +02:00
time.c xen: features and fixes for v4.15-rc1 2017-11-16 13:06:27 -08:00
tmem.c fs: switch ->s_uuid to uuid_t 2017-06-05 16:59:12 +02:00
xen-acpi-cpuhotplug.c xen: rename dom0_op to platform_op 2015-12-21 14:40:55 +00:00
xen-acpi-memhotplug.c
xen-acpi-pad.c xen: rename dom0_op to platform_op 2015-12-21 14:40:55 +00:00
xen-acpi-processor.c xen/acpi: upload PM state from init-domain to Xen 2017-03-23 12:00:02 -04:00
xen-balloon.c xen: fix booting ballooned down hvm guest 2017-10-26 08:11:44 -04:00
xen-scsiback.c xen/scsiback: Make TMF processing slightly faster 2017-07-06 22:58:03 -07:00
xen-selfballoon.c License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
xen-stub.c
xlate_mmu.c Xen: xlate: Use page_to_xen_pfn instead of page_to_pfn 2016-07-06 10:34:42 +01:00