From patchwork Tue Feb 24 15:34:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 5873411 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62AE6BF440 for ; Tue, 24 Feb 2015 15:34:53 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 918602037E for ; Tue, 24 Feb 2015 15:34:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A578C20379 for ; Tue, 24 Feb 2015 15:34:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbbBXPea (ORCPT ); Tue, 24 Feb 2015 10:34:30 -0500 Received: from userp1040.oracle.com ([156.151.31.81]:25449 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750748AbbBXPe3 (ORCPT ); Tue, 24 Feb 2015 10:34:29 -0500 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t1OFYHZO012923 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 24 Feb 2015 15:34:18 GMT Received: from userz7022.oracle.com (userz7022.oracle.com [156.151.31.86]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id t1OFYEDw018565 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 24 Feb 2015 15:34:15 GMT Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userz7022.oracle.com (8.14.5+Sun/8.14.4) with ESMTP id t1OFYDKv013030; Tue, 24 Feb 2015 15:34:13 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 24 Feb 2015 07:34:12 -0800 Date: Tue, 24 Feb 2015 18:34:01 +0300 From: Dan Carpenter To: "J. Bruce Fields" Cc: Trond Myklebust , Anna Schumaker , "David S. Miller" , Jeff Layton , Kinglong Mee , linux-nfs@vger.kernel.org, netdev@vger.kernel.org, "Eric W. Biederman" , Andrew Morton , Andy Lutomirski , Wang YanQing , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [patch v2] sunrpc: integer underflow in rsc_parse() Message-ID: <20150224153401.GA12218@mwanda> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150223211607.GB28635@fieldses.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: acsinet22.oracle.com [141.146.126.238] Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If we call groups_alloc() with invalid values then it's might lead to memory corruption. For example, with a negative value then we might not allocate enough for sizeof(struct group_info). Signed-off-by: Dan Carpenter --- v2: In v1, I changed groups_alloc(). The other places which call groups_alloc() check the value before calling. Eric wanted that, either have all the callers check, or all the callers rely on groups_alloc(). In the end, Bruce Fields said adding the check here was probably reasonable. -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 224a82f..1095be9 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -463,6 +463,8 @@ static int rsc_parse(struct cache_detail *cd, /* number of additional gid's */ if (get_int(&mesg, &N)) goto out; + if (N < 0 || N > NGROUPS_MAX) + goto out; status = -ENOMEM; rsci.cred.cr_group_info = groups_alloc(N); if (rsci.cred.cr_group_info == NULL)