NetBSD-Bugs archive

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

kern/52225: Kernel crash when memory allocation fails in lua module



>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:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May 10 21:45:00 +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;
+



Home | Main Index | Thread Index | Old Index