Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp493952ybl; Tue, 28 Jan 2020 06:50:11 -0800 (PST) X-Google-Smtp-Source: APXvYqwqAAY31OMQD6TeaWBInmx19W7IzzoDq7UvGkCM8D4PrlA7ZeOxZOUMzPMH3VVVWGWa4gpE X-Received: by 2002:aca:4994:: with SMTP id w142mr3013205oia.178.1580223011304; Tue, 28 Jan 2020 06:50:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580223011; cv=none; d=google.com; s=arc-20160816; b=MVY1DgkAB3fRDfPAj/RcPirgzJiFt/26Yu5rm+fir9o/sFPHnPpbSvSwlQzEMvIfMm E26BsxyqLhyr9HQoXdXyhmJQ1zEBY6RzHCure/z8q+czm+TJ3h5ItJqpFpO0vchO+GUk xP8V+AkVfn+Ov8EXMPD24XowE/J+zPPCugVojwhBFTFD0KuOFdCYjijUgz5PC4lf6i14 TqO1IZNOVjakO+eRdtPOfmMEzU2RIb6KCkvLsrAjwmb1MH4HFkLreSo+DAT/+U9DZMXc lsXPavEmQLg3F7VPUQA3PBS8uwng3TtcwujzDmOvHgSC25MiaKPxzGSfb+MTsvXNtxst 0CUA== 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=4gWzq/co4qouHx1J7FIPO5GynuNXMIM7O54O0oeN7Ak=; b=i7Qf/bduq+Rv+bsuTY9ttQmzvlV+9RNCcr53+SM3uRd3JNOEvOgJ150U6Fuk4x6qp3 LuS85Sihzfzhqo4TuR+DYln+n+bDMU4PCfXyKozicLGVR7hDidWUZBs++Nb3Buw2t7ef r8mBB2qaCmNuRE2dMSfOxxTPcgY+Ormvg47lPk6p+Ky4K+3OHqM1/rt0RZ+J9q6XzNLv pWJm2CL8VZRzMg+RbckdiHzw+yozhQ06ziFUkIaJgbLCcGvreyj2e6F2gcp497paVEZO Qw/0ctprSlOzM/ZdfQTIxwT0F1A3YRriRvEU/oRBCCkQsGhserZCTgunoPqfvzzj8L/S BQkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=r+3Fxzq+; 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 k125si2167065oib.212.2020.01.28.06.49.59; Tue, 28 Jan 2020 06:50:11 -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=r+3Fxzq+; 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 S1727535AbgA1OCD (ORCPT + 99 others); Tue, 28 Jan 2020 09:02:03 -0500 Received: from mail.kernel.org ([198.145.29.99]:48132 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726683AbgA1OB5 (ORCPT ); Tue, 28 Jan 2020 09:01:57 -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 6252624685; Tue, 28 Jan 2020 14:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580220116; bh=GblreWZ+JRtAI9Ywunt0o62CX5WRB6D8ta66N+lyYlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+3Fxzq+ra9s2sFdiIK8qNHJEyo7x3IxkB8uVj1eO0BfvZnex2aXIEA/0NUnJEjlp k3QNdc4pdPjuL49r0cbOiOWWwx9FpAd7s/zDfvsNU5mmJYW6rV4IXGfUC3ULQf9ZLK nVEFXvo0Lz4BWcas9rV3l6KLa5bP8eXYx0buPrME= 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 5.4 006/104] net: cxgb3_main: Add CAP_NET_ADMIN check to CHELSIO_GET_MEM Date: Tue, 28 Jan 2020 14:59:27 +0100 Message-Id: <20200128135818.138777535@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200128135817.238524998@linuxfoundation.org> References: <20200128135817.238524998@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 @@ -2448,6 +2448,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)))