public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Dominique Martinet <asmadeus@codewreck.org>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Christian Schoenebeck <linux_oss@crudebyte.com>,
	Sasha Levin <sashal@kernel.org>,
	ericvh@gmail.com, lucho@ionkov.net, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 5.4 15/16] 9p/xen: check logical size for buffer size
Date: Mon, 28 Nov 2022 12:41:58 -0500	[thread overview]
Message-ID: <20221128174201.1442499-15-sashal@kernel.org> (raw)
In-Reply-To: <20221128174201.1442499-1-sashal@kernel.org>

From: Dominique Martinet <asmadeus@codewreck.org>

[ Upstream commit 391c18cf776eb4569ecda1f7794f360fe0a45a26 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/9p/trans_xen.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/net/9p/trans_xen.c b/net/9p/trans_xen.c
index 2779ec1053a0..f043938ae782 100644
--- a/net/9p/trans_xen.c
+++ b/net/9p/trans_xen.c
@@ -230,6 +230,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;
 
@@ -239,6 +247,7 @@ static void p9_xen_response(struct work_struct *work)
 				     masked_prod, &masked_cons,
 				     XEN_9PFS_RING_SIZE);
 
+recv_error:
 		virt_mb();
 		cons += h.size;
 		ring->intf->in_cons = cons;
-- 
2.35.1


  parent reply	other threads:[~2022-11-28 17:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28 17:41 [PATCH AUTOSEL 5.4 01/16] arm64: dts: rockchip: keep I2S1 disabled for GPIO function on ROCK Pi 4 series Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 02/16] arm: dts: rockchip: fix node name for hym8563 rtc Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 03/16] ARM: dts: rockchip: fix ir-receiver node names Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 04/16] ARM: dts: rockchip: rk3188: fix lcdc1-rgb24 node name Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 05/16] ARM: 9251/1: perf: Fix stacktraces for tracepoint events in THUMB2 kernels Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 06/16] ARM: 9266/1: mm: fix no-MMU ZERO_PAGE() implementation Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 07/16] ARM: dts: rockchip: disable arm_global_timer on rk3066 and rk3188 Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 08/16] 9p/fd: Use P9_HDRSZ for header size Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 09/16] regulator: slg51000: Wait after asserting CS pin Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 10/16] ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 11/16] btrfs: send: avoid unaligned encoded writes when attempting to clone range Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 12/16] ASoC: soc-pcm: Add NULL check in BE reparenting Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 13/16] regulator: twl6030: fix get status of twl6032 regulators Sasha Levin
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 14/16] fbcon: Use kzalloc() in fbcon_prepare_logo() Sasha Levin
2022-11-28 17:41 ` Sasha Levin [this message]
2022-11-28 17:41 ` [PATCH AUTOSEL 5.4 16/16] net: usb: qmi_wwan: add u-blox 0x1342 composition Sasha Levin

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=20221128174201.1442499-15-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=asmadeus@codewreck.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=ericvh@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux_oss@crudebyte.com \
    --cc=lucho@ionkov.net \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sstabellini@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=v9fs-developer@lists.sourceforge.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox