From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933628AbcJUOPE (ORCPT ); Fri, 21 Oct 2016 10:15:04 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:33918 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755662AbcJUOPC (ORCPT ); Fri, 21 Oct 2016 10:15:02 -0400 Date: Fri, 21 Oct 2016 16:14:54 +0200 From: Michal Hocko To: Alexey Dobriyan Cc: Linux Kernel , chianglungyu@gmail.com, Janis Danisevskis , John Stultz , Kees Cook , Mateusz Guzik , Oleg Nesterov , Al Viro , mm-commits@vger.kernel.org Subject: Re: + proc-fix-null-dereference-when-reading-proc-pid-auxv.patch added to -mm tree Message-ID: <20161021141453.GN6045@dhcp22.suse.cz> References: <580987f2.JsdBOQG1KdULbbHg%akpm@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 21-10-16 16:44:03, Alexey Dobriyan wrote: > On Fri, Oct 21, 2016 at 6:13 AM, wrote: > > > Reading auxv of any kernel thread results in NULL pointer dereferencing in > > auxv_read() where mm can be NULL. Fix that by checking for NULL mm and > > bailing out early. This is also the original behavior changed by recent > > commit c5317167854e ("proc: switch auxv to use of __mem_open()"). > > > --- a/fs/proc/base.c~proc-fix-null-dereference-when-reading-proc-pid-auxv > > +++ a/fs/proc/base.c > > @@ -1014,6 +1014,9 @@ static ssize_t auxv_read(struct file *fi > > { > > struct mm_struct *mm = file->private_data; > > unsigned int nwords = 0; > > + > > + if (!mm) > > + return 0; > > Rhetorical question: who wrote such clever __mem_open() ? This is nothing really new. __mem_open resp. proc_mem_open returned NULL mm for ages. I was suggesting to return ESRCH for NULL mm [1]. [1] http://lkml.kernel.org/r/20161019171748.GO24393@dhcp22.suse.cz -- Michal Hocko SUSE Labs