Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1614792pxb; Thu, 4 Nov 2021 05:37:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5TXEYCH64cX6lcalD49TERKO54+S5eKcurk0/JtPgIxvQWCpCoS8xlE841t26ycXKHQwK X-Received: by 2002:a17:907:2627:: with SMTP id aq7mr54124299ejc.483.1636029459871; Thu, 04 Nov 2021 05:37:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1636029459; cv=none; d=google.com; s=arc-20160816; b=mSy9pWD9pgM60KmvvcMHEbVnacO2Ld8Hzdlx4Cp85Nd2h0FZ5496XkwBSvc2GMTRT5 mNOgJgg8uZMFAE9CtKiOyJwrCvsy+PZfBrofPdiMlY185X7SldRpzsRHbZd3BX3hnONY /F9901BY93o/1QhIZA8Jc4jTmz/82OSEBKHw78VCtZ8ilVM50mq7fvsJKqY5oBamMsGE 7CD+nGC0BTrmiKwPYaDusHccnWk7BvsY079vXxTOYoRfrdLNQVd+CroWp2uT3hl2TQax 36gPQSTe0yyaNjX251HDR5PGPHv8ytsi85B2nSIFELX8gJcaBNm6chnHVLI5nnnNikpy CAng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gTvExCAIQniJoHis0zPNIcgjI2X81k00ve1hFKX54uM=; b=g7UtuFHZCcyggxiY8Xj4usUe8oM/zl0bnb2KXJUuNXMvCu10akJogLtgBhDYFVvXqM U9T+WxfCO7k2EzYR5GLFDy9c0yhxgIe/JSCsyoDi9tDnKW0XnehNQ9YxDvPDeEi1kQGj OzYwabhp7NziCh8w5RQc3RJYfJ0zTgyQH606CCobqmmnDaletAhH0SWSexP6i+Hwqqpb xtwTT+D5wmiYoaYbdGLnM8sGZGGfbDsjU/KqUUaG2oiUrSEHqATIwcmK9GpDMkEEiNAh Sj8Pw5GftknlGt93F8sH+lMyCh/IARxjChEkHlqX5wss8NDvZ1cyy8a+mjlYdIGDzaJG 9iOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=2DgZrVNV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si8985836eje.649.2021.11.04.05.37.15; Thu, 04 Nov 2021 05:37:39 -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=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=2DgZrVNV; 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=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231185AbhKDMiG (ORCPT + 99 others); Thu, 4 Nov 2021 08:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45844 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhKDMiF (ORCPT ); Thu, 4 Nov 2021 08:38:05 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54BD6C061714; Thu, 4 Nov 2021 05:35:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=gTvExCAIQniJoHis0zPNIcgjI2X81k00ve1hFKX54uM=; b=2DgZrVNVn0KO/S5YqvnoQeU5qI 5NIJjAH3MmpmUkdV/waNALRuh3hiaylM/dYIWF3aC1NHZCBXIBgqPtkBSWkvFpQ1nj/ckiXEP1j8C S8dV6b3z2p+Q2arlftQHDTU6kdrhkvCwGr3Vv9nRv18lbojdO4df5z1J//gpKN/+bENpRAsKvVAU4 tt0Cah64EhMVhcba/nAp58tifAvp/UH1MTj8jCQsg07Dt8fnbFIic8Q447ewVdFIjaKR9c6sqRHvU ZwPEZvPWhziA7GTirM5H5ciPCxj6xf3hkBXXTErDfz1/Ph8wLLIMDgtPAC76YV/aIsUdO49keAIdp pWYKqVeg==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:55478) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mibxg-0005x4-6e; Thu, 04 Nov 2021 12:35:20 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mibxd-0007KM-7M; Thu, 04 Nov 2021 12:35:17 +0000 Date: Thu, 4 Nov 2021 12:35:17 +0000 From: "Russell King (Oracle)" To: Tobias Waldekranz Cc: Andrew Lunn , Grygorii Strashko , "David S. Miller" , netdev@vger.kernel.org, Jakub Kicinski , Heiner Kallweit , Florian Fainelli , linux-kernel@vger.kernel.org, Vignesh Raghavendra , Sean Anderson Subject: Re: [RFC PATCH] net: phy/mdio: enable mmd indirect access through phy_mii_ioctl() Message-ID: References: <828e2d69-be15-fe69-48d8-9cfc29c4e76e@ti.com> <8d24c421-064c-9fee-577a-cbbf089cdf33@ti.com> <01a0ebf9-5d3f-e886-4072-acb9bf418b12@ti.com> <87pmrgjhk4.fsf@waldekranz.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87pmrgjhk4.fsf@waldekranz.com> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 04, 2021 at 12:17:47PM +0100, Tobias Waldekranz wrote: > On Wed, Nov 03, 2021 at 20:36, Andrew Lunn wrote: > > On Wed, Nov 03, 2021 at 08:42:07PM +0200, Grygorii Strashko wrote: > >> > >> > >> On 03/11/2021 02:27, Andrew Lunn wrote: > >> > > > What i find interesting is that you and the other resent requester are > >> > > > using the same user space tool. If you implement C45 over C22 in that > >> > > > tool, you get your solution, and it will work for older kernels as > >> > > > well. Also, given the diverse implementations of this IOTCL, it > >> > > > probably works for more drivers than just those using phy_mii_ioctl(). > >> > > > >> > > Do you mean change uapi, like > >> > > add mdio_phy_id_is_c45_over_c22() and > >> > > flag #define MDIO_PHY_ID_C45_OVER_C22 0x4000? > >> > > >> > No, i mean user space implements C45 over C22. Make phytool write > >> > MII_MMD_CTRL and MII_MMD_DATA to perform a C45 over C22. > >> > >> Now I give up - as mentioned there is now way to sync User space vs Kernel > >> MMD transactions and so no way to get trusted results. > > Except that there is a way: https://github.com/wkz/mdio-tools I'm guessing that this hasn't had much in the way of review, as it has a nice exploitable bug - you really want "pc" to be unsigned in mdio_nl_eval(), otherwise one can write a branch instruction that makes "pc" negative. Also it looks like one can easily exploit this to trigger any of your BUG_ON()/BUG() statements, thereby crashing while holding the MDIO bus lock causing a denial of service attack. I also see nothing that protects against any user on a system being able to use this interface, so the exploits above can be triggered by any user. Moreover, this lack of protection means any user on the system can use this interface to write to a PHY. Given that some PHYs today contain firmware, this gives anyone access to reprogram the PHY firmware, possibly introducing malicious firmware. I hope no one is using this module in a production environment. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!