[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CACVxJT_mZhX7G7q31WW+EY_sT-KJXFDnQ29j0D1YF6Nba_Ld3g@mail.gmail.com>
Date: Fri, 29 Apr 2016 13:25:24 +0300
From: Alexey Dobriyan <adobriyan@...il.com>
To: Mathias Krause <minipli@...glemail.com>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
"linux-kernel@...r.kernel.org" <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>,
Cyrill Gorcunov <gorcunov@...nvz.org>,
Jarod Wilson <jarod@...hat.com>
Subject: Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready
On Fri, Apr 29, 2016 at 9:02 AM, Mathias Krause <minipli@...glemail.com> wrote:
> On 28 April 2016 at 23:30, Andrew Morton <akpm@...ux-foundation.org> wrote:
>> 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.
>
> I totally agree that this kind of "synchronization" is rather fragile.
> Adding comments won't help much, I fear. Rather a dedicated flag,
> signaling "process ready for inspection" may be needed. So far, that's
> what env_end is (ab-)used for.
If MM Cabal is OK with MMF_LOAD_BINARY_OK flag
applied at search_binary_handler(), it should work for /proc .
Alexey
Powered by blists - more mailing lists