Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Also check for MT_CONTROL, and end the receive oper...



details:   https://anonhg.NetBSD.org/src/rev/10d842edde36
branches:  trunk
changeset: 997915:10d842edde36
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Mar 31 19:54:36 2019 +0000

description:
Also check for MT_CONTROL, and end the receive operation if we see one. It
is possible to get an MT_CONTROL if we sleep in MSG_WAITALL. The other BSDs
do the same.

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

diffstat:

 sys/kern/uipc_socket.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (41 lines):

diff -r 798fb70e73f3 -r 10d842edde36 sys/kern/uipc_socket.c
--- a/sys/kern/uipc_socket.c    Sun Mar 31 16:14:48 2019 +0000
+++ b/sys/kern/uipc_socket.c    Sun Mar 31 19:54:36 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uipc_socket.c,v 1.271 2019/03/07 12:29:14 maxv Exp $   */
+/*     $NetBSD: uipc_socket.c,v 1.272 2019/03/31 19:54:36 maxv Exp $   */
 
 /*
  * Copyright (c) 2002, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.271 2019/03/07 12:29:14 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uipc_socket.c,v 1.272 2019/03/31 19:54:36 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -1415,15 +1415,21 @@
        moff = 0;
        offset = 0;
        while (m != NULL && uio->uio_resid > 0 && error == 0) {
+               /*
+                * If the type of mbuf has changed, end the receive
+                * operation and do a short read.
+                */
                if (m->m_type == MT_OOBDATA) {
                        if (type != MT_OOBDATA)
                                break;
                } else if (type == MT_OOBDATA) {
                        break;
+               } else if (m->m_type == MT_CONTROL) {
+                       break;
                }
 #ifdef DIAGNOSTIC
                else if (m->m_type != MT_DATA && m->m_type != MT_HEADER) {
-                       panic("receive 3");
+                       panic("%s: m_type=%d", __func__, m->m_type);
                }
 #endif
 



Home | Main Index | Thread Index | Old Index