lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20090203111447.41e2022c.akpm@linux-foundation.org>
Date:	Tue, 3 Feb 2009 11:14:47 -0800
From:	Andrew Morton <akpm@...ux-foundation.org>
To:	KOSAKI Motohiro <kosaki.motohiro@...fujitsu.com>
Cc:	pavel@...e.cz, kosaki.motohiro@...fujitsu.com,
	linux-kernel@...r.kernel.org, linux-mm@...ck.org
Subject: Re: /proc/sys/vm/drop_caches: add error handling

On Tue,  3 Feb 2009 20:47:56 +0900 (JST)
KOSAKI Motohiro <kosaki.motohiro@...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 from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ