From patchwork Thu Feb 15 18:27:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13559055 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-vk1-f170.google.com (mail-vk1-f170.google.com [209.85.221.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D56E13A86F for ; Thu, 15 Feb 2024 18:27:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021660; cv=none; b=OzKq9P5F91QVElNgNBX266DdhxLEpCW8P0zGFIUcEM+h4gB/aFXqCcQJVL7cMVfR0uQ0DNLd1els9JThP8aM6WuhMR2lqITWE9VQqqrT58As3pXQVhSp2Q2bR4XVeFzIbmuAqTOO9Za2dJVBC53ZBz+1vtQ9uch97pGCtJqV8es= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021660; c=relaxed/simple; bh=uojcWBOoSn7XqblZfDYnYRLq8qK0Q8wxNU53TgQOzMg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=Bc4F+J0iRJAIT2/hlU0dKV06VnpqzGpCiqQ/GZ1tmyq1JK6asPBgj5UEtXTTSfKX3jSpxSxXYBkYKnYp2TSSCxxoJW2J9zzmx9pFPwtjISdY+JWjP+vY53/MtsOpfx+BLXnWZHtL0ymrC8DLRMqV4ZtDboCGsfeyHfcXzK4q/+4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=BT8i8J9b; arc=none smtp.client-ip=209.85.221.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="BT8i8J9b" Received: by mail-vk1-f170.google.com with SMTP id 71dfb90a1353d-4c0375d438eso447742e0c.0 for ; Thu, 15 Feb 2024 10:27:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708021658; x=1708626458; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Dm9N87hfmQQHAIvjJyt050gbg8DpzraaCt9t68u+Ocw=; b=BT8i8J9bmhC96ME4+BZ9JgShGt+MvMXBO4b4y1e7HTlwPrQqQJWAk4+OVYK64JFSkm OUPBLw7VHRf15aHubpGzqt1AabHmnnuFnlcG3N6ghdM7jpSZ4s8z6qB35uBmw5aYOhwg XfCdN4CxWfV4sbl0b2a0BBtTr2bA1BOkZAkaI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708021658; x=1708626458; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Dm9N87hfmQQHAIvjJyt050gbg8DpzraaCt9t68u+Ocw=; b=HLzS8mqx++ve5okqrzrL/Az2n2+IyOj2ZzDJ/QcPFZj1DeNf2QUpcj0QR+8kCAYsXk WkBK0fF15zUMokeizcmdnWRmyT9E8kKSx2Y5PSKPpvz5UrJjBYknKUL0hJ2n/VbQz4Ig VuDB1p6pRJRp8jiPiNWLE/vCVLr6BoEoSX040AiyEXMn7S/nV6BLMl/3aC4W/0yVD3Qo IGNa+4BVH5rHIkxHZ4JncOWb4OJAyAIb4mOW212ty7GKZFW4TjCEVCJ6IVQgcgOZBs+i uz7y2HZtqWkeFXtdxuS4zvnM3MF3Rcq+aFOBWW1eq2XJyOXH3QK39IhJyoTLFgjLP8t+ U86g== X-Gm-Message-State: AOJu0YwWDAnSZoNvor5J0xY9Ut3NUKHvjIGZkoqvecKNwT8Vt9Cv2roR FvBvqyvBaQuQqGvk18POwlDtkBb3c3YZilSYzd6sYZ765ADT82/olnKSLseLLGGgtj80M9ZE5Gu C88Agog73Lb6mnKzpUq1HzKy/k3OGP9+bZ6f4BtrTsyVb/62YH5y49HUcPY5QpxKBl7TvJR4Rjx DQiY5GlPfWJmRf2EeTHl7Y0y/Qcn9W35WJKYpsyl8r/w== X-Google-Smtp-Source: AGHT+IEJrb2s5dSVNf4U1V5s6hi41ipLrWEX6HPDvSozHkleaielqpnvAD2/Ofm/m/mdGTo5JNzabw== X-Received: by 2002:a1f:e042:0:b0:4c0:fda:7d8c with SMTP id x63-20020a1fe042000000b004c00fda7d8cmr2724538vkg.2.1708021657784; Thu, 15 Feb 2024 10:27:37 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id mf4-20020a0562145d8400b0068f13038031sm901515qvb.5.2024.02.15.10.27.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:27:37 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: Florian Fainelli , Justin Chen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM ASP 2.0 ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] net: bcmasp: Indicate MAC is in charge of PHY PM Date: Thu, 15 Feb 2024 10:27:31 -0800 Message-Id: <20240215182732.1536941-2-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215182732.1536941-1-justin.chen@broadcom.com> References: <20240215182732.1536941-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Florian Fainelli Avoid the PHY library call unnecessarily into the suspend/resume functions by setting phydev->mac_managed_pm to true. The ASP driver essentially does exactly what mdio_bus_phy_resume() does. Fixes: 490cb412007d ("net: bcmasp: Add support for ASP2.0 Ethernet controller") Signed-off-by: Florian Fainelli Signed-off-by: Justin Chen --- drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index f59557b0cd51..6ad1366270f7 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -1050,6 +1050,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) netdev_err(dev, "could not attach to PHY\n"); goto err_phy_disable; } + + /* Indicate that the MAC is responsible for PHY PM */ + phydev->mac_managed_pm = true; } else if (!intf->wolopts) { ret = phy_resume(dev->phydev); if (ret) From patchwork Thu Feb 15 18:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13559056 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-oi1-f178.google.com (mail-oi1-f178.google.com [209.85.167.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E766D13A886 for ; Thu, 15 Feb 2024 18:27:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021662; cv=none; b=SR/wYCtqlcgHl98RjD14RXiGgijcpB4MIylK3O7PSvq/J9f5QmHF+z2UUv5ueBG0Q6SVQcWc8KbNMnodcJGGGSE+WkLvlPuYhXKVIWgByoBi0ubE7aRXJazY16Akxv3crEOJ+MzB3yDUmhO17CMbpASMXuCfthP9RERnqpoZ8UA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708021662; c=relaxed/simple; bh=ie+iGNEbrInmXeM7EUsBPBcgubCE4VG7+3jCyBzKxUo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=ik45w95OSo4bRT01qzO/i1HSjBNn6EcvsqKX3rShO/kD3frYtOhRGoC5sB6J6r6EFQiGpB5TN9BfmdxcjKizYOotaxbY4484YPneE5QF00WlK6TV965TIc7q292AzFAiRN/b/AuGZ9/RdvjLekySQw2e90bWb1yVjsWKn9sdASs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=dkocPXiw; arc=none smtp.client-ip=209.85.167.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="dkocPXiw" Received: by mail-oi1-f178.google.com with SMTP id 5614622812f47-3c132695f1bso923899b6e.2 for ; Thu, 15 Feb 2024 10:27:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708021660; x=1708626460; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=DjN0KrN4K8ta78wKaCE8wWbE++XwSGRWgX9GpS4l5Vc=; b=dkocPXiwKxPjNKvKpn1Giz/yJsLYGr08t/1oDKqQPxhngCye9Toe5F12ArYExOYp1C nxN0p/eHoTUcsqSCPNyxJ5jvkdEWvA8w3PzC+FlZB+bG5KgONkTGQF7/jcyQOfTG4s8r HVqhkBI2cy05zn8sSdlCykqe8ApGLZq50vMOg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708021660; x=1708626460; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=DjN0KrN4K8ta78wKaCE8wWbE++XwSGRWgX9GpS4l5Vc=; b=BE0InFPNsJOTs58+Hp5mqDVuJni9mX4q8fPWCFcLvACWu7BotljcNgCK6Uozmxt7MU 5NFCDHspMRxBgxh1abOBfqf3jH1A7jwnYfdpsXNZ1cwlgKbVIipvh00fbtruPUYJ/eYF ra7EK5gG+iZA2iK7TfqQ4wZlkNuJtIeVx4Mfu0OHlNRZpBmo3zlGqChB9GrEghzAbdlW MWY+9e+u2y9UIg7frfvFPmKlWxp51hqrfQ4uPo7QwKo6QXfDj08rySgRoeYhuyJOGDYF RE745zs+vrTRxenfy12HpTvNG407ZQ+C1FSW/x3TBluyAtjMcoz82sTnm9gAvu4/vK0O GUrw== X-Gm-Message-State: AOJu0Yyn+KqF3RsgAzcr+/dcwLzqoXfBf2nYslGmRspJYFfhIQbUlOnX j4+6GCGTPdlAUpUuQEnS1Ghu+6zmz0N+WyCzV3ezteugu/S3jHt1o7hn4oSOsP3ivY61j2CDsG/ QP+Briv1DYfqb5Wm3eHJkVTsZXTZJmdnzMXWmWSMdV2SQ//eurfxvQ2P/MeJ8L8PGCQXyHCsZ6Z FbUS4j8AIUq5sC6vK3uUkhWc+60qWAViLbTNQPX7nGwQ== X-Google-Smtp-Source: AGHT+IHmhET1pIJGjsljlBZCoPCqcZ+qIT9ia2lHH5LqZUw/o0RXU9TJFUjekxtmoP5WcjUZzAj/nQ== X-Received: by 2002:a05:6808:9a3:b0:3c0:326a:9cff with SMTP id e3-20020a05680809a300b003c0326a9cffmr2709373oig.23.1708021659611; Thu, 15 Feb 2024 10:27:39 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id mf4-20020a0562145d8400b0068f13038031sm901515qvb.5.2024.02.15.10.27.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 10:27:39 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: Justin Chen , Florian Fainelli , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Hangyu Hua , bcm-kernel-feedback-list@broadcom.com (open list:BROADCOM ASP 2.0 ETHERNET DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] net: bcmasp: Sanity check is off by one Date: Thu, 15 Feb 2024 10:27:32 -0800 Message-Id: <20240215182732.1536941-3-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240215182732.1536941-1-justin.chen@broadcom.com> References: <20240215182732.1536941-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org A sanity check for OOB write is off by one leading to a false positive when the array is full. Fixes: 9b90aca97f6d ("net: ethernet: bcmasp: fix possible OOB write in bcmasp_netfilt_get_all_active()") Signed-off-by: Justin Chen Reviewed-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index 29b04a274d07..80245c65cc90 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -535,9 +535,6 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, int j = 0, i; for (i = 0; i < NUM_NET_FILTERS; i++) { - if (j == *rule_cnt) - return -EMSGSIZE; - if (!priv->net_filters[i].claimed || priv->net_filters[i].port != intf->port) continue; @@ -547,6 +544,9 @@ int bcmasp_netfilt_get_all_active(struct bcmasp_intf *intf, u32 *rule_locs, priv->net_filters[i - 1].wake_filter) continue; + if (j == *rule_cnt) + return -EMSGSIZE; + rule_locs[j++] = priv->net_filters[i].fs.location; }