Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5761342imm; Mon, 23 Jul 2018 05:44:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeNNfXKyUIx+1e6T77m+EWlHDuJlT7vksSOhqAgzi1na38NkKdk308md07ivhBxhZcyjXE4 X-Received: by 2002:a17:902:b7c6:: with SMTP id v6-v6mr12430417plz.49.1532349899078; Mon, 23 Jul 2018 05:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532349899; cv=none; d=google.com; s=arc-20160816; b=Ox1YESev2b4ZZZV1ueZXLIm4s0LuPPVQY/Z95xjEydLwkQjgMWCSddOfAD52+pEtT2 IgOnM0EN2Fulblw3qNRrCnAlAKBnj/tGxbq0YtPBgubrzoBPybg/ABzapMoU+vQAcZO0 ck8h/LdK3i5pBE2+sjYYYvkhjwLWjFEae6nAPpKOzogEAlVU4JC0f1xNP4pdPj9EXuoX JDhy+kzdC29YKch0YThVbvB7EvfqH4lyc41n9pU5saLL8dpAW84m3kyvYLhRVG9Oue0c zOjxmvpyRnvkDKW2PTlFpZvPVGrhP1Zb6UMVIWmFdtmJO7B/yRL6NyWBEQ47UG9d/1bP +17Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=MCDUNrIVX5NYg+14H+elfGqFUyUjVgFOrxjcKjeQ4Wk=; b=XFLr9nxv/TC8cht+Koi49rzZvDorMPipKRq96A/km/sHM7KTGcRWcLvbsuxWaSbD9D DSf33llDRVT6XTIXd15to5JAfHeUsW4lzCjmqt0RjNa4KRNebunD81BUjIUh2KCrxBjf hccqvRrAXOJDya2id3PoCSs14wEbmxaabf7M8uKTJbGsVG10d/95MetP0Te9zYOa/cEK +F4XC9qbl1aLdYhp8i691jzdOgiThDTKTEvYEFtOHjBsXizh8Bt9uduBW98/Iaw4QRW2 kYTNkyeHD46mGh4jrA0sMkS67x2iMLDBk4pfc95V/zkj0vAuQcVp6K6/hD8SqQdnzFhy z03g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a128-v6si8623742pfb.81.2018.07.23.05.44.44; Mon, 23 Jul 2018 05:44:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388998AbeGWNok (ORCPT + 99 others); Mon, 23 Jul 2018 09:44:40 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48536 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388401AbeGWNoj (ORCPT ); Mon, 23 Jul 2018 09:44:39 -0400 Received: from localhost (LFbn-1-12238-233.w90-92.abo.wanadoo.fr [90.92.53.233]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 259BDC7D; Mon, 23 Jul 2018 12:43:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyler Hicks , "David S. Miller" Subject: [PATCH 4.4 008/107] ipv4: Return EINVAL when ping_group_range sysctl doesnt map to user ns Date: Mon, 23 Jul 2018 14:41:02 +0200 Message-Id: <20180723122413.312352857@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180723122413.003644357@linuxfoundation.org> References: <20180723122413.003644357@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tyler Hicks [ Upstream commit 70ba5b6db96ff7324b8cfc87e0d0383cf59c9677 ] The low and high values of the net.ipv4.ping_group_range sysctl were being silently forced to the default disabled state when a write to the sysctl contained GIDs that didn't map to the associated user namespace. Confusingly, the sysctl's write operation would return success and then a subsequent read of the sysctl would indicate that the low and high values are the overflowgid. This patch changes the behavior by clearly returning an error when the sysctl write operation receives a GID range that doesn't map to the associated user namespace. In such a situation, the previous value of the sysctl is preserved and that range will be returned in a subsequent read of the sysctl. Signed-off-by: Tyler Hicks Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv4/sysctl_net_ipv4.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/net/ipv4/sysctl_net_ipv4.c +++ b/net/ipv4/sysctl_net_ipv4.c @@ -141,8 +141,9 @@ static int ipv4_ping_group_range(struct if (write && ret == 0) { low = make_kgid(user_ns, urange[0]); high = make_kgid(user_ns, urange[1]); - if (!gid_valid(low) || !gid_valid(high) || - (urange[1] < urange[0]) || gid_lt(high, low)) { + if (!gid_valid(low) || !gid_valid(high)) + return -EINVAL; + if (urange[1] < urange[0] || gid_lt(high, low)) { low = make_kgid(&init_user_ns, 1); high = make_kgid(&init_user_ns, 0); }