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


Groups > linux.kernel > #1390557

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

From Andrew Morton <akpm@linux-foundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH] proc: prevent accessing /proc/<PID>/environ until it's ready
Date 2016-04-28 23:40 +0200
Message-ID <rt1Pc-2H9-3@gated-at.bofh.it> (permalink)
References <rsZu2-JY-5@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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().

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.

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