Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fix NULL deref. The original code before Jaromir's ...



details:   https://anonhg.NetBSD.org/src/rev/b3877e7812d4
branches:  trunk
changeset: 973273:b3877e7812d4
user:      maxv <maxv%NetBSD.org@localhost>
date:      Thu Jun 25 16:19:07 2020 +0000

description:
Fix NULL deref. The original code before Jaromir's cleanup had an #ifndef
block that wrongly contained the 'else' statement, causing the NULL check
to have no effect.

Reported-by: syzbot+c41bbfe5a7ff07bf0f99%syzkaller.appspotmail.com@localhost

diffstat:

 sys/kern/sys_pipe.c |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (28 lines):

diff -r d7a688c1b3de -r b3877e7812d4 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Thu Jun 25 16:16:48 2020 +0000
+++ b/sys/kern/sys_pipe.c       Thu Jun 25 16:19:07 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.149 2020/06/25 14:22:18 jdolecek Exp $  */
+/*     $NetBSD: sys_pipe.c,v 1.150 2020/06/25 16:19:07 maxv Exp $      */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.149 2020/06/25 14:22:18 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.150 2020/06/25 16:19:07 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -778,7 +778,8 @@
                pipe = pipe->pipe_peer;
                if (pipe == NULL)
                        *(int *)data = 0;
-               *(int *)data = pipe->pipe_buffer.cnt;
+               else
+                       *(int *)data = pipe->pipe_buffer.cnt;
                mutex_exit(lock);
                return (0);
 



Home | Main Index | Thread Index | Old Index