Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp479528ybl; Tue, 28 Jan 2020 06:36:13 -0800 (PST) X-Google-Smtp-Source: APXvYqzo3NKMCZmCqGOU0BE1ErgGM216Sn2idBjVSYQoJoM8pTySFBsjoJ3xlmMBHvlUjFGx4MZP X-Received: by 2002:a05:6830:1d7a:: with SMTP id l26mr15924846oti.138.1580222173438; Tue, 28 Jan 2020 06:36:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580222173; cv=none; d=google.com; s=arc-20160816; b=aZR086pMJjuvMPzL2+/jyz89EeXbC4T1bgJbKOeUVJg1tcHWRcl2ZdrL8G+5yE3qXU 1/RIVoNCdaHGVBrSXOvxwUTLgap9dyAvopDZH1HyVg/B5qeYNl2y3uCr+6hexb5nINHU Gftj++hgrUv+QsC2ercXRvaKurjFnh6glTDh71vqQD7dzUtEh53n+sXs8MOQOjOJQfij 4Lxvcbw6FecT+saMi/XwoVTnxHpK5z6aDIvgXNlQWF/1upbQGwCTZhlAijrwYytfLSNs tjvopTk3hKw8yMBIuppjCHudtsGXK/dL9v6i+a+3pLgrO61z6J2nXQ4xBAceuNbNqJsp dLHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=OkZh595hEexmrzpDjLP4rBdsrocf40xZet7SmD3ZWt0=; b=iGxTvXFgE39+kzUYaJL9MR6H+x7NlfSuUdFu3Zn+Rjuv75S1ISDEXi+st+8c2OHXNJ RLRPQu6OGzbW+Zb1szfgg5y1tbFg9mJ6WdaUblx5bHaCs+esQTHAmRVp6opdKJjFbyMa YDM2Om5rFnd1qGY2U+7xQ/mqf84rLBcFXcXTm0njqv7NVqhm/WfnuiqijEWy4FPCKE7s iNuWU2ANoALQDRkw4r5lhNao14T1UAHHUISPWop+AGpcA6YNFJaZpryhch6sY0u7aX3R lJ0XbVsIY6DO8Y9piRgNQrskH1Pyh6nsrLKtCO4g6jEAbSp2ZSIUzzvN12MJUV1xzDJK XqLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=MlKuQXyB; 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 i9si9132673otp.139.2020.01.28.06.36.01; Tue, 28 Jan 2020 06:36:13 -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; dkim=pass header.i=@kernel.org header.s=default header.b=MlKuQXyB; 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 S1732126AbgA1OY3 (ORCPT + 99 others); Tue, 28 Jan 2020 09:24:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:51120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732541AbgA1OYZ (ORCPT ); Tue, 28 Jan 2020 09:24:25 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A804A21739; Tue, 28 Jan 2020 14:24:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580221465; bh=7Ra6XYIggFqUGPLCI3cb/b2nfYudOYiqxKkRdQa3n+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MlKuQXyBxZIKjYJ32jxaGC+UKHrDnw99dSbnD28sdIHSOFZBxC0GpzN+tCroH3t3/ PM24KITu0qiNrtDqFgwZXdHZ09eLJyGfXtSzKQWm+gK9cC0iJiMaJ1+9BEFmjusa3I Mq05wBarpW0azUpVRrbtnnTy212krk5KLB2fCSQY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ilja Van Sprundel , Michael Ellerman , "David S. Miller" Subject: [PATCH 4.9 236/271] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM Date: Tue, 28 Jan 2020 15:06:25 +0100 Message-Id: <20200128135910.120857970@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135852.449088278@linuxfoundation.org> References: <20200128135852.449088278@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Ellerman [ Upstream commit 3546d8f1bbe992488ed91592cf6bf76e7114791a = The cxgb3 driver for "Chelsio T3-based gigabit and 10Gb Ethernet adapters" implements a custom ioctl as SIOCCHIOCTL/SIOCDEVPRIVATE in cxgb_extension_ioctl(). One of the subcommands of the ioctl is CHELSIO_GET_MEM, which appears to read memory directly out of the adapter and return it to userspace. It's not entirely clear what the contents of the adapter memory contains, but the assumption is that it shouldn't be accessible to all users. So add a CAP_NET_ADMIN check to the CHELSIO_GET_MEM case. Put it after the is_offload() check, which matches two of the other subcommands in the same function which also check for is_offload() and CAP_NET_ADMIN. Found by Ilja by code inspection, not tested as I don't have the required hardware. Reported-by: Ilja Van Sprundel Signed-off-by: Michael Ellerman Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c @@ -2440,6 +2440,8 @@ static int cxgb_extension_ioctl(struct n if (!is_offload(adapter)) return -EOPNOTSUPP; + if (!capable(CAP_NET_ADMIN)) + return -EPERM; if (!(adapter->flags & FULL_INIT_DONE)) return -EIO; /* need the memory controllers */ if (copy_from_user(&t, useraddr, sizeof(t)))