[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140421154505.eef405f0a23e2ff8a1c7536e@linux-foundation.org>
Date: Mon, 21 Apr 2014 15:45:05 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Kees Cook <keescook@...omium.org>
Cc: linux-kernel@...r.kernel.org, David Howells <dhowells@...hat.com>,
Randy Dunlap <rdunlap@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Rik van Riel <riel@...hat.com>, Mel Gorman <mgorman@...e.de>,
Li Zefan <lizefan@...wei.com>,
Dave Hansen <dave@...ux.vnet.ibm.com>,
Aaron Tomlin <atomlin@...hat.com>,
Dario Faggioli <raistlin@...ux.it>,
Andrew Shewmaker <agshew@...il.com>,
Andi Kleen <ak@...ux.intel.com>, Jens Axboe <axboe@...com>,
Wanpeng Li <liwanp@...ux.vnet.ibm.com>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Frederic Weisbecker <fweisbec@...il.com>,
Pavel Emelyanov <xemul@...allels.com>,
Andrey Vagin <avagin@...nvz.org>,
Michael Ellerman <michael@...erman.id.au>
Subject: Re: [PATCH v2 3/4] sysctl: allow for strict write position handling
On Thu, 17 Apr 2014 17:16:22 -0700 Kees Cook <keescook@...omium.org> wrote:
> When writing to a sysctl string, each write, regardless of VFS position,
> begins writing the string from the start. This means the contents of
> the last write to the sysctl controls the string contents instead of
> the first:
>
> open("/proc/sys/kernel/modprobe", O_WRONLY) = 1
> write(1, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"..., 4096) = 4096
> write(1, "/bin/true", 9) = 9
> close(1) = 0
>
> $ cat /proc/sys/kernel/modprobe
> /bin/true
>
> Expected behaviour would be to have the sysctl be "AAAA..." capped at
> maxlen (in this case KMOD_PATH_LEN: 256), instead of truncating to the
> contents of the second write. Similarly, multiple short writes would not
> append to the sysctl.
>
> This provides CONFIG_PROC_SYSCTL_STRICT_WRITES as a way to make this
> behavior act in a less surprising manner for strings, and disallows
> non-zero file position when writing numeric sysctls (similar to what is
> already done when reading from non-zero file positions).
Adding a Kconfig knob to alter the behavior of procfs writes creeps me
out. I wonder why.
- I doubt if many people have a sufficient amount of control over
their entire systems to be able to confidently set
CONFIG_PROC_SYSCTL_STRICT_WRITES.
- Software will be shipped which runs OK with one setting but breaks
with the other setting.
So what to do?
I think we can *detect* this situation easily enough. So some options are
a) change the behaviour and add code which detects when userspace is
doing a write whose behaviour is now altered. Print a warning. Or
b) leave the behaviour as-is. Add a detector which tells people
"hey, your userspace is probably broken - please fix". Wait N
years. Then alter the behaviour as in a).
In either case the detector should display current->comm, the procfs
pathname and the contents of the write, to aid people in hunting down
and fixing their userspace.
--
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