Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/fs/ptyfs ptyfs: Don't copy out cookies past end of buffer.



details:   https://anonhg.NetBSD.org/src/rev/60c26bde1be9
branches:  trunk
changeset: 368792:60c26bde1be9
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Aug 05 10:36:02 2022 +0000

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

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

diffstat:

 sys/fs/ptyfs/ptyfs_vnops.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r 08505fbd3542 -r 60c26bde1be9 sys/fs/ptyfs/ptyfs_vnops.c
--- a/sys/fs/ptyfs/ptyfs_vnops.c        Fri Aug 05 08:48:36 2022 +0000
+++ b/sys/fs/ptyfs/ptyfs_vnops.c        Fri Aug 05 10:36:02 2022 +0000
@@ -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 @@
                *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;



Home | Main Index | Thread Index | Old Index