X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=kernel%2Fsysctl.c;h=d34b4e64a957c7d19eb49f0daeb47c5562161cb2;hb=f7f1b0f1e2fbadeab12d24236000e778aa9b1ead;hp=8f87d9924b71972bcb47a8d818b9e65f5a0ef3bf;hpb=a6d8dea2993ef90fb69b81372daa0b63f8aa940e;p=linux-2.6.git diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 8f87d9924..d34b4e64a 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -123,6 +123,8 @@ extern int sysctl_hz_timer; extern int acct_parm[]; #endif +int randomize_va_space = 1; + static int parse_table(int __user *, int, void __user *, size_t __user *, void __user *, size_t, ctl_table *, void **); static int proc_doutsstring(ctl_table *table, int write, struct file *filp, @@ -648,6 +650,15 @@ static ctl_table kern_table[] = { .proc_handler = &proc_dointvec, }, #endif + { + .ctl_name = KERN_RANDOMIZE, + .procname = "randomize_va_space", + .data = &randomize_va_space, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = &proc_dointvec, + }, + { .ctl_name = 0 } }; @@ -1382,6 +1393,7 @@ static ssize_t proc_writesys(struct file * file, const char __user * buf, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes a string from/to the user buffer. If the kernel * buffer provided is not large enough to hold the string, the @@ -1402,15 +1414,13 @@ int proc_dostring(ctl_table *table, int write, struct file *filp, data = table->data; maxlen = table->maxlen; + + if (!data || !maxlen || !*lenp || (*ppos && !write)) + return (*lenp = 0); + if (table->virt_handler) table->virt_handler(table, write, filp->f_xid, &data, &maxlen); - if (!table->data || !table->maxlen || !*lenp || - (*ppos && !write)) { - *lenp = 0; - return 0; - } - if (write) { len = 0; p = buffer; @@ -1604,6 +1614,7 @@ static int do_proc_dointvec(ctl_table *table, int write, struct file *filp, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes up to table->maxlen/sizeof(unsigned int) integer * values from/to the user buffer, treated as an ASCII string. @@ -1708,6 +1719,7 @@ static int do_proc_dointvec_minmax_conv(int *negp, unsigned long *lvalp, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes up to table->maxlen/sizeof(unsigned int) integer * values from/to the user buffer, treated as an ASCII string. @@ -1840,6 +1852,7 @@ static int do_proc_doulongvec_minmax(ctl_table *table, int write, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long * values from/to the user buffer, treated as an ASCII string. @@ -1862,6 +1875,7 @@ int proc_doulongvec_minmax(ctl_table *table, int write, struct file *filp, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes up to table->maxlen/sizeof(unsigned long) unsigned long * values from/to the user buffer, treated as an ASCII string. The values @@ -1952,6 +1966,7 @@ static int do_proc_dointvec_ms_jiffies_conv(int *negp, unsigned long *lvalp, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position * * Reads/writes up to table->maxlen/sizeof(unsigned int) integer * values from/to the user buffer, treated as an ASCII string. @@ -1996,6 +2011,8 @@ int proc_dointvec_userhz_jiffies(ctl_table *table, int write, struct file *filp, * @filp: the file structure * @buffer: the user buffer * @lenp: the size of the user buffer + * @ppos: file position + * @ppos: the current position in the file * * Reads/writes up to table->maxlen/sizeof(unsigned int) integer * values from/to the user buffer, treated as an ASCII string.