• Joao Martins's avatar
    xenbus: track caller request id · 0f0fd007
    Joao Martins authored
    commit 29fee6ee upstream.
    
    Commit fd8aa909 ("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: fd8aa909 ("xen: optimize xenbus driver for multiple concurrent xenstore accesses")
    Reported-by: 's avatarBhavesh Davda <bhavesh.davda@oracle.com>
    Signed-off-by: 's avatarJoao Martins <joao.m.martins@oracle.com>
    Reviewed-by: 's avatarJuergen Gross <jgross@suse.com>
    Signed-off-by: 's avatarJuergen Gross <jgross@suse.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    0f0fd007
Name
Last commit
Last update
..
events Loading commit data...
xen-pciback Loading commit data...
xenbus Loading commit data...
xenfs Loading commit data...
Kconfig Loading commit data...
Makefile Loading commit data...
acpi.c Loading commit data...
arm-device.c Loading commit data...
balloon.c Loading commit data...
biomerge.c Loading commit data...
cpu_hotplug.c Loading commit data...
dbgp.c Loading commit data...
efi.c Loading commit data...
evtchn.c Loading commit data...
fallback.c Loading commit data...
features.c Loading commit data...
gntalloc.c Loading commit data...
gntdev.c Loading commit data...
grant-table.c Loading commit data...
manage.c Loading commit data...
mcelog.c Loading commit data...
pci.c Loading commit data...
pcpu.c Loading commit data...
platform-pci.c Loading commit data...
preempt.c Loading commit data...
privcmd.c Loading commit data...
privcmd.h Loading commit data...
pvcalls-back.c Loading commit data...
swiotlb-xen.c Loading commit data...
sys-hypervisor.c Loading commit data...
time.c Loading commit data...
tmem.c Loading commit data...
xen-acpi-cpuhotplug.c Loading commit data...
xen-acpi-memhotplug.c Loading commit data...
xen-acpi-pad.c Loading commit data...
xen-acpi-processor.c Loading commit data...
xen-balloon.c Loading commit data...
xen-scsiback.c Loading commit data...
xen-selfballoon.c Loading commit data...
xen-stub.c Loading commit data...
xlate_mmu.c Loading commit data...