Received: by 10.223.176.5 with SMTP id f5csp3392852wra; Mon, 29 Jan 2018 12:31:46 -0800 (PST) X-Google-Smtp-Source: AH8x227znuZc46aDCNpo+ENhkt/qaSaqtwKWrww3TvaOqOHDe4+qRzambmTRxdB2zsngR/DMUSvI X-Received: by 2002:a17:902:fa2:: with SMTP id 31-v6mr21987427plz.346.1517257906174; Mon, 29 Jan 2018 12:31:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517257906; cv=none; d=google.com; s=arc-20160816; b=IzdRs2DL8ArqjWkSIWAKZ0r+SFunpMiuDkJH/Y8t5aFGrTSsHe/D+2TSteUObbarPI y5RSlVCttvYBmZgJ08SHt9PTEtxJ7uqwKb0OESbxFfOgoq+saZRiVhCfHaS4nBSo8pJC PoX9PZT/y5elmjT7sTtU73OMJJfFw2/dCwn4CJloN55O6QnUOYc2NWOY1B9gbIGhMFPK YC2W9ptP0IA193obR0i1mB8gfLF8SKum7srbyxE47X8QYKGjtSB1bqZOwnSOAPv46drh LlHZXIkJrRzWi16as3mwXzcPAIVkDwZzbyHQiXiK6Hlc1CU+lBxGrDST9zvKiUWf9+A7 kS4A== 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=XeU69S1Mvip5JgOZ43ed4y1w7e0cxzwvcx1WO3LKJso=; b=UVxzALuqS5fRhucCJ88b9/Nkm5M/1FP70yorSCGLTif2STZvNKUWfhf1kUwyQcgXzo qJQTbvNMjD7PXRHoNlJ381CQYHHLlxT7YApRgW3gUF39QLULQ9W8v8cPh7tyZ0t4bl2U zcXYGJiofqm071mGuf9RU7RgkFuu5fipwX5XcWDXX/idxwuG6NcnPwWdwlVID3HFbFUI jEn4fC1iENIWEhLqoTZImDQilt2DcTxHrx2L5Bf9gESVVJYYPffZoEfCgFtYv5+EuDEk /wgPC4nVaTcRuBdguHdSGCpx50KSugYGdAfv3utXbSwqdILeUHcXSzoCOI9lsdr5NBxi A4cA== 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 i135si7954980pgc.459.2018.01.29.12.31.31; Mon, 29 Jan 2018 12:31:46 -0800 (PST) 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 S932651AbeA2Ua4 (ORCPT + 99 others); Mon, 29 Jan 2018 15:30:56 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42796 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754177AbeA2UP1 (ORCPT ); Mon, 29 Jan 2018 15:15:27 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B3ACD2FFF; Mon, 29 Jan 2018 13:08:57 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kevin Cernekee , Pablo Neira Ayuso , Michal Kubecek Subject: [PATCH 4.14 05/71] netfilter: xt_osf: Add missing permission checks Date: Mon, 29 Jan 2018 13:56:33 +0100 Message-Id: <20180129123827.693106349@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123827.271171825@linuxfoundation.org> References: <20180129123827.271171825@linuxfoundation.org> User-Agent: quilt/0.65 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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kevin Cernekee commit 916a27901de01446bcf57ecca4783f6cff493309 upstream. The capability check in nfnetlink_rcv() verifies that the caller has CAP_NET_ADMIN in the namespace that "owns" the netlink socket. However, xt_osf_fingers is shared by all net namespaces on the system. An unprivileged user can create user and net namespaces in which he holds CAP_NET_ADMIN to bypass the netlink_net_capable() check: vpnns -- nfnl_osf -f /tmp/pf.os vpnns -- nfnl_osf -f /tmp/pf.os -d These non-root operations successfully modify the systemwide OS fingerprint list. Add new capable() checks so that they can't. Signed-off-by: Kevin Cernekee Signed-off-by: Pablo Neira Ayuso Acked-by: Michal Kubecek Signed-off-by: Greg Kroah-Hartman --- net/netfilter/xt_osf.c | 7 +++++++ 1 file changed, 7 insertions(+) --- a/net/netfilter/xt_osf.c +++ b/net/netfilter/xt_osf.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -70,6 +71,9 @@ static int xt_osf_add_callback(struct ne struct xt_osf_finger *kf = NULL, *sf; int err = 0; + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (!osf_attrs[OSF_ATTR_FINGER]) return -EINVAL; @@ -115,6 +119,9 @@ static int xt_osf_remove_callback(struct struct xt_osf_finger *sf; int err = -ENOENT; + if (!capable(CAP_NET_ADMIN)) + return -EPERM; + if (!osf_attrs[OSF_ATTR_FINGER]) return -EINVAL;