[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20160428143058.0c12162dbc11461144cfa57f@linux-foundation.org>
Date: Thu, 28 Apr 2016 14:30:58 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Mathias Krause <minipli@...glemail.com>
Cc: linux-kernel@...r.kernel.org, Emese Revfy <re.emese@...il.com>,
Pax Team <pageexec@...email.hu>,
Al Viro <viro@...iv.linux.org.uk>,
Mateusz Guzik <mguzik@...hat.com>,
Alexey Dobriyan <adobriyan@...il.com>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Jarod Wilson <jarod@...hat.com>
Subject: Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's
ready
On Thu, 28 Apr 2016 21:04:18 +0200 Mathias Krause <minipli@...glemail.com> wrote:
> If /proc/<PID>/environ gets read before the envp[] array is fully set
> up in create_{aout,elf,elf_fdpic,flat}_tables(), we might end up trying
> to read more bytes than are actually written, as env_start will already
> be set but env_end will still be zero, making the range calculation
> underflow, allowing to read beyond the end of what has been written.
>
> Fix this as it is done for /proc/<PID>/cmdline by testing env_end for
> zero. It is, apparently, intentionally set last in create_*_tables().
Also, if this is indeed our design then
a) the various create_*_tables() should have comments in there which
explain this subtlety to the reader. Or, better, they use a common
helper function for this readiness-signaling operation because..
b) we'll need some barriers there to ensure that the environ_read()
caller sees the create_*_tables() writes in the correct order.
> This bug was found by the PaX size_overflow plugin that detected the
> arithmetic underflow of 'this_len = env_end - (env_start + src)' when
> env_end is still zero.
Powered by blists - more mailing lists