Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1390774

Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready

From Mathias Krause <minipli@googlemail.com>
Newsgroups linux.kernel
Subject Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready
Date 2016-04-29 08:00 +0200
Message-ID <rt9D4-Oo-1@gated-at.bofh.it> (permalink)
References <rsZu2-JY-5@gated-at.bofh.it> <rt1Fx-2Aw-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 28 April 2016 at 23:26, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Thu, 28 Apr 2016 21:04:18 +0200 Mathias Krause <minipli@googlemail.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().
>>
>> 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.
>
> So what are the implications of this?  From my reading, a craftily
> constructed application could occasionally read arbitrarily large
> amounts of kernel memory?

I don't think access_remote_vm() is capable of that. So, the only
consequence is, userland trying to access /proc/<PID>/environ of a not
yet fully set up process may get inconsistent data as we're in the
middle of copying in the environment variables.

Regards,
Mathias

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Mathias Krause <minipli@googlemail.com> - 2016-04-28 21:10 +0200
  Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's  ready Cyrill Gorcunov <gorcunov@gmail.com> - 2016-04-28 21:30 +0200
  Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's  ready Mateusz Guzik <mguzik@redhat.com> - 2016-04-28 21:30 +0200
    Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Mathias Krause <minipli@googlemail.com> - 2016-04-28 21:40 +0200
    Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Alexey Dobriyan <adobriyan@gmail.com> - 2016-04-29 12:20 +0200
  Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's  ready Andrew Morton <akpm@linux-foundation.org> - 2016-04-28 23:30 +0200
    Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Mathias Krause <minipli@googlemail.com> - 2016-04-29 08:00 +0200
  Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's  ready Andrew Morton <akpm@linux-foundation.org> - 2016-04-28 23:40 +0200
    Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Mathias Krause <minipli@googlemail.com> - 2016-04-29 08:10 +0200
      Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready Alexey Dobriyan <adobriyan@gmail.com> - 2016-04-29 12:30 +0200

csiph-web