Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp477817pxj; Thu, 20 May 2021 13:57:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhKAedHrMFjHgsmwq7W2Oy1ep8pvDMG6OCTkxgwRp71aIQ6+S6FeG64g6JiRVCVakNNIdq X-Received: by 2002:a17:906:13db:: with SMTP id g27mr6631701ejc.88.1621544239338; Thu, 20 May 2021 13:57:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621544239; cv=none; d=google.com; s=arc-20160816; b=KZwVgLkRoUzm6pc9+gbR3/JlTGt+DB1BuG4voPQBHFDp9yn0HFj9GtnKuEjFhxeRHV P0Qzvx+ZiAjnJjxWNHvUrCvMn38xFRCu2g/2xhINyPxbKpzz3SiAWN1b94m0MtL5PfPe UG7GzT8GqNNoKrlwgOCqFDIW/c4m7qtqeBIR5FRwFr77IaY8fwmIvh0HqyjYzs525hwH g2vAf73y4jcHGzQaFX+NvGiRQxE05O9BtIVDMNV5QQkeS8wUPmIqGqQey/anlzwc43Wq 1EG+VwzQQ0fC9/X1r/V1rEX46VnGY3CY2dz7V/QYxVyhl3O2IZXs/6uVTJCrIbQ5kK5s 9URg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XrtPmtpRa0IURBeO7nvn19uibSHPxc/dOLpUIzPmW+g=; b=gSXhBgXbrW9/rYbM02eHP5zuodIku3V14f+Gdqdmm3VzJIlP8dBnYXtviT2CqpBa6H WD/w7EH4OiWICOb707vkwO4CZqKpxm8copdOXhMtXkGsE+/2zjbJAWZLkDUlKKvt/eK4 Y6wPE6ibjLUFagn9ZqptmmMcVM/QqKeNqVRPWygMeSWD0EGTsCjsGl53jFvswx3GZl+S wuvN/SjlWaIB8xXFB0R+vphR+BWQ8qumuW7W6JL4ySGRQB9cH+nDihfpaRPAMOLPHfTP 6m+Ab433aVVCCsfx/mkMkdocQGF+Y4/tgUvbSugtU+czIMhhxIGOHVHwQA5ILt/Eadln P2eQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MKu9gjwS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp35si4148380ejc.141.2021.05.20.13.56.54; Thu, 20 May 2021 13:57:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MKu9gjwS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238666AbhETK5R (ORCPT + 99 others); Thu, 20 May 2021 06:57:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:44328 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237437AbhETKlQ (ORCPT ); Thu, 20 May 2021 06:41:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 48A6461C99; Thu, 20 May 2021 09:55:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504558; bh=szv2HLS/5Rd0Kx8gYLKoQ6jvjayXh5uwmj3A7gZYGlI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MKu9gjwSJYXTm1qbuMAT06dsRINTOuaNK8WQ48EhHRFSVh4ZF6W0O2CRrzDHpu3AB ZOAhZYwCMfCSvxCYUkzTCNObho0teveBE5kxf8pSlmfGIbk5Qd26bUcjlGgiEmF+SA V+VyGYjne9XHa0PIJDAKalPDtmkGYWnN5Yy5/JFs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathon Reinhart , "David S. Miller" Subject: [PATCH 4.14 300/323] netfilter: conntrack: Make global sysctls readonly in non-init netns Date: Thu, 20 May 2021 11:23:12 +0200 Message-Id: <20210520092130.514104922@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jonathon Reinhart commit 2671fa4dc0109d3fb581bc3078fdf17b5d9080f6 upstream. These sysctls point to global variables: - NF_SYSCTL_CT_MAX (&nf_conntrack_max) - NF_SYSCTL_CT_EXPECT_MAX (&nf_ct_expect_max) - NF_SYSCTL_CT_BUCKETS (&nf_conntrack_htable_size_user) Because their data pointers are not updated to point to per-netns structures, they must be marked read-only in a non-init_net ns. Otherwise, changes in any net namespace are reflected in (leaked into) all other net namespaces. This problem has existed since the introduction of net namespaces. The current logic marks them read-only only if the net namespace is owned by an unprivileged user (other than init_user_ns). Commit d0febd81ae77 ("netfilter: conntrack: re-visit sysctls in unprivileged namespaces") "exposes all sysctls even if the namespace is unpriviliged." Since we need to mark them readonly in any case, we can forego the unprivileged user check altogether. Fixes: d0febd81ae77 ("netfilter: conntrack: re-visit sysctls in unprivileged namespaces") Signed-off-by: Jonathon Reinhart Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conntrack_standalone.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/net/netfilter/nf_conntrack_standalone.c +++ b/net/netfilter/nf_conntrack_standalone.c @@ -631,8 +631,11 @@ static int nf_conntrack_standalone_init_ if (net->user_ns != &init_user_ns) table[0].procname = NULL; - if (!net_eq(&init_net, net)) + if (!net_eq(&init_net, net)) { + table[0].mode = 0444; table[2].mode = 0444; + table[5].mode = 0444; + } net->ct.sysctl_header = register_net_sysctl(net, "net/netfilter", table); if (!net->ct.sysctl_header)