summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2022-11-18 22:44:41 +0900
committerDominique Martinet <asmadeus@codewreck.org>2022-11-23 14:01:27 +0900
commit391c18cf776eb4569ecda1f7794f360fe0a45a26 (patch)
tree10a3ffb03e458b1461069ff48257b6f72cfc4836 /net
parent6854fadbeee10891ed74246bdc05031906b6c8cf (diff)
downloadlinux-391c18cf776eb4569ecda1f7794f360fe0a45a26.tar.gz
linux-391c18cf776eb4569ecda1f7794f360fe0a45a26.tar.bz2
linux-391c18cf776eb4569ecda1f7794f360fe0a45a26.zip
9p/xen: check logical size for buffer size
trans_xen did not check the data fits into the buffer before copying from the xen ring, but we probably should. Add a check that just skips the request and return an error to userspace if it did not fit Tested-by: Stefano Stabellini <sstabellini@kernel.org> Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com> Link: https://lkml.kernel.org/r/20221118135542.63400-1-asmadeus@codewreck.org Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'net')
-rw-r--r--net/9p/trans_xen.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index b15c64128c3e..aaa5fd364691 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -208,6 +208,14 @@ static void p9_xen_response(struct work_struct *work)
continue;
}
+ if (h.size > req->rc.capacity) {
+ dev_warn(&priv->dev->dev,
+ "requested packet size too big: %d for tag %d with capacity %zd\n",
+ h.size, h.tag, req->rc.capacity);
+ req->status = REQ_STATUS_ERROR;
+ goto recv_error;
+ }
+
memcpy(&req->rc, &h, sizeof(h));
req->rc.offset = 0;
@@ -217,6 +225,7 @@ static void p9_xen_response(struct work_struct *work)
masked_prod, &masked_cons,
XEN_9PFS_RING_SIZE(ring));
+recv_error:
virt_mb();
cons += h.size;
ring->intf->in_cons = cons;