Module Name:    src
Committed By:   riastradh
Date:           Fri Aug  5 10:36:02 UTC 2022

Modified Files:
        src/sys/fs/ptyfs: ptyfs_vnops.c

Log Message:
ptyfs: Don't copy out cookies past end of buffer.

Reported-by: syzbot+2aae7c4eddc796f91...@syzkaller.appspotmail.com
https://syzkaller.appspot.com/bug?id=5fe24c1da952ac2ea498d745d6479bc6be91a751


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/fs/ptyfs/ptyfs_vnops.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/fs/ptyfs/ptyfs_vnops.c
diff -u src/sys/fs/ptyfs/ptyfs_vnops.c:1.68 src/sys/fs/ptyfs/ptyfs_vnops.c:1.69
--- src/sys/fs/ptyfs/ptyfs_vnops.c:1.68	Wed Dec  8 20:11:54 2021
+++ src/sys/fs/ptyfs/ptyfs_vnops.c	Fri Aug  5 10:36:02 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptyfs_vnops.c,v 1.68 2021/12/08 20:11:54 andvar Exp $	*/
+/*	$NetBSD: ptyfs_vnops.c,v 1.69 2022/08/05 10:36:02 riastradh Exp $	*/
 
 /*
  * Copyright (c) 1993, 1995
@@ -76,7 +76,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.68 2021/12/08 20:11:54 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ptyfs_vnops.c,v 1.69 2022/08/05 10:36:02 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -691,7 +691,7 @@ ptyfs_readdir(void *v)
 		*ap->a_cookies = cookies;
 	}
 
-	for (; i < 2; i++) {
+	for (; i < 2 && uio->uio_resid >= UIO_MX; i++) {
 		/* `.' and/or `..' */
 		dp->d_fileno = PTYFS_FILENO(PTYFSroot, 0);
 		dp->d_namlen = i + 1;

Reply via email to