From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932952AbcJTRGW (ORCPT ); Thu, 20 Oct 2016 13:06:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58254 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932123AbcJTRGI (ORCPT ); Thu, 20 Oct 2016 13:06:08 -0400 Date: Thu, 20 Oct 2016 19:04:39 +0200 From: Oleg Nesterov To: Leon Yu Cc: Andrew Morton , Al Viro , Kees Cook , Michal Hocko , 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: <20161020170438.GA13724@redhat.com> References: <1476885580-7612-1-git-send-email-chianglungyu@gmail.com> <1476966200-14457-1-git-send-email-chianglungyu@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1476966200-14457-1-git-send-email-chianglungyu@gmail.com> User-Agent: Mutt/1.5.18 (2008-05-17) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 20 Oct 2016 17:06:08 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Acked-by: Oleg Nesterov