r94495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94494‎ | r94495 | r94496 >
Date:08:27, 15 August 2011
Author:tstarling
Status:ok
Tags:
Comment:
* Remove a comment about a memory leak. I fixed it before I finished writing the comment.
* Add a comment about a possible timeout strategy.
Modified paths:
  • /trunk/php/luasandbox/luasandbox.c (modified) (history)

Diff [purge]

Index: trunk/php/luasandbox/luasandbox.c
@@ -26,8 +26,21 @@
2727 * lua_tocfunction().
2828 *
2929 * * Add CPU time limits.
 30+ *
 31+ * Doing a longjmp() from a signal handler destroys anything that the
 32+ * call stack may have been modifying at the time. Allowing continued
 33+ * access to such state will allow security vulnerabilities (SIG32-C).
 34+ *
 35+ * So I propose having two timeouts. When the first expires, a debug hook
 36+ * is set which calls lua_error(), and a flag is set prohibiting dispatch
 37+ * of any PHP callback. When the second expires, emergency action is
 38+ * taken. If a PHP callback has been dispatched and we are waiting for it
 39+ * to return, zend_error() will need to be called with E_ERROR, to safely
 40+ * destroy the PHP state. This mirrors the behaviour of normal Zend timeouts.
 41+ * Otherwise, lua_error() should be called, to return control to the
 42+ * lua_pcall() caller, which should then destroy the lua state.
 43+ *
3044 * * Add LuaSandbox::getMemoryUsage().
31 - * * Fix memory leak probably in
3245 */
3346
3447 #ifdef HAVE_CONFIG_H

Status & tagging log