From: Pavel Machek <pavel@ucw.cz>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Kees Cook <keescook@chromium.org>,
Andrew Morton <akpm@linux-foundation.org>,
LKML <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@kernel.org>, Rik van Riel <riel@redhat.com>,
David Rientjes <rientjes@google.com>,
Aaron Tomlin <atomlin@redhat.com>,
Dario Faggioli <raistlin@linux.it>,
Andi Kleen <ak@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>, Jens Axboe <axboe@fb.com>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Paul Wise <pabs3@bonedaddy.net>
Subject: Re: [PATCH] sysctl: terminate strings also on \r
Date: Mon, 27 Oct 2014 13:01:15 +0100 [thread overview]
Message-ID: <20141027120115.GB18586@amd> (raw)
In-Reply-To: <CAMuHMdVeFGjti-6ghv_u6_r2HkKHwWj70TGzQ0yGkuTmu7zBLQ@mail.gmail.com>
On Mon 2014-10-27 11:11:53, Geert Uytterhoeven wrote:
> On Mon, Oct 27, 2014 at 10:56 AM, Pavel Machek <pavel@ucw.cz> wrote:
> > On Wed 2014-10-22 16:43:10, Kees Cook wrote:
> >> On Wed, Oct 22, 2014 at 4:26 PM, Andrew Morton
> >> <akpm@linux-foundation.org> wrote:
> >> > On Tue, 21 Oct 2014 13:21:37 -0700 Kees Cook <keescook@chromium.org> wrote:
> >> >
> >> >> From: Paul Wise <pabs3@bonedaddy.net>
> >> >>
> >> >> This partially mitigates a common strategy used by attackers for hiding
> >> >> the full contents of strings in procfs from naive sysadmins who use cat,
> >> >> more or sysctl to inspect the contents of strings in procfs.
> >> >>
> >> >> ...
> >> >>
> >> >> --- a/kernel/sysctl.c
> >> >> +++ b/kernel/sysctl.c
> >> >> @@ -1739,7 +1739,7 @@ static int _proc_do_string(char *data, int maxlen, int write,
> >> >> while ((p - buffer) < *lenp && len < maxlen - 1) {
> >> >> if (get_user(c, p++))
> >> >> return -EFAULT;
> >> >> - if (c == 0 || c == '\n')
> >> >> + if (c == 0 || c == '\n' || c == '\r')
> >> >> break;
> >> >> data[len++] = c;
> >> >> }
> >> >
> >> > There are no valid uses of \r in a procfs write?
> >>
> >> I struggle to imagine one; everything I found that uses proc_dostring
> >> seems to be names, paths, and commands.
> >
> > Well, filename can contain \r, right?
>
> Even \n. AFAIK, the only thing a filename cannot contain is the nul character
> and a forward slash, as that's used to separate path components (so slash
> is valid for a path name).
>
> Still, we can hide stuff using ANSI ESC sequences, and e.g. backspaces,
> right?
Right :-(. So this patch makes no sense, it would have to forbid any
character < 32 to be effective.
And more sfun is... with ESCape sequences, you can actually cause
stuff to be forced as an input on poor admin's terminal. cat could be
"fixed", but pretty much all the command line tools could be abused to
do this... I see no reasonable way forward.
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
prev parent reply other threads:[~2014-10-27 12:01 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-21 20:21 [PATCH] sysctl: terminate strings also on \r Kees Cook
2014-10-22 10:03 ` Aaron Tomlin
2014-10-22 13:39 ` Paul E. McKenney
2014-10-22 22:49 ` David Rientjes
2014-10-22 23:26 ` Andrew Morton
2014-10-22 23:43 ` Kees Cook
2014-10-23 2:00 ` Andrew Morton
2014-10-23 16:39 ` Kees Cook
2014-10-23 18:23 ` Andrew Morton
2014-10-23 18:50 ` Kees Cook
2014-10-27 9:56 ` Pavel Machek
2014-10-27 10:11 ` Geert Uytterhoeven
2014-10-27 12:01 ` Pavel Machek [this message]
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=20141027120115.GB18586@amd \
--to=pavel@ucw.cz \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=atomlin@redhat.com \
--cc=axboe@fb.com \
--cc=geert@linux-m68k.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=pabs3@bonedaddy.net \
--cc=paulmck@linux.vnet.ibm.com \
--cc=peterz@infradead.org \
--cc=raistlin@linux.it \
--cc=riel@redhat.com \
--cc=rientjes@google.com \
/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