From owner-freebsd-bugs@freebsd.org Sun Aug 27 09:37:33 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 143E1DEBAF2 for ; Sun, 27 Aug 2017 09:37:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0244F6C18B for ; Sun, 27 Aug 2017 09:37:33 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v7R9bW5L061767 for ; Sun, 27 Aug 2017 09:37:32 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 221849] Kernel panic, kqueue related NULL pointer dereference sys/kern/kern_event.c Date: Sun, 27 Aug 2017 09:37:33 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 11.1-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: aragon@phat.za.net X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Aug 2017 09:37:33 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D221849 Bug ID: 221849 Summary: Kernel panic, kqueue related NULL pointer dereference sys/kern/kern_event.c Product: Base System Version: 11.1-RELEASE Hardware: amd64 OS: Any Status: New Severity: Affects Only Me Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: aragon@phat.za.net I've stumbled upon a consistently reproducible panic with a GENERIC kernel = on 11.1-RELEASE. For me it happens every time I try connect my Android device= to the L2TP/IPSec (racoon+mpd) server running on the system in question. I do= n't know what's special about the Android VPN client, so I guess this panic mig= ht occur under other conditions too (other VPN clients don't trigger this). kern_kqueue() in sys/kern/kern_event.c:827 gets passed a struct thread poin= ter, and member td_ucred->cr_ruidinfo (null pointer) gets passed to chgkqcnt() in sys/kern/kern_resource.c:1430, which eventually gets dereferenced by atomic_fetchadd_long in sys/amd64/include/atomic.h. Fatal trap 12: page fault while in kernel mode cpuid =3D 1; apic id =3D 01 fault virtual address =3D 0x50 fault code =3D supervisor write data, page not present instruction pointer =3D 0x20:0xffffffff80a65f95 stack pointer =3D 0x28:0xfffffe004f1258c0 frame pointer =3D 0x28:0xfffffe004f1258d0 code segment =3D base 0x0, limit 0xfffff, type 0x1b =3D DPL 0, pres 1, long 1, def32 0, gran 1 processor eflags =3D interrupt enabled, resume, IOPL =3D 0 current process =3D 816 (sshd) trap number =3D 12 panic: page fault cpuid =3D 1 KDB: stack backtrace: #0 0xffffffff80aada97 at kdb_backtrace+0x67 #1 0xffffffff80a6bb76 at vpanic+0x186 #2 0xffffffff80a6b9e3 at panic+0x43 #3 0xffffffff80edf832 at trap_fatal+0x322 #4 0xffffffff80edf889 at trap_pfault+0x49 #5 0xffffffff80edf0c6 at trap+0x286 #6 0xffffffff80ec3641 at calltrap+0x8 #7 0xffffffff80a21fbc at kern_kqueue+0x4c #8 0xffffffff80ee0394 at amd64_syscall+0x6c4 #9 0xffffffff80ec392b at Xfast_syscall+0xfb Uptime: 6m56s Dumping 122 out of 991 MB:..14%..27%..40%..53%..66%..79%..92% Reading symbols from /boot/kernel/ng_socket.ko...Reading symbols from /usr/lib/debug//boot/kernel/ng_socket.ko.debug...done. done. Loaded symbols for /boot/kernel/ng_socket.ko Reading symbols from /boot/kernel/netgraph.ko...Reading symbols from /usr/lib/debug//boot/kernel/netgraph.ko.debug...done. done. Loaded symbols for /boot/kernel/netgraph.ko Reading symbols from /boot/kernel/ng_mppc.ko...Reading symbols from /usr/lib/debug//boot/kernel/ng_mppc.ko.debug...done. done. Loaded symbols for /boot/kernel/ng_mppc.ko Reading symbols from /boot/kernel/rc4.ko...Reading symbols from /usr/lib/debug//boot/kernel/rc4.ko.debug...done. done. Loaded symbols for /boot/kernel/rc4.ko #0 doadump (textdump=3D) at pcpu.h:222 222 __asm("movq %%gs:%1,%0" : "=3Dr" (td) (kgdb) list *0xffffffff80a65f95 0xffffffff80a65f95 is in chgkqcnt (atomic.h:263). 258 */ 259 static __inline u_long 260 atomic_fetchadd_long(volatile u_long *p, u_long v) 261 { 262 263 __asm __volatile( 264 " " MPLOCKED " " 265 " xaddq %0,%1 ; " 266 "# atomic_fetchadd_long" 267 : "+r" (v), /* 0 */ Current language: auto; currently minimal (kgdb) backtrace #0 doadump (textdump=3D) at pcpu.h:222 #1 0xffffffff80a6b6f1 in kern_reboot (howto=3D260) at /usr/src/sys/kern/kern_shutdown.c:366 #2 0xffffffff80a6bbb0 in vpanic (fmt=3D, ap=3D) at /usr/src/sys/kern/kern_shutdown.c:759 #3 0xffffffff80a6b9e3 in panic (fmt=3D) at /usr/src/sys/kern/kern_shutdown.c:690 #4 0xffffffff80edf832 in trap_fatal (frame=3D0xfffffe004f125800, eva=3D80)= at /usr/src/sys/amd64/amd64/trap.c:801 #5 0xffffffff80edf889 in trap_pfault (frame=3D0xfffffe004f125800, usermode= =3D0) at pcpu.h:222 #6 0xffffffff80edf0c6 in trap (frame=3D0xfffffe004f125800) at /usr/src/sys/amd64/amd64/trap.c:421 #7 0xffffffff80ec3641 in calltrap () at /usr/src/sys/amd64/amd64/exception.S:236 #8 0xffffffff80a65f95 in chgkqcnt (uip=3D0x0, diff=3D1, max=3D922337203685= 4775807) at atomic.h:263 #9 0xffffffff80a21fbc in kern_kqueue (td=3D0xfffff80003e6a000, flags=3D0, fcaps=3D0x0) at /usr/src/sys/kern/kern_event.c:837 #10 0xffffffff80ee0394 in amd64_syscall (td=3D0xfffff80003e6a000, traced=3D= 0) at subr_syscall.c:135 #11 0xffffffff80ec392b in Xfast_syscall () at /usr/src/sys/amd64/amd64/exception.S:396 #12 0x00000008021aae9a in ?? () Previous frame inner to this frame (corrupt stack?) (kgdb) frame 9 #9 0xffffffff80a21fbc in kern_kqueue (td=3D0xfffff80003e6a000, flags=3D0, fcaps=3D0x0) at /usr/src/sys/kern/kern_event.c:837 837 if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES))) (kgdb) list 832 struct ucred *cred; 833 int fd, error; 834 835 fdp =3D td->td_proc->p_fd; 836 cred =3D td->td_ucred; 837 if (!chgkqcnt(cred->cr_ruidinfo, 1, lim_cur(td, RLIMIT_KQUEUES))) 838 return (ENOMEM); 839 840 error =3D falloc_caps(td, &fp, &fd, flags, fcaps); 841 if (error !=3D 0) { (kgdb) print *cred $1 =3D {cr_ref =3D 2168608751, cr_uid =3D 4294967295, cr_ruid =3D 21168128,= cr_svuid =3D 0, cr_ngroups =3D 0, cr_rgid =3D 0, cr_svgid =3D 4,=20 cr_uidinfo =3D 0x0, cr_ruidinfo =3D 0x0, cr_prison =3D 0xfffff8002676b4b0, cr_loginclass =3D 0xfffff80003945280, cr_flags =3D 60052120,=20 cr_pspare2 =3D 0xfffff80003640448, cr_label =3D 0x0, cr_audit =3D {ai_aui= d =3D 0, ai_mask =3D {am_success =3D 0, am_failure =3D 2158116784},=20 ai_termid =3D {at_port =3D 4294967295, at_type =3D 2158116848, at_addr = =3D 0xfffff80003640474}, ai_asid =3D -1,=20 ai_flags =3D 18446735277673415680}, cr_groups =3D 0x0, cr_agroups =3D 0, cr_smallgroups =3D 0xfffff8000364049c} --=20 You are receiving this mail because: You are the assignee for the bug.=