* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree [not found] <201103072305.p27N5hKT000474@imap1.linux-foundation.org> @ 2011-03-07 23:26 ` Alexey Dobriyan 2011-03-08 5:15 ` Dave Young 0 siblings, 1 reply; 10+ messages in thread From: Alexey Dobriyan @ 2011-03-07 23:26 UTC (permalink / raw) To: linux-kernel; +Cc: akpm, hidave.darkstar On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: > Add a proc_dointvec_unsigned() sysctl handler for positive value cases. > --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler > +++ a/kernel/sysctl.c > +int proc_dointvec_unsigned(struct ctl_table *table, int write, > + void __user *buffer, size_t *lenp, loff_t *ppos) > +{ > + struct do_proc_dointvec_minmax_conv_param param = { > + .min = &zero, > + }; > + return do_proc_dointvec(table, write, buffer, lenp, ppos, > + do_proc_dointvec_minmax_conv, ¶m); > +} This silently ignored max value in .extra2 . ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-07 23:26 ` + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree Alexey Dobriyan @ 2011-03-08 5:15 ` Dave Young 2011-03-08 5:43 ` Dave Young 0 siblings, 1 reply; 10+ messages in thread From: Dave Young @ 2011-03-08 5:15 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: linux-kernel, akpm On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: >> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. > >> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler >> +++ a/kernel/sysctl.c > >> +int proc_dointvec_unsigned(struct ctl_table *table, int write, >> + void __user *buffer, size_t *lenp, loff_t *ppos) >> +{ >> + struct do_proc_dointvec_minmax_conv_param param = { >> + .min = &zero, >> + }; >> + return do_proc_dointvec(table, write, buffer, lenp, ppos, >> + do_proc_dointvec_minmax_conv, ¶m); >> +} > > This silently ignored max value in .extra2 . Hi, Good cache, should set .max = NULL here Thanks, will update this patch. -- Regards dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 5:15 ` Dave Young @ 2011-03-08 5:43 ` Dave Young 2011-03-08 8:24 ` Alexey Dobriyan 0 siblings, 1 reply; 10+ messages in thread From: Dave Young @ 2011-03-08 5:43 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: linux-kernel, akpm On Tue, Mar 8, 2011 at 1:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote: > On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: >> On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: >>> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. >> >>> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler >>> +++ a/kernel/sysctl.c >> >>> +int proc_dointvec_unsigned(struct ctl_table *table, int write, >>> + void __user *buffer, size_t *lenp, loff_t *ppos) >>> +{ >>> + struct do_proc_dointvec_minmax_conv_param param = { >>> + .min = &zero, >>> + }; >>> + return do_proc_dointvec(table, write, buffer, lenp, ppos, >>> + do_proc_dointvec_minmax_conv, ¶m); >>> +} >> >> This silently ignored max value in .extra2 . > > Hi, > > Good cache, should set .max = NULL here Oh, c99 set default value to 0, isn't it? What do you mean silently ignore here? Let's see the code: if ((param->min && *param->min > val) || (param->max && *param->max < val)) return -EINVAL; There's no problem max == NULL -- Regards dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 5:43 ` Dave Young @ 2011-03-08 8:24 ` Alexey Dobriyan 2011-03-08 8:43 ` Dave Young 0 siblings, 1 reply; 10+ messages in thread From: Alexey Dobriyan @ 2011-03-08 8:24 UTC (permalink / raw) To: Dave Young; +Cc: linux-kernel, akpm On Tue, Mar 08, 2011 at 01:43:31PM +0800, Dave Young wrote: > On Tue, Mar 8, 2011 at 1:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote: > > On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > >> On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: > >>> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. > >> > >>> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler > >>> +++ a/kernel/sysctl.c > >> > >>> +int proc_dointvec_unsigned(struct ctl_table *table, int write, > >>> + void __user *buffer, size_t *lenp, loff_t *ppos) > >>> +{ > >>> + struct do_proc_dointvec_minmax_conv_param param = { > >>> + .min = &zero, > >>> + }; > >>> + return do_proc_dointvec(table, write, buffer, lenp, ppos, > >>> + do_proc_dointvec_minmax_conv, ¶m); > >>> +} > >> > >> This silently ignored max value in .extra2 . > > > > Hi, > > > > Good cache, should set .max = NULL here > > Oh, c99 set default value to 0, isn't it? > > What do you mean silently ignore here? > > Let's see the code: > > if ((param->min && *param->min > val) || > (param->max && *param->max < val)) > return -EINVAL; > > There's no problem max == NULL I mean literally "silently ignore". Try { .name = "foo", .data = &foo, .maxlen = sizeof(foo), .proc_handler = proc_dointvec_unsigned, .extra2 = &_42, } ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 8:24 ` Alexey Dobriyan @ 2011-03-08 8:43 ` Dave Young 2011-03-08 9:02 ` Alexey Dobriyan 0 siblings, 1 reply; 10+ messages in thread From: Dave Young @ 2011-03-08 8:43 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: linux-kernel, akpm On Tue, Mar 8, 2011 at 4:24 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > On Tue, Mar 08, 2011 at 01:43:31PM +0800, Dave Young wrote: >> On Tue, Mar 8, 2011 at 1:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote: >> > On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: >> >> On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: >> >>> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. >> >> >> >>> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler >> >>> +++ a/kernel/sysctl.c >> >> >> >>> +int proc_dointvec_unsigned(struct ctl_table *table, int write, >> >>> + void __user *buffer, size_t *lenp, loff_t *ppos) >> >>> +{ >> >>> + struct do_proc_dointvec_minmax_conv_param param = { >> >>> + .min = &zero, >> >>> + }; >> >>> + return do_proc_dointvec(table, write, buffer, lenp, ppos, >> >>> + do_proc_dointvec_minmax_conv, ¶m); >> >>> +} >> >> >> >> This silently ignored max value in .extra2 . >> > >> > Hi, >> > >> > Good cache, should set .max = NULL here >> >> Oh, c99 set default value to 0, isn't it? >> >> What do you mean silently ignore here? >> >> Let's see the code: >> >> if ((param->min && *param->min > val) || >> (param->max && *param->max < val)) >> return -EINVAL; >> >> There's no problem max == NULL > > I mean literally "silently ignore". > > Try > { > .name = "foo", > .data = &foo, > .maxlen = sizeof(foo), > .proc_handler = proc_dointvec_unsigned, > .extra2 = &_42, > } > Yes, extra2 is ignored, what would you like to do for this kind of ignore? -- Regards dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 8:43 ` Dave Young @ 2011-03-08 9:02 ` Alexey Dobriyan 2011-03-08 9:09 ` Dave Young 0 siblings, 1 reply; 10+ messages in thread From: Alexey Dobriyan @ 2011-03-08 9:02 UTC (permalink / raw) To: Dave Young; +Cc: linux-kernel, akpm On Tue, Mar 08, 2011 at 04:43:36PM +0800, Dave Young wrote: > On Tue, Mar 8, 2011 at 4:24 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > > On Tue, Mar 08, 2011 at 01:43:31PM +0800, Dave Young wrote: > >> On Tue, Mar 8, 2011 at 1:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote: > >> > On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > >> >> On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: > >> >>> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. > >> >> > >> >>> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler > >> >>> +++ a/kernel/sysctl.c > >> >> > >> >>> +int proc_dointvec_unsigned(struct ctl_table *table, int write, > >> >>> + void __user *buffer, size_t *lenp, loff_t *ppos) > >> >>> +{ > >> >>> + struct do_proc_dointvec_minmax_conv_param param = { > >> >>> + .min = &zero, > >> >>> + }; > >> >>> + return do_proc_dointvec(table, write, buffer, lenp, ppos, > >> >>> + do_proc_dointvec_minmax_conv, ¶m); > >> >>> +} > >> >> > >> >> This silently ignored max value in .extra2 . > >> > > >> > Hi, > >> > > >> > Good cache, should set .max = NULL here > >> > >> Oh, c99 set default value to 0, isn't it? > >> > >> What do you mean silently ignore here? > >> > >> Let's see the code: > >> > >> if ((param->min && *param->min > val) || > >> (param->max && *param->max < val)) > >> return -EINVAL; > >> > >> There's no problem max == NULL > > > > I mean literally "silently ignore". > > > > Try > > { > > .name = "foo", > > .data = &foo, > > .maxlen = sizeof(foo), > > .proc_handler = proc_dointvec_unsigned, > > .extra2 = &_42, > > } > > > > Yes, extra2 is ignored, what would you like to do for this kind of ignore? Obviously it should remain upper bound. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 9:02 ` Alexey Dobriyan @ 2011-03-08 9:09 ` Dave Young 2011-05-26 19:59 ` Andrew Morton 0 siblings, 1 reply; 10+ messages in thread From: Dave Young @ 2011-03-08 9:09 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: linux-kernel, akpm On Tue, Mar 8, 2011 at 5:02 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > On Tue, Mar 08, 2011 at 04:43:36PM +0800, Dave Young wrote: >> On Tue, Mar 8, 2011 at 4:24 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: >> > On Tue, Mar 08, 2011 at 01:43:31PM +0800, Dave Young wrote: >> >> On Tue, Mar 8, 2011 at 1:15 PM, Dave Young <hidave.darkstar@gmail.com> wrote: >> >> > On Tue, Mar 8, 2011 at 7:26 AM, Alexey Dobriyan <adobriyan@gmail.com> wrote: >> >> >> On Mon, Mar 07, 2011 at 03:05:43PM -0800, akpm@linux-foundation.org wrote: >> >> >>> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. >> >> >> >> >> >>> --- a/kernel/sysctl.c~sysctl-add-proc_dointvec_unsigned-handler >> >> >>> +++ a/kernel/sysctl.c >> >> >> >> >> >>> +int proc_dointvec_unsigned(struct ctl_table *table, int write, >> >> >>> + void __user *buffer, size_t *lenp, loff_t *ppos) >> >> >>> +{ >> >> >>> + struct do_proc_dointvec_minmax_conv_param param = { >> >> >>> + .min = &zero, >> >> >>> + }; >> >> >>> + return do_proc_dointvec(table, write, buffer, lenp, ppos, >> >> >>> + do_proc_dointvec_minmax_conv, ¶m); >> >> >>> +} >> >> >> >> >> >> This silently ignored max value in .extra2 . >> >> > >> >> > Hi, >> >> > >> >> > Good cache, should set .max = NULL here >> >> >> >> Oh, c99 set default value to 0, isn't it? >> >> >> >> What do you mean silently ignore here? >> >> >> >> Let's see the code: >> >> >> >> if ((param->min && *param->min > val) || >> >> (param->max && *param->max < val)) >> >> return -EINVAL; >> >> >> >> There's no problem max == NULL >> > >> > I mean literally "silently ignore". >> > >> > Try >> > { >> > .name = "foo", >> > .data = &foo, >> > .maxlen = sizeof(foo), >> > .proc_handler = proc_dointvec_unsigned, >> > .extra2 = &_42, >> > } >> > >> >> Yes, extra2 is ignored, what would you like to do for this kind of ignore? > > Obviously it should remain upper bound. > This function is intend for case val >=0, So I don't think extra2 should be added. -- Regards dave ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-03-08 9:09 ` Dave Young @ 2011-05-26 19:59 ` Andrew Morton 2011-05-27 4:51 ` Alexey Dobriyan 0 siblings, 1 reply; 10+ messages in thread From: Andrew Morton @ 2011-05-26 19:59 UTC (permalink / raw) To: Dave Young; +Cc: Alexey Dobriyan, linux-kernel So... where did we end up with this discussion? There are four patches involved: http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-add-proc_dointvec_bool-handler.patch http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-use-proc_dointvec_bool-where-appropriate.patch http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-add-proc_dointvec_unsigned-handler.patch http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-use-proc_dointvec_unsigned-where-appropriate.patch ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-05-26 19:59 ` Andrew Morton @ 2011-05-27 4:51 ` Alexey Dobriyan 2011-06-01 8:48 ` Dave Young 0 siblings, 1 reply; 10+ messages in thread From: Alexey Dobriyan @ 2011-05-27 4:51 UTC (permalink / raw) To: Andrew Morton; +Cc: Dave Young, linux-kernel On Thu, May 26, 2011 at 12:59:18PM -0700, Andrew Morton wrote: > > So... where did we end up with this discussion? > > There are four patches involved: > http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-add-proc_dointvec_unsigned-handler.patch > http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-use-proc_dointvec_unsigned-where-appropriate.patch This still sucks: * .extra2 aka max is ignored(!) * even if not ignored, API can't be used on array, because min and max boundaries should match wrt length. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree 2011-05-27 4:51 ` Alexey Dobriyan @ 2011-06-01 8:48 ` Dave Young 0 siblings, 0 replies; 10+ messages in thread From: Dave Young @ 2011-06-01 8:48 UTC (permalink / raw) To: Alexey Dobriyan; +Cc: Andrew Morton, linux-kernel [-- Attachment #1: Type: text/plain, Size: 765 bytes --] On Fri, May 27, 2011 at 12:51 PM, Alexey Dobriyan <adobriyan@gmail.com> wrote: > On Thu, May 26, 2011 at 12:59:18PM -0700, Andrew Morton wrote: >> >> So... where did we end up with this discussion? >> >> There are four patches involved: > >> http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-add-proc_dointvec_unsigned-handler.patch >> http://userweb.kernel.org/~akpm/mmotm/broken-out/sysctl-use-proc_dointvec_unsigned-where-appropriate.patch > > This still sucks: > * .extra2 aka max is ignored(!) > * even if not ignored, API can't be used on array, because min and max > boundaries should match wrt length. > Andrew, I'm offline last days, sorry for late reply. Alexey, I updated the patch, do you feel better? -- Regards dave [-- Attachment #2: sysctl-add-proc_dointvec_unsigned-handler-v2.patch --] [-- Type: text/x-pascal, Size: 2349 bytes --] From: Dave Young <hidave.darkstar@gmail.com> Add a proc_dointvec_unsigned() sysctl handler for positive value cases. V2 changes: As to Alexey Dobriyan: do not ignore max in proc_dointvec_unsigned param setup. Signed-off-by: Dave Young <hidave.darkstar@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> --- include/linux/sysctl.h | 2 ++ kernel/sysctl.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) --- linux-2.6.orig/include/linux/sysctl.h 2011-04-27 13:58:51.343332511 +0800 +++ linux-2.6/include/linux/sysctl.h 2011-06-01 16:28:07.679536892 +0800 @@ -971,6 +971,8 @@ extern int proc_dointvec(struct ctl_tabl void __user *, size_t *, loff_t *); extern int proc_dointvec_minmax(struct ctl_table *, int, void __user *, size_t *, loff_t *); +extern int proc_dointvec_unsigned(struct ctl_table *, int, + void __user *, size_t *, loff_t *); extern int proc_dointvec_jiffies(struct ctl_table *, int, void __user *, size_t *, loff_t *); extern int proc_dointvec_userhz_jiffies(struct ctl_table *, int, --- linux-2.6.orig/kernel/sysctl.c 2011-06-01 16:08:51.682872883 +0800 +++ linux-2.6/kernel/sysctl.c 2011-06-01 16:29:48.389536662 +0800 @@ -2476,6 +2476,33 @@ int proc_dointvec_minmax(struct ctl_tabl do_proc_dointvec_minmax_conv, ¶m); } +/** + * proc_dointvec_unsigned - read a vector of integers with positive values + * @table: the sysctl table + * @write: %TRUE if this is a write to the sysctl file + * @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. + * + * This routine will ensure the values are positive. + * + * Returns 0 on success. + */ +int proc_dointvec_unsigned(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + struct do_proc_dointvec_minmax_conv_param param = { + .min = &zero, + .max = (int *) table->extra2, + }; + return do_proc_dointvec(table, write, buffer, lenp, ppos, + do_proc_dointvec_minmax_conv, ¶m); +} +EXPORT_SYMBOL(proc_dointvec_unsigned); + static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos, ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2011-06-01 8:48 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <201103072305.p27N5hKT000474@imap1.linux-foundation.org>
2011-03-07 23:26 ` + sysctl-add-proc_dointvec_unsigned-handler.patch added to -mm tree Alexey Dobriyan
2011-03-08 5:15 ` Dave Young
2011-03-08 5:43 ` Dave Young
2011-03-08 8:24 ` Alexey Dobriyan
2011-03-08 8:43 ` Dave Young
2011-03-08 9:02 ` Alexey Dobriyan
2011-03-08 9:09 ` Dave Young
2011-05-26 19:59 ` Andrew Morton
2011-05-27 4:51 ` Alexey Dobriyan
2011-06-01 8:48 ` Dave Young
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®