From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753433AbbE0WMT (ORCPT ); Wed, 27 May 2015 18:12:19 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:32778 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752059AbbE0WMQ (ORCPT ); Wed, 27 May 2015 18:12:16 -0400 Date: Thu, 28 May 2015 01:12:14 +0300 From: Alexey Dobriyan To: Cyrill Gorcunov Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, jarod@redhat.com, jstancek@redhat.com Subject: Re: [PATCH 1/2] prctl: more prctl(PR_SET_MM_*) checks Message-ID: <20150527221214.GA27996@p183.telecom.by> References: <20150527214757.GA12863@p183.telecom.by> <20150527220229.GF17625@uranus.sw.swsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150527220229.GF17625@uranus.sw.swsoft.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2015 at 01:02:29AM +0300, Cyrill Gorcunov wrote: > On Thu, May 28, 2015 at 12:47:57AM +0300, Alexey Dobriyan wrote: > > Individual prctl(PR_SET_MM_*) calls do some checking to maintain > > consistent view of mm->arg_start et al fields, but not enough. > > In particular PR_SET_MM_ARG_START/PR_SET_MM_ARG_END/PR_SET_MM_ENV_START/PR_SET_MM_ENV_END > > only check that address lies in existent VMA, but doesn't check that > > start address is lower that end address _at all_. > > > > Consolidate all consistency checks, so there will be no difference in > > the future between PR_SET_MM_MAP and individual PR_SET_MM_* calls. > > > > The program below makes both ARGV and ENVP areas reverted, > > makes /proc/$PID/cmdline show garbage (doesn't oops by luck). > > Why should it oops? Anything can happen if you constantly write code like this unsigned long len = mm->arg_end - mm->arg_start; and expect result to be positive.