Re: [PATCH] proc: fix NULL dereference when reading /proc/<pid>/auxv
From: Leon Yu
Date: Wed Oct 19 2016 - 10:52:14 EST
On Wed, Oct 19, 2016 at 10:20 PM, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Oct 19, 2016 at 09:59:40PM +0800, Leon Yu wrote:
> > Reading auxv of any kernel thread results in NULL pointer dereferencing in
> > auxv_read() where mm can be NULL or even error code. Fix that by testing mm
> > with IS_ERR_OR_NULL() helper. This is also the original behavior changed by
> > recent commit c5317167854e ("proc: switch auxv to use of __mem_open()").
>
> What the... How can it be ERR_PTR(...) after it has passed __mem_open()?
Doh.. didn't realize that IS_ERR() case can't happen.
> I agree that we ought to check for NULL mm (the only question is whether it's
> best done by failing open() or by treating the file as empty), but this
> IS_ERR_OR_NULL() is pure cargo-cult, AFAICS.
Treating the file in question as empty might be a better choice, just in case
something depends on old behavior.
-Leon