kernel - Fix new static stackgap feature from recent commit
authorMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Dec 2011 21:18:41 +0000 (13:18 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Thu, 22 Dec 2011 21:18:41 +0000 (13:18 -0800)
* Fix the code up a bit to make the feature actually work properly.

sys/kern/kern_exec.c

index abedbb9..f18b33c 100644 (file)
@@ -976,20 +976,16 @@ exec_copyout_strings(struct image_params *imgp)
                if (gap < 0)
                        sgap = ALIGN(-gap);
                else
-                       sgap = ALIGN(karc4random() & (stackgap_random - 1));
+                       sgap = ALIGN(karc4random() & (gap - 1));
        } else {
                sgap = 0;
        }
 
-       if (stackgap_random != 0)
-               sgap = ALIGN(karc4random() & (stackgap_random - 1));
-       else
-               sgap = 0;
-
        /*
         * Calculate destp, which points to [args & env] and above.
         */
-       destp = (caddr_t)arginfo - szsigcode -
+       destp = (caddr_t)arginfo -
+               szsigcode -
                roundup(execpath_len, sizeof(char *)) -
                SPARE_USRSPACE -
                sgap -