Date: Sat, 1 Nov 2003 13:36:47 +0100 (CET) From: Per Hedeland <per@hedeland.org> To: FreeBSD-gnats-submit@FreeBSD.org Cc: per@hedeland.org Subject: kern/58803: kern.argmax isn't changeable even at boot [PATCH] Message-ID: <200311011236.hA1CakZK083508@pluto.hedeland.org> Resent-Message-ID: <200311011240.hA1CeHhK040406@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 58803 >Category: kern >Synopsis: kern.argmax isn't changeable even at boot [PATCH] >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Nov 01 04:40:16 PST 2003 >Closed-Date: >Last-Modified: >Originator: Per Hedeland >Release: FreeBSD 5.0-RELEASE i386 >Organization: none >Environment: System: FreeBSD pluto.hedeland.org 5.0-RELEASE FreeBSD 5.0-RELEASE #7: Thu Oct 30 01:31:43 CET 2003 per@pluto.hedeland.org:/usr/src/sys/i386/compile/PLUTO i386 >Description: It isn't possible to change kern.argmax even by using the /boot/loader.conf etc interface. This is a rather annoying limitation, especially since the FreeBSD default of 64 kB could be considered to be pretty low (e.g. Solaris has 1 MB). Changing the ARG_MAX value in /usr/src/sys/sys/syslimits.h and rebuilding the kernel works of course, but isn't very convenient. >How-To-Repeat: Put a line kern.argmax="1048576" in /boot/loader.conf. Reboot, and query the new value with sysctl kern.argmax The output will still show the original 65536 value. >Fix: The trivial patch enclosed seems to fix the problem. --- /usr/src/sys/alpha/osf1/osf1_sysvec.c.ORIG Sun Sep 1 23:41:22 2002 +++ /usr/src/sys/alpha/osf1/osf1_sysvec.c Thu Oct 30 01:25:25 2003 @@ -121,7 +121,7 @@ sz = *(imgp->proc->p_sysent->sv_szsigcode); destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - - roundup((ARG_MAX - imgp->stringspace), sizeof(char *)); + roundup((argmax - imgp->stringspace), sizeof(char *)); destp -= imgp->stringspace; --- /usr/src/sys/ia64/ia32/ia32_sysvec.c.ORIG Sun Sep 1 23:41:23 2002 +++ /usr/src/sys/ia64/ia32/ia32_sysvec.c Thu Oct 30 01:25:25 2003 @@ -146,7 +146,7 @@ arginfo = (struct ia32_ps_strings *)IA32_PS_STRINGS; szsigcode = *(imgp->proc->p_sysent->sv_szsigcode); destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - - roundup((ARG_MAX - imgp->stringspace), sizeof(char *)); + roundup((argmax - imgp->stringspace), sizeof(char *)); /* * install sigcode @@ -194,7 +194,7 @@ /* * Copy out strings - arguments and environment. */ - copyout(stringp, destp, ARG_MAX - imgp->stringspace); + copyout(stringp, destp, argmax - imgp->stringspace); /* * Fill in "ps_strings" struct for ps, w, etc. --- /usr/src/sys/kern/kern_exec.c.ORIG Thu Dec 19 10:40:10 2002 +++ /usr/src/sys/kern/kern_exec.c Thu Oct 30 01:27:26 2003 @@ -235,7 +235,7 @@ * Allocate temporary demand zeroed space for argument and * environment strings */ - imgp->stringbase = (char *)kmem_alloc_wait(exec_map, ARG_MAX + + imgp->stringbase = (char *)kmem_alloc_wait(exec_map, argmax + PAGE_SIZE); if (imgp->stringbase == NULL) { error = ENOMEM; @@ -243,8 +243,8 @@ goto exec_fail; } imgp->stringp = imgp->stringbase; - imgp->stringspace = ARG_MAX; - imgp->image_header = imgp->stringbase + ARG_MAX; + imgp->stringspace = argmax; + imgp->image_header = imgp->stringbase + argmax; /* * Translate the file name. namei() returns a vnode pointer @@ -260,7 +260,7 @@ error = namei(ndp); if (error) { kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX + PAGE_SIZE); + argmax + PAGE_SIZE); goto exec_fail; } @@ -633,7 +633,7 @@ if (imgp->stringbase != NULL) kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX + PAGE_SIZE); + argmax + PAGE_SIZE); if (imgp->object) vm_object_deallocate(imgp->object); @@ -987,7 +987,7 @@ if (p->p_sysent->sv_szsigcode != NULL) szsigcode = *(p->p_sysent->sv_szsigcode); destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE - - roundup((ARG_MAX - imgp->stringspace), sizeof(char *)); + roundup((argmax - imgp->stringspace), sizeof(char *)); /* * install sigcode @@ -1035,7 +1035,7 @@ /* * Copy out strings - arguments and environment. */ - copyout(stringp, destp, ARG_MAX - imgp->stringspace); + copyout(stringp, destp, argmax - imgp->stringspace); /* * Fill in "ps_strings" struct for ps, w, etc. --- /usr/src/sys/kern/kern_mib.c.ORIG Fri Nov 8 00:57:17 2002 +++ /usr/src/sys/kern/kern_mib.c Thu Oct 30 01:27:27 2003 @@ -111,7 +111,7 @@ &maxusers, 0, "Hint for kernel tuning"); SYSCTL_INT(_kern, KERN_ARGMAX, argmax, CTLFLAG_RD, - 0, ARG_MAX, "Maximum bytes of argument to execve(2)"); + &argmax, 0, "Maximum bytes of argument to execve(2)"); SYSCTL_INT(_kern, KERN_POSIX1, posix1version, CTLFLAG_RD, 0, _POSIX_VERSION, "Version of POSIX attempting to comply to"); --- /usr/src/sys/kern/subr_param.c.ORIG Fri Aug 30 06:04:35 2002 +++ /usr/src/sys/kern/subr_param.c Thu Oct 30 01:27:28 2003 @@ -75,6 +75,7 @@ int nswbuf; int maxswzone; /* max swmeta KVA storage */ int maxbcache; /* max buffer cache KVA storage */ +int argmax; /* max bytes of argument to exec */ u_quad_t maxtsiz; /* max text size */ u_quad_t dfldsiz; /* initial data size limit */ u_quad_t maxdsiz; /* max data size */ @@ -166,4 +167,7 @@ ncallout = 16 + maxproc + maxfiles; TUNABLE_INT_FETCH("kern.ncallout", &ncallout); + + argmax = ARG_MAX; + TUNABLE_INT_FETCH("kern.argmax", &argmax); } --- /usr/src/sys/sys/proc.h.ORIG Tue Dec 10 03:33:45 2002 +++ /usr/src/sys/sys/proc.h Thu Oct 30 01:27:29 2003 @@ -827,6 +827,7 @@ extern int hogticks; /* Limit on kernel cpu hogs. */ extern int nprocs, maxproc; /* Current and max number of procs. */ extern int maxprocperuid; /* Max procs per uid. */ +extern int argmax; /* Max bytes of argument to exec. */ extern u_long ps_arg_cache_limit; extern int ps_argsopen; extern int ps_showallprocs; --- /usr/src/sys/vm/vm_init.c.ORIG Fri Nov 8 00:57:17 2002 +++ /usr/src/sys/vm/vm_init.c Thu Oct 30 01:25:25 2003 @@ -193,7 +193,7 @@ (nswbuf*MAXPHYS) + pager_map_size); pager_map->system_map = 1; exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - (16*(ARG_MAX+(PAGE_SIZE*3)))); + (16*(argmax+(PAGE_SIZE*3)))); /* * XXX: Mbuf system machine-specific initializations should >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311011236.hA1CakZK083508>