Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbbBWRNb (ORCPT ); Mon, 23 Feb 2015 12:13:31 -0500 Received: from out03.mta.xmission.com ([166.70.13.233]:41806 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752253AbbBWRN3 (ORCPT ); Mon, 23 Feb 2015 12:13:29 -0500 From: ebiederm@xmission.com (Eric W. Biederman) To: Dan Carpenter Cc: Andrew Morton , Andy Lutomirski , Wang YanQing , linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, kernel-janitors@vger.kernel.org References: <20150223154419.GA2542@mwanda> Date: Mon, 23 Feb 2015 11:10:02 -0600 In-Reply-To: <20150223154419.GA2542@mwanda> (Dan Carpenter's message of "Mon, 23 Feb 2015 18:44:19 +0300") Message-ID: <87385w1rmd.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX1/dQL3iEvgHNyVPSm1Lt+tk2Z08uXClieQ= X-SA-Exim-Connect-IP: 70.59.163.10 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa06 1397; Body=1 Fuz1=1 Fuz2=1] * 0.0 T_TooManySym_02 5+ unique symbols in subject * 0.0 T_TooManySym_01 4+ unique symbols in subject X-Spam-DCC: XMission; sa06 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Dan Carpenter X-Spam-Relay-Country: X-Spam-Timing: total 405 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 10 (2.5%), b_tie_ro: 8 (1.9%), parse: 0.65 (0.2%), extract_message_metadata: 11 (2.7%), get_uri_detail_list: 1.05 (0.3%), tests_pri_-1000: 4.9 (1.2%), tests_pri_-950: 1.26 (0.3%), tests_pri_-900: 1.09 (0.3%), tests_pri_-400: 19 (4.8%), check_bayes: 18 (4.5%), b_tokenize: 5 (1.2%), b_tok_get_all: 6 (1.4%), b_comp_prob: 2.7 (0.7%), b_tok_touch_all: 2.5 (0.6%), b_finish: 0.65 (0.2%), tests_pri_0: 349 (86.2%), tests_pri_500: 4.8 (1.2%), rewrite_mail: 0.00 (0.0%) Subject: Re: [patch] groups: integer underflow in groups_alloc() X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1621 Lines: 44 Dan Carpenter writes: > This is called from rsc_parse() with a use controlled value. Say for > example that "gidsetsize" is negative, then we could end up allocating > less than sizeof(struct group_info) leading to memory corruption. Right now it is the responsibility of the caller of groups_alloc to make certain that gidsetsize is a valid value, and the callers of groups_alloc who know what they are doing already validate this value. Either the pattern of caller validates the messages needs to continue, or groups_alloc needs to be changed and all of the callers need to be updated. Changing groups_alloc for one particular caller is just going to cause maintenance problems. Eric > Signed-off-by: Dan Carpenter > --- > I copied the NGROUPS_MAX limit from the surrounding code, I'm not > absolutely that it's the correct limit to use. > > diff --git a/kernel/groups.c b/kernel/groups.c > index 664411f..e9341b3 100644 > --- a/kernel/groups.c > +++ b/kernel/groups.c > @@ -18,6 +18,9 @@ struct group_info *groups_alloc(int gidsetsize) > int nblocks; > int i; > > + if ((unsigned)gidsetsize > NGROUPS_MAX) > + return NULL; > + > nblocks = (gidsetsize + NGROUPS_PER_BLOCK - 1) / NGROUPS_PER_BLOCK; > /* Make sure we always allocate at least one indirect block pointer */ > nblocks = nblocks ? : 1; -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/