[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230813154934.1067569-9-sashal@kernel.org>
Date: Sun, 13 Aug 2023 11:48:48 -0400
From: Sasha Levin <sashal@...nel.org>
To: linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc: Dominique Martinet <asmadeus@...ewreck.org>,
Simon Horman <simon.horman@...igine.com>,
Eric Van Hensbergen <ericvh@...nel.org>,
Sasha Levin <sashal@...nel.org>, lucho@...kov.net,
davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
pabeni@...hat.com, v9fs@...ts.linux.dev, netdev@...r.kernel.org
Subject: [PATCH AUTOSEL 6.4 09/54] 9p: virtio: fix unlikely null pointer deref in handle_rerror
From: Dominique Martinet <asmadeus@...ewreck.org>
[ Upstream commit 13ade4ac5c28e8a014fa85278f5a4270b215f906 ]
handle_rerror can dereference the pages pointer, but it is not
necessarily set for small payloads.
In practice these should be filtered out by the size check, but
might as well double-check explicitly.
This fixes the following scan-build warnings:
net/9p/trans_virtio.c:401:24: warning: Dereference of null pointer [core.NullDereference]
memcpy_from_page(to, *pages++, offs, n);
^~~~~~~~
net/9p/trans_virtio.c:406:23: warning: Dereference of null pointer (loaded from variable 'pages') [core.NullDereference]
memcpy_from_page(to, *pages, offs, size);
^~~~~~
Reviewed-by: Simon Horman <simon.horman@...igine.com>
Signed-off-by: Dominique Martinet <asmadeus@...ewreck.org>
Signed-off-by: Eric Van Hensbergen <ericvh@...nel.org>
Signed-off-by: Sasha Levin <sashal@...nel.org>
---
net/9p/trans_virtio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c
index 3c27ffb781e3e..2c9495ccda6ba 100644
--- a/net/9p/trans_virtio.c
+++ b/net/9p/trans_virtio.c
@@ -384,7 +384,7 @@ static void handle_rerror(struct p9_req_t *req, int in_hdr_len,
void *to = req->rc.sdata + in_hdr_len;
// Fits entirely into the static data? Nothing to do.
- if (req->rc.size < in_hdr_len)
+ if (req->rc.size < in_hdr_len || !pages)
return;
// Really long error message? Tough, truncate the reply. Might get
--
2.40.1
Powered by blists - more mailing lists