From patchwork Fri Apr 25 12:30:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 342805 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id BC36A14016A; Fri, 25 Apr 2014 22:30:58 +1000 (EST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WdfHK-0003ze-K1; Fri, 25 Apr 2014 12:30:54 +0000 Received: from mail-qc0-f173.google.com ([209.85.216.173]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WdfHB-0003xD-Tg for kernel-team@lists.ubuntu.com; Fri, 25 Apr 2014 12:30:46 +0000 Received: by mail-qc0-f173.google.com with SMTP id r5so3928932qcx.32 for ; Fri, 25 Apr 2014 05:30:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=YxaTQoYKZMcHc5JzpPRjX01BlifngOUcpnqdzb8dBCY=; b=daf0Z+mlVlXyO22EyylN/HQDJk8QA6MA3O/ZRA0tyF16ERcTcefSImOok0nN8t56hj 8fizWXg0HdqJaXqgpaCDB+I6Aa9f/P2CK7pLcEGeDBlFfsPkAd3PDFIUo8NajaAqCvwH FWnJuJpU7gXS3kacrhxQC3FOIApbM7ry/wme1/mSrTjfe09tdPi+QtwPJUfH7iCv5am3 Uf8/GsBW+v5AFO53F0+2ZMFRUH/fsc0huwnQCnpWF1MF8pKIgStEOqG8F49DMsfNFrTo thNxpmwlrpqpitHLccQ1b3iFC7hGSiKUy07SiNr72ZspNJ2ZTWUwoqDN2+2ev7kFy0su faRA== X-Gm-Message-State: ALoCoQnN39CxMd/ImkP3p4QOM3MQc+0rB0TiCq23lKvIqVYiDFyeEqHLgxqDDi2LCgTovo3KFMp2 X-Received: by 10.224.49.131 with SMTP id v3mr3665067qaf.31.1398429045360; Fri, 25 Apr 2014 05:30:45 -0700 (PDT) Received: from localhost ([2001:470:6973:2:221:70ff:fe81:b177]) by mx.google.com with ESMTPSA id q62sm9408577qgd.0.2014.04.25.05.30.44 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 05:30:45 -0700 (PDT) From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [precise/lts-backport-raring-next 1/1] net: ipv4: current group_info should be put after using. Date: Fri, 25 Apr 2014 13:30:37 +0100 Message-Id: <1398429040-12559-2-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1398429040-12559-1-git-send-email-apw@canonical.com> References: <1398429040-12559-1-git-send-email-apw@canonical.com> Cc: Andy Whitcroft X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: "Wang, Xiaoming" Plug a group_info refcount leak in ping_init. group_info is only needed during initialization and the code failed to release the reference on exit. While here move grabbing the reference to a place where it is actually needed. Signed-off-by: Chuansheng Liu Signed-off-by: Zhang Dongxing Signed-off-by: xiaoming wang Signed-off-by: David S. Miller (cherry picked from commit b04c46190219a4f845e46a459e3102137b7f6cac) CVE-2014-2851 Signed-off-by: Andy Whitcroft --- net/ipv4/ping.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c index 3d8ddd9..69f3f3e 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -204,26 +204,33 @@ static int ping_init_sock(struct sock *sk) { struct net *net = sock_net(sk); kgid_t group = current_egid(); - struct group_info *group_info = get_current_groups(); - int i, j, count = group_info->ngroups; + struct group_info *group_info; + int i, j, count; kgid_t low, high; + int ret = 0; inet_get_ping_group_range_net(net, &low, &high); if (gid_lte(low, group) && gid_lte(group, high)) return 0; + group_info = get_current_groups(); + count = group_info->ngroups; for (i = 0; i < group_info->nblocks; i++) { int cp_count = min_t(int, NGROUPS_PER_BLOCK, count); for (j = 0; j < cp_count; j++) { kgid_t gid = group_info->blocks[i][j]; if (gid_lte(low, gid) && gid_lte(gid, high)) - return 0; + goto out_release_group; } count -= cp_count; } - return -EACCES; + ret = -EACCES; + +out_release_group: + put_group_info(group_info); + return ret; } static void ping_close(struct sock *sk, long timeout)