From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755428AbcJTTVd (ORCPT ); Thu, 20 Oct 2016 15:21:33 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:34968 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755271AbcJTTV1 (ORCPT ); Thu, 20 Oct 2016 15:21:27 -0400 Date: Thu, 20 Oct 2016 21:21:24 +0200 From: Michal Hocko To: Oleg Nesterov Cc: Leon Yu , Andrew Morton , Al Viro , Kees Cook , John Stultz , Mateusz Guzik , Janis Danisevskis , linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] proc: fix NULL dereference when reading /proc//auxv Message-ID: <20161020192124.GB27342@dhcp22.suse.cz> References: <1476885580-7612-1-git-send-email-chianglungyu@gmail.com> <1476966200-14457-1-git-send-email-chianglungyu@gmail.com> <20161020170438.GA13724@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161020170438.GA13724@redhat.com> 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 Thu 20-10-16 19:04:39, Oleg Nesterov wrote: > On 10/20, Leon Yu wrote: > > > > --- a/fs/proc/base.c > > +++ b/fs/proc/base.c > > @@ -1014,6 +1014,9 @@ static ssize_t auxv_read(struct file *file, char __user *buf, > > { > > struct mm_struct *mm = file->private_data; > > unsigned int nwords = 0; > > + > > + if (!mm) > > + return 0; > > do { > > nwords += 2; > > } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */ > > Michal disagrees and I won't argue with his patch which makes __mem_open() > fail if ->mm == NULL. Even if I don't really understand why should we change > the old behaviour, this _can_ break or at least confuse something/someone. > > However, even if we do the change above, personally I do think we should > fix the trivial bug first, then surprise the user-space. I am not objecting to this particular patch as it is obviously correct. I was just hoping to have a more generic solution. The issue was introduced in this merge window so it is not like we would need as minimalistic approach possible. If the __mem_open approach sounds too dangerous I will not pursue it. Anyway feel free to add Acked-by: Michal Hocko for this patch. -- Michal Hocko SUSE Labs