From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Morton Subject: Re: [PATCH][REPOST] Check maxlen on strnlen_user usage Date: Wed, 7 Sep 2011 17:06:21 -0700 Message-ID: <20110907170621.389b1314.akpm@linux-foundation.org> References: <4E68042A.1050406@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Mark Salter , Alexander Viro , linux-fsdevel@vger.kernel.org, "linux-kernel@vger.kernel.org" , "trivial@kernel.org" To: Ryan Mallon Return-path: Received: from smtp1.linux-foundation.org ([140.211.169.13]:49970 "EHLO smtp1.linux-foundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756742Ab1IHAHG (ORCPT ); Wed, 7 Sep 2011 20:07:06 -0400 In-Reply-To: <4E68042A.1050406@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Thu, 08 Sep 2011 09:54:18 +1000 Ryan Mallon wrote: > strnlen_user returns the length of the string including the nul > terminator. In the case where maxlen is reached strnlen_user returns > maxlen + 1. Most callsites already check for this condition. Fix the > call to strnlen_user in fs/exec.c to check for the maxlen case. > > diff --git a/fs/exec.c b/fs/exec.c > index 25dcbe5..e19588c 100644 > --- a/fs/exec.c > +++ b/fs/exec.c > @@ -481,7 +481,7 @@ static int copy_strings(int argc, struct > user_arg_ptr argv, > goto out; > > len = strnlen_user(str, MAX_ARG_STRLEN); > - if (!len) > + if (!len || len> MAX_ARG_STRLEN) > goto out; > > ret = -E2BIG; The following call to vald_arg_len() already does this? This change will cause copy_strings() to incorrectly return -EFAULT, rather than -E2BIG. Your email client is wordwrapping and space-stuffing the patches, btw.