Re: [PATCH] sysctl: some input constraints checks were added for /proc/sys/vm directory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 3, 2011 at 12:16 AM, Petr Holasek <pholasek@xxxxxxxxxx> wrote:
> There were added boundaries of allowed input ranges for: dirty_expire_centisecs,
> drop_caches, overcommit_memory, page-cluster and panic_on_oom.
>
> Signed-off-by: Petr Holasek <pholasek@xxxxxxxxxx>
> ---
> Âfs/drop_caches.c | Â Â6 +++++-
> Âkernel/sysctl.c Â| Â 17 +++++++++++++----
> Â2 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/fs/drop_caches.c b/fs/drop_caches.c
> index 2195c21..8e61858 100644
> --- a/fs/drop_caches.c
> +++ b/fs/drop_caches.c
> @@ -45,7 +45,11 @@ static void drop_slab(void)
> Âint drop_caches_sysctl_handler(ctl_table *table, int write,
> Â Â Â Âvoid __user *buffer, size_t *length, loff_t *ppos)
> Â{
> - Â Â Â proc_dointvec_minmax(table, write, buffer, length, ppos);
> + Â Â Â int ret;
> +
> + Â Â Â ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
> + Â Â Â if (ret)
> + Â Â Â Â Â return ret;

s/space/tab, otherwise Acked-by: Dave Young <hidave.darkstar@xxxxxxxxx>

> Â Â Â Âif (write) {
> Â Â Â Â Â Â Â Âif (sysctl_drop_caches & 1)
> Â Â Â Â Â Â Â Â Â Â Â Âiterate_supers(drop_pagecache_sb, NULL);
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 0f1bd83..e0a4d50 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -117,6 +117,7 @@ static int neg_one = -1;
> Âstatic int zero;
> Âstatic int __maybe_unused one = 1;
> Âstatic int __maybe_unused two = 2;
> +static int __maybe_unused three = 3;
> Âstatic unsigned long one_ul = 1;
> Âstatic int one_hundred = 100;
> Â#ifdef CONFIG_PRINTK
> @@ -978,14 +979,18 @@ static struct ctl_table vm_table[] = {
>        Â.data      = &sysctl_overcommit_memory,
>        Â.maxlen     = sizeof(sysctl_overcommit_memory),
>        Â.mode      = 0644,
> -        .proc_handler  = proc_dointvec,
> +        .proc_handler  = proc_dointvec_minmax,
> + Â Â Â Â Â Â Â .extra1 Â Â Â Â = &zero,
> + Â Â Â Â Â Â Â .extra2 Â Â Â Â = &two,
> Â Â Â Â},
> Â Â Â Â{
>        Â.procname    = "panic_on_oom",
>        Â.data      = &sysctl_panic_on_oom,
>        Â.maxlen     = sizeof(sysctl_panic_on_oom),
>        Â.mode      = 0644,
> -        .proc_handler  = proc_dointvec,
> +        .proc_handler  = proc_dointvec_minmax,
> + Â Â Â Â Â Â Â .extra1 Â Â Â Â = &zero,
> + Â Â Â Â Â Â Â .extra2 Â Â Â Â = &two,
> Â Â Â Â},
> Â Â Â Â{
>        Â.procname    = "oom_kill_allocating_task",
> @@ -1013,7 +1018,8 @@ static struct ctl_table vm_table[] = {
>        Â.data      = &page_cluster,
>        Â.maxlen     = sizeof(int),
>        Â.mode      = 0644,
> -        .proc_handler  = proc_dointvec,
> +        .proc_handler  = proc_dointvec_minmax,
> + Â Â Â Â Â Â Â .extra1 Â Â Â Â = &zero,
> Â Â Â Â},
> Â Â Â Â{
>        Â.procname    = "dirty_background_ratio",
> @@ -1061,7 +1067,8 @@ static struct ctl_table vm_table[] = {
>        Â.data      = &dirty_expire_interval,
>        Â.maxlen     = sizeof(dirty_expire_interval),
>        Â.mode      = 0644,
> -        .proc_handler  = proc_dointvec,
> +        .proc_handler  = proc_dointvec_minmax,
> + Â Â Â Â Â Â Â .extra1 Â Â Â Â = &zero,
> Â Â Â Â},
> Â Â Â Â{
>        Â.procname    = "nr_pdflush_threads",
> @@ -1137,6 +1144,8 @@ static struct ctl_table vm_table[] = {
>        Â.maxlen     = sizeof(int),
>        Â.mode      = 0644,
>        Â.proc_handler  = drop_caches_sysctl_handler,
> + Â Â Â Â Â Â Â .extra1 Â Â Â Â = &one,
> + Â Â Â Â Â Â Â .extra2 Â Â Â Â = &three,
> Â Â Â Â},
> Â#ifdef CONFIG_COMPACTION
> Â Â Â Â{
> --
> 1.7.1
>
>



-- 
Regards
dave
ÿô.nlj·Ÿ®‰­†+%ŠË±é¥Šwÿº{.nlj·¥Š{±ýþ)íèjg¬±¨¶‰šŽŠÝjÿ¾«þG«é¸¢·¦j:+v‰¨Šwèm¶Ÿÿþø®w¥þŠà£¢·hšâÿ†Ù



[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux