From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753609AbaHYBke (ORCPT ); Sun, 24 Aug 2014 21:40:34 -0400 Received: from mail-pa0-f53.google.com ([209.85.220.53]:63513 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753088AbaHYBkd (ORCPT ); Sun, 24 Aug 2014 21:40:33 -0400 Date: Sun, 24 Aug 2014 18:38:44 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Oleg Nesterov cc: Cyrill Gorcunov , Andrew Morton , Hugh Dickins , Manfred Spraul , Davidlohr Bueso , Kees Cook , Tejun Heo , Andrew Vagin , "Eric W. Biederman" , "H. Peter Anvin" , Serge Hallyn , Pavel Emelyanov , Vasiliy Kulikov , KAMEZAWA Hiroyuki , Michael Kerrisk , Julien Tinnes , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] ipc/shm: fix the historical/wrong mm->start_stack check In-Reply-To: <20140823155832.GA9406@redhat.com> Message-ID: References: <20140823144246.GA6281@redhat.com> <20140823144327.GA6299@redhat.com> <20140823152240.GH25918@moon> <20140823155832.GA9406@redhat.com> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 23 Aug 2014, Oleg Nesterov wrote: > On 08/23, Cyrill Gorcunov wrote: > > > > On Sat, Aug 23, 2014 at 04:43:27PM +0200, Oleg Nesterov wrote: > > > The ->start_stack check in do_shmat() looks ugly and simply wrong. > > > > > > 1. ->start_stack is only valid right after exec(), the application > > > can switch to another stack and even unmap this area. > > > > > > 2. The reason for this check is not clear at all. The application > > > should know what it does. And why 4 pages? And why in fact it > > > requires 5 pages? > > > > > > 3. This wrongly assumes that the stack can only grown down. > > > > > > Personally I think we should simply kill this check, but I did not > > > dare to do this. So the patch only fixes the 1st problem (mostly to > > > avoid the usage of mm->start_stack) and ignores VM_GROWSUP. > > > > > > Signed-off-by: Oleg Nesterov > > Reviewed-by: Cyrill Gorcunov Yes, much better to use find_vma than have this strange stray use of unreliable start_stack. Acked-by: Hugh Dickins though like Manfred I didn't quite see how overflow was impossible on unfamiliar architectures. > > Thanks! > > > I don't understand this check either, the comment above it says nothing > > but only commits what code is doing not explaining why. > > Yes, and this check predates the git history. I even looked into > git://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git but this > change was added by the huge "v2.5.0.7 -> v2.5.0.8" update in 2002, > and obviously without any explanation (apart from "fix up proper shmat > semantics", but this connects SHM_REMAP itself). I'd say it comes earlier, from Christoph Rohland's 2.4.17-pre7's "Add missing checks on shmat()", though I didn't find more than that. We can all understand wanting to leave a gap below the growsdown stack, but of course could argue about growsup and 1 or 4 or 5 or whatever: okay that we're all more interested in just removing that start_stack. Hugh