NetBSD Problem Report #52225

From www@NetBSD.org  Wed May 10 21:40:33 2017
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 5B4B57A200
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 10 May 2017 21:40:33 +0000 (UTC)
Message-Id: <20170510214032.6DD387A2AB@mollari.NetBSD.org>
Date: Wed, 10 May 2017 21:40:32 +0000 (UTC)
From: alexander@mihalicyn.com
Reply-To: alexander@mihalicyn.com
To: gnats-bugs@NetBSD.org
Subject: Kernel crash when memory allocation fails in lua module
X-Send-Pr-Version: www-1.0

>Number:         52225
>Category:       kern
>Synopsis:       Kernel crash when memory allocation fails in lua module
>Confidential:   no
>Severity:       non-critical
>Priority:       high
>Responsible:    kern-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 10 21:45:00 +0000 2017
>Closed-Date:    Thu May 11 07:36:41 +0000 2017
>Last-Modified:  Sun Jul 23 06:00:02 +0000 2017
>Originator:     Alexander Mihalicyn
>Release:        7.1
>Organization:
>Environment:
NetBSD netbsd 7.1 NetBSD 7.1 (GENERIC.201703111743Z) i386
>Description:
Take a look at file /usr/src/sys/modules/lua/lua.c:
(http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/sys/modules/lua/lua.c?rev=1.20&content-type=text/plain&only_with_tag=MAIN)

>K = kluaL_newstate(create->name, create->desc, IPL_NONE);
>K->ks_user = true;

>if (K == NULL)
>    return ENOMEM;

We have a obvious problem.

>How-To-Repeat:
N/A
>Fix:
diff --git a/sys/modules/lua/lua.c b/sys/modules/lua/lua.c
index 723a161..4e2487d 100644
--- a/sys/modules/lua/lua.c
+++ b/sys/modules/lua/lua.c
@@ -335,10 +335,11 @@ luaioctl(dev_t dev, u_long cmd, void *data, int flag, stru
ct lwp *l)
                        }

                K = kluaL_newstate(create->name, create->desc, IPL_NONE);
-               K->ks_user = true;
-
                if (K == NULL)
                        return ENOMEM;
+
+               K->ks_user = true;
+

>Release-Note:

>Audit-Trail:
From: "Marc Balmer" <mbalmer@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52225 CVS commit: src/sys/modules/lua
Date: Thu, 11 May 2017 07:34:27 +0000

 Module Name:	src
 Committed By:	mbalmer
 Date:		Thu May 11 07:34:27 UTC 2017

 Modified Files:
 	src/sys/modules/lua: lua.c

 Log Message:
 Avoid possible null pointer dereferencing.
 Fixes PR kern/52225.


 To generate a diff of this commit:
 cvs rdiff -u -r1.20 -r1.21 src/sys/modules/lua/lua.c

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

State-Changed-From-To: open->closed
State-Changed-By: mbalmer@NetBSD.org
State-Changed-When: Thu, 11 May 2017 07:36:41 +0000
State-Changed-Why:
Thanks for noticing!  Fix applied to -current and pullup to netbsd-7 requested.


From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52225 CVS commit: [netbsd-7] src/sys/modules/lua
Date: Sun, 23 Jul 2017 05:55:04 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sun Jul 23 05:55:04 UTC 2017

 Modified Files:
 	src/sys/modules/lua [netbsd-7]: lua.c

 Log Message:
 Pull up following revision(s) (requested by mbalmer in ticket #1418):
 	sys/modules/lua/lua.c: revision 1.21
 Avoid possible null pointer dereferencing.
 Fixes PR kern/52225.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13.2.3 -r1.13.2.4 src/sys/modules/lua/lua.c

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

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/52225 CVS commit: [netbsd-7-1] src/sys/modules/lua
Date: Sun, 23 Jul 2017 05:56:36 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Sun Jul 23 05:56:36 UTC 2017

 Modified Files:
 	src/sys/modules/lua [netbsd-7-1]: lua.c

 Log Message:
 Pull up following revision(s) (requested by mbalmer in ticket #1418):
 	sys/modules/lua/lua.c: revision 1.21
 Avoid possible null pointer dereferencing.
 Fixes PR kern/52225.


 To generate a diff of this commit:
 cvs rdiff -u -r1.13.2.3 -r1.13.2.3.4.1 src/sys/modules/lua/lua.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2014 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.