linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: vpe: fix integer overflow in vpe_write()
@ 2022-07-14 14:17 Ning Qiang
  2022-07-14 14:21 ` Dan Carpenter
  2022-07-14 17:34 ` Linus Torvalds
  0 siblings, 2 replies; 3+ messages in thread
From: Ning Qiang @ 2022-07-14 14:17 UTC (permalink / raw)
  To: dan.carpenter, sohu0106; +Cc: greg, security, linux-mips, tsbogend

In the vpe_write function of arch/mips/kernel/vpe.c,parameter "size_t
count" is pass by userland, if "count" is very large, it will bypass
the check of "if ((count + v->len) > v->plen)".(such as
count=0xffffffffffffffff). Then it will lead to buffer overflow in
"copy_from_user(v->pbuffer + v->len, buffer, count)".

Signed-off-by: Ning Qiang <sohu0106@126.com>
---
 arch/mips/kernel/vpe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/mips/kernel/vpe.c b/arch/mips/kernel/vpe.c
index 13294972707b..1529e755200d 100644
--- a/arch/mips/kernel/vpe.c
+++ b/arch/mips/kernel/vpe.c
@@ -849,7 +849,7 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
 	if (v == NULL)
 		return -ENODEV;
 
-	if ((count + v->len) > v->plen) {
+	if ((count + v->len) > v->plen || count + v->len < v->len) {
 		pr_warn("VPE loader: elf size too big. Perhaps strip unneeded symbols\n");
 		return -ENOMEM;
 	}
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-14 17:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 14:17 [PATCH] MIPS: vpe: fix integer overflow in vpe_write() Ning Qiang
2022-07-14 14:21 ` Dan Carpenter
2022-07-14 17:34 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).