From: Andrew Morton <akpm@linux-foundation.org>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: pavel@suse.cz, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: /proc/sys/vm/drop_caches: add error handling
Date: Tue, 3 Feb 2009 11:14:47 -0800 [thread overview]
Message-ID: <20090203111447.41e2022c.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090203204456.ECA3.KOSAKI.MOTOHIRO@jp.fujitsu.com>
On Tue, 3 Feb 2009 20:47:56 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> wrote:
> >
> > Document that drop_caches is unsafe, and add error checking so that it
> > bails out on invalid inputs. [Note that this was triggered by Android
> > trying to use it in production, and incidentally writing invalid
> > value...]
>
> Yup. good patch.
>
> > - return 0;
> > + int res;
> > + res = proc_dointvec_minmax(table, write, file, buffer, length, ppos);
> > + if (res)
> > + return res;
> > + if (!write)
> > + return res;
> > + if (sysctl_drop_caches & ~3)
> > + return -EINVAL;
> > + if (sysctl_drop_caches & 1)
> > + drop_pagecache();
> > + if (sysctl_drop_caches & 2)
> > + drop_slab();
> > + return res;
> > }
>
> I think following is clarify more.
>
> res = proc_dointvec_minmax(table, write, file, buffer, length, ppos);
> if (res)
> return res;
> if (!write)
> return 0;
> if (sysctl_drop_caches & ~3)
> return -EINVAL;
> if (sysctl_drop_caches & 1)
> drop_pagecache();
> if (sysctl_drop_caches & 2)
> drop_slab();
> return 0;
>
>
> otherthings, _very_ looks good to me. :)
>
For better or for worse, my intent here was to be
future-back-compatible. So if we later add new flags, and people write
code which uses those new flags, that code won't break on old kernels.
Probably that wasn't a very good idea, and such userspace code isn't
very good.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-02-03 19:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090203113319.GA2022@elf.ucw.cz>
2009-02-03 11:47 ` KOSAKI Motohiro
2009-02-03 19:14 ` Andrew Morton [this message]
2009-02-04 18:26 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090203111447.41e2022c.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=pavel@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox