Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp2223507rdb; Mon, 20 Nov 2023 05:42:27 -0800 (PST) X-Google-Smtp-Source: AGHT+IHdq0HcDEAxf2tzf2j0QXB8TnCehFLttbwng1t3PmmwleiXd3wyLfBk/2MIGgTQq3xcT++z X-Received: by 2002:a05:6a20:861d:b0:187:152d:c1e2 with SMTP id l29-20020a056a20861d00b00187152dc1e2mr3713295pze.46.1700487747315; Mon, 20 Nov 2023 05:42:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700487747; cv=none; d=google.com; s=arc-20160816; b=oHyzNZZIIMjCkci0vdeB1eko7Br6xYiM8ffcLiSKzdK2dOrGJnoCfMn6GqnK77a83H qHcPHCbmPxlZczwH5in+XHM+FikOpuTbCL4YlPdUJ1zLW0IVYw4zx5fpRNrrSx5F1ok6 ykdCSYRvnjpccAeeuUd2EDi/hQpQ5DLsZedJd/tlcwhiZvZISsYJwQW9azjHk90eWxf/ K5qV4hNtWg/grXlIEhXziBKl1/tY8qAHGhImCD/K3ruOJ5+qZkfYPWIs7hi+9nT5AcUy vnHUi1mDb58v3cgx0915OIKexxOyXgD5J9vA6XeI+K7udolwb7EnU+kY7uisT1Kb1L6f L5KA== 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=c0jEFenPI665cRskmAiFDtYQkHXkawiJhPQ0fqLm3E0=; fh=ICNw+ZbXRqSikCFIL/H5EijSsqCBVAhnBl+64lIaDNw=; b=ae4hMrnOcYynmPrQFzJBlE8WI5h3PZA/FMMUZkYp5qGiJglEQw/Tzedi7VvGkmPwOE Ey235V4ezldXIcqpR+U9AK4EPqHB6pGeE7cPWnld5rA4GznXtoZB27H2s04FtzD9xi/5 p+b1u0xLKHetC2DNB6qZkGy/1v8OFMJ+KBG7TWKwwpfHUHCs0jfwZEiNWCi25N6YLfSK t8J6ORJYyMI5MxnF0OcOQvX+IWuoePDcIOU1AeBqGEhwI6RCKyUz7Ma5Qb406FbDDuNK gvtxmhDNRl87HWWsCZfoWS+3FNuf9iw2IWE4saDXZVwerKwNMcDFV+TSEwNjViYSi0f5 IoBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="sTkMdBg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id k38-20020a63ff26000000b005acd3068202si8062426pgi.552.2023.11.20.05.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Nov 2023 05:42:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b="sTkMdBg/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 8B0D680417C1; Mon, 20 Nov 2023 05:42:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232200AbjKTNmT (ORCPT + 99 others); Mon, 20 Nov 2023 08:42:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbjKTNmS (ORCPT ); Mon, 20 Nov 2023 08:42:18 -0500 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 AE8B9113; Mon, 20 Nov 2023 05:42:14 -0800 (PST) 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=c0jEFenPI665cRskmAiFDtYQkHXkawiJhPQ0fqLm3E0=; b=sTkMdBg/31M+ezs+Gyzl4C0S3w lRA0kgzv9hRJIZO1T21tS2EDACESvMgOQY8l8AOwfG3q46V676MgC0WASxVGunZbqIa9/vQrOeU6r K+OMfx+YscaNTWnVz2yKzAnFyjo4cEqTKpx1uXWurYefi6fWoARuUd2WsEnuJZE4jHr0jHhn94wEo oWYbo1fU5MoXnTP8ovuR6/gL+9NupkqYR0Vhn3nKbaBMa3erjH6RIvkmbAc8y1O7pk22Z+UTUvHRP 7CJ3wmCoOEfbACxOxHTZxfWFB8G4XjxjKYRcJ4mk/W4ZCDaVwcsKOFJRn23nGwIldJ1KNEZWlln/2 y5hjw6zw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:58828) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1r54XN-0005ch-01; Mon, 20 Nov 2023 13:42:05 +0000 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1r54XN-0003Dr-Fk; Mon, 20 Nov 2023 13:42:05 +0000 Date: Mon, 20 Nov 2023 13:42:05 +0000 From: "Russell King (Oracle)" To: Lukas Funke Cc: Andrew Lunn , Heiner Kallweit , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Lukas Funke , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] net: phy: Fix potential null pointer access Message-ID: References: <20231120093256.3642327-1-lukas.funke-oss@weidmueller.com> <2508da6b-a099-4271-a1d0-04cfe5d39daf@weidmueller.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2508da6b-a099-4271-a1d0-04cfe5d39daf@weidmueller.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 20 Nov 2023 05:42:23 -0800 (PST) On Mon, Nov 20, 2023 at 01:38:06PM +0100, Lukas Funke wrote: > Hi Russel, > > On 20.11.2023 10:51, Russell King (Oracle) wrote: > > On Mon, Nov 20, 2023 at 10:32:54AM +0100, Lukas Funke wrote: > > > From: Lukas Funke > > > > > > When there is no driver associated with the phydev, there will be a > > > nullptr access. The commit checks if the phydev driver is set before > > > access. > > > > What's the call path that we encounter a NULL drv pointer? > > > The patch is a bit older and the path is reconstructed from my memory: > > macb_phylink_connect -> phylink_of_phy_connect -> of_phy_connect -> > phy_connect_direct -> phy_request_interrupt > > It happend when we used the Xilinx gmii2rgmii phy driver. We did a > missconfiguration in the dt and bumped into the nullpointer exception. Since > other functions like phy_aneg_done() also check for driver existence I > thought it would be a good addition. So how does this happen in the path you indicate? phy_connect_direct() calls phy_attach_direct() before calling phy_request_interrupt(). If phy_attach_direct() needs to succeed for us to get to call phy_request_interrupt(). phy_attach_direct() checks to see whether the phydev is bound to a driver. If it isn't, it binds it to the appropriate genphy driver. As part of that binding, phydev->drv is guaranteed to be set (by phy_probe(), which will be called via d->driver->probe() if using one of the genphy drivers. You mention using the gmii2rgmii driver, which does mess with phydev->drv, but I can't see a way in that driver where we would end up with a NULL pointer there. I think a bit mroe information is needed to describe how this comes about - and that needs to go in the commit message, so the reason for this patch is properly documented. Thanks. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!