From patchwork Fri Apr 25 12:30:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 342807 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 19C1B14016A; Fri, 25 Apr 2014 22:31:12 +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 1WdfHY-00047p-6M; Fri, 25 Apr 2014 12:31:08 +0000 Received: from mail-qg0-f50.google.com ([209.85.192.50]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1WdfHH-0003yV-1V for kernel-team@lists.ubuntu.com; Fri, 25 Apr 2014 12:30:51 +0000 Received: by mail-qg0-f50.google.com with SMTP id 63so3875868qgz.37 for ; Fri, 25 Apr 2014 05:30:50 -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=XTdethJtA0LafhTCwrZjXR9u0UJEAbEvpGt7iaeYq94=; b=hz7jRqi0gJR7bnPKq9lM1Tz5iUKO4U2ao/qsCQ1Q1PEsnR1bh7HxQq+WnptxG3C4W1 8kiaykMp3dKEEbQy4ZDPaWdCuroc63erBUPLvA3JRKi8x3MATY6ohVkrTaQSLAqZiVfE aRUuac8UoEVM2knt62vuC1bgzjl/IJ9RcI09aDzjuy8WKcBOLA7PnR24Wb5IFg+Z8Nfp mrKiZL0nj151JhULymnKWuzwA/PdCGQESJs7MIyPVd5jHQU+kz/wXllZQIYSHdPETeBN HD4/jZO/nyEeKilRjJoE8EMmZ8u7wvk7PNLs+Fa5OngC1ajxAW0q18EpVnE0Sh5u4lUV OHmg== X-Gm-Message-State: ALoCoQnHTDsdU0KMBQi25dTCMNLnhXBxsQU/nTTh8tHXFDkMaH7tvkfUBiy28wlu+1erTWt9HqE0 X-Received: by 10.140.36.86 with SMTP id o80mr10319592qgo.25.1398429050471; Fri, 25 Apr 2014 05:30:50 -0700 (PDT) Received: from localhost ([2001:470:6973:2:221:70ff:fe81:b177]) by mx.google.com with ESMTPSA id r16sm9404293qgd.9.2014.04.25.05.30.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 25 Apr 2014 05:30:50 -0700 (PDT) From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [quantal 1/1] net: ipv4: current group_info should be put after using. Date: Fri, 25 Apr 2014 13:30:39 +0100 Message-Id: <1398429040-12559-4-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 (backported from commit b04c46190219a4f845e46a459e3102137b7f6cac) CVE-2014-2851 Conflicts: net/ipv4/ping.c 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 80c0847..83535ae 100644 --- a/net/ipv4/ping.c +++ b/net/ipv4/ping.c @@ -205,9 +205,10 @@ static int ping_init_sock(struct sock *sk) struct net *net = sock_net(sk); gid_t group = current_egid(); gid_t range[2]; - 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, range, range+1); low = make_kgid(&init_user_ns, range[0]); @@ -218,18 +219,24 @@ static int ping_init_sock(struct sock *sk) if (range[0] <= group && group <= range[1]) 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)