Received: by 10.223.176.5 with SMTP id f5csp3434544wra; Mon, 29 Jan 2018 13:07:43 -0800 (PST) X-Google-Smtp-Source: AH8x226ucFVEaTiarVzQoO2/5swJ7A0CPll5jMokdgWDUvnTUzEqCr/DGrRdDCG2a7bx+P4tCI81 X-Received: by 2002:a17:902:9686:: with SMTP id n6-v6mr22561234plp.333.1517260062923; Mon, 29 Jan 2018 13:07:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517260062; cv=none; d=google.com; s=arc-20160816; b=N/MhiPkL/j9OTPbT1x/pNYfp97nE2UqPpoyPSItUBz364jIF3eWEy+zpfyi9v0KWfK RURGSdEk0YFBLJ+6APgUuLBZ/XQO3kIRDZ7Ddqk0YHHinZ9e7C4yPB72Ln6gRbEMz5ms hI93ifn1jLMHuDOdsE4yeOPh7Twfaq/UNgB2bLde5hqJ4HJIpAVaYDjzVj1AXfHbUqtE 04Puob5SK/2LBR0WtwOAeLnTL2J0IY/UOqO1kxi9sk9fl2GAjz5zGHaQfesW9FJeEDNL 0Gg3tuDs7wdBdV2Jbxfo61caN+Df0oeeM8NOw8Pdq9wLFwk6sbMqHZeetF1kvwDU+aM1 DSXg== 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=OHv2zbw7+J5ACIVgPS84bJhYHzfzeBNESYIx0QdxzHU=; b=VoPk3XJiC3P8rAZL72RmGD2h66wszB0Lea0EG0b3DTFa4raFNehiKQZxcpQn5ev4tH B5yNZYx2Sgik78dTs8TDihHWezGuRJa/edAvZ7N6dl7/qQayp1TbNAUI5/dZAeiwDmKK zYVlULRKBcYOfaLYnIZ5D0b9a7sSK8kehacGcU0eJd3w1cNEXRittxXA44KIB0aq40Ua vCXNWkw82ROvkgqjzci7b08npcvwI3eIOY47Y11+ncWr63fFknVDN3hxnUZq26CMecBD 7eHzhUjmYoqQ6A0czRDpWc+/1CkoNCXW3migDvMhzi2m/vJPQjxSaIDewHIqQDFPtVkL nU9A== 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 l3-v6si706655pld.558.2018.01.29.13.07.28; Mon, 29 Jan 2018 13:07:42 -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 S1751920AbeA2VGc (ORCPT + 99 others); Mon, 29 Jan 2018 16:06:32 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:48578 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752766AbeA2UGj (ORCPT ); Mon, 29 Jan 2018 15:06:39 -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 7CA4D2F0D; Mon, 29 Jan 2018 13:02:13 +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.4 40/74] netfilter: xt_osf: Add missing permission checks Date: Mon, 29 Jan 2018 13:56:45 +0100 Message-Id: <20180129123849.389817535@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180129123847.507563674@linuxfoundation.org> References: <20180129123847.507563674@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.4-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 @@ -69,6 +70,9 @@ static int xt_osf_add_callback(struct so 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; @@ -112,6 +116,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;