From patchwork Wed Jul 10 11:42:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13729230 X-Patchwork-Delegate: kuba@kernel.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CD30618FA02; Wed, 10 Jul 2024 11:42:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720611763; cv=none; b=S+2zRl2cVEx0GIbAcc3iKe2Nc4KAmbcgtnf/4DkIp85va7Sd60trFrII1qvuATFfZN8UBbCsAOIq8XPtKeIWKFfFwK/AS8DJ0lFi+MucUmMSzbpSaK0QdIWFzvwTLI9Uq/DlKNX5rhLsIqxmstkvwliPV8uwjtK1FfEuEQRi5d4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720611763; c=relaxed/simple; bh=znjGy39C1npmblToIx+FyOtCMLLb0RTKiAz/2zeJerk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=Ouq2fH1Qt0SxhGFXJvwBrGN5mtuF6AIaoJCu+v7x3luuQCvPlAUGFGCGnIth0+1Rp94xZz8r325aDSevP9fdHqUWT9uVOZqRneoWZnUkwB0nk0fYglgSZFGU4RA84rBT6mBRRccdi+17U1YUsBbPDz1fwh6brufz5OL0H+H/t+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=RyJ0N4ou; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="RyJ0N4ou" Received: by mail.gandi.net (Postfix) with ESMTPSA id 21D9820007; Wed, 10 Jul 2024 11:42:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720611759; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=wuDJHn3ercIUcLR103Clt+Q0LNc7jTkBi80l92bbsqo=; b=RyJ0N4ouBMDoHXQ4N0LedKERGxZxyGYEGqUdU8tcssY34b/FIZl2Nw37uxhXvA+bAHvUas vnuPBlMWDpaT7VBUBI3+tPRPiVCkGrYv/MHm37PkKrZ8eFZd5L9Al/Sl51xcTDPH8oLWQ2 hx48+uGkLF44k90aRNUyyGznF/jaWO9RNgBaPHE1tlUk+GPncB3i62GuXgDu1JT+ChrXRz RdkupUaB1/MluXNjXbM0WyBlD5lULQjsyHnyxGt4IgKyUQzCM1ljLtJWt3g0DsQP9r4DFv 7oVX3nvPUxcJcGSiGHt3vYk9R8/ABNtV8sURCgdOd939//hd5e577kMgLX2Hag== From: Kory Maincent To: Andrew Lunn , "Kory Maincent (Dent Project)" , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, Oleksij Rempel , "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH v2 1/2] net: pse-pd: Do not return EOPNOSUPP if config is null Date: Wed, 10 Jul 2024 13:42:30 +0200 Message-Id: <20240710114232.257190-1-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: kory.maincent@bootlin.com X-Patchwork-Delegate: kuba@kernel.org For a PSE supporting both c33 and PoDL, setting config for one type of PoE leaves the other type's config null. Currently, this case returns EOPNOTSUPP, which is incorrect. Instead, we should do nothing if the configuration is empty. Signed-off-by: Kory Maincent Fixes: d83e13761d5b ("net: pse-pd: Use regulator framework within PSE framework") --- Changes in v2: - New patch to fix dealing with a null config. --- drivers/net/pse-pd/pse_core.c | 4 ++-- net/ethtool/pse-pd.c | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c index 795ab264eaf2..513cd7f85933 100644 --- a/drivers/net/pse-pd/pse_core.c +++ b/drivers/net/pse-pd/pse_core.c @@ -719,13 +719,13 @@ int pse_ethtool_set_config(struct pse_control *psec, { int err = 0; - if (pse_has_c33(psec)) { + if (pse_has_c33(psec) && config->c33_admin_control) { err = pse_ethtool_c33_set_config(psec, config); if (err) return err; } - if (pse_has_podl(psec)) + if (pse_has_podl(psec) && config->podl_admin_control) err = pse_ethtool_podl_set_config(psec, config); return err; diff --git a/net/ethtool/pse-pd.c b/net/ethtool/pse-pd.c index 2c981d443f27..982995ff1628 100644 --- a/net/ethtool/pse-pd.c +++ b/net/ethtool/pse-pd.c @@ -183,7 +183,9 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info) if (pse_has_c33(phydev->psec)) config.c33_admin_control = nla_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL]); - /* Return errno directly - PSE has no notification */ + /* Return errno directly - PSE has no notification + * pse_ethtool_set_config() will do nothing if the config is null + */ return pse_ethtool_set_config(phydev->psec, info->extack, &config); } From patchwork Wed Jul 10 11:42:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13729231 X-Patchwork-Delegate: kuba@kernel.org Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [217.70.183.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC0C818FDC4; Wed, 10 Jul 2024 11:42:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.200 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720611764; cv=none; b=P4zS3KnxZCs6Mjy/XRi3XXO10vedC8dLrr/5YlYjjLCpbnnAnDC6fJYm6J0FGg7Z0nwb3IHX8q8T/qGi0PTlbjd6CGoqlEdEy9Lox1fS69lqvMfTiGFtqWLFVx3svfylZlHxcjNt1xJIXeeCYbNMfjNPpN4Pfx3J69lhNPAIXj8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720611764; c=relaxed/simple; bh=saEXLfnetRqCX2p7vcE7tLJrTm/XEutrHu/3Vi+j1LU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pvfyfxjBTWKeU59uqhx0gyT8EY8Vu+b4pV4EE0hj64Sns2qpbkXzFlBTIHdnJjICtQsPtN0JAlpWFdPb5pvy0GWNYWXm/AkszoixuCQodUKPuWWHt26z+a4AltbNIQ+JwDr/FBSrTIxIXAc6enOcsL4VVcpfypwKXvlqCEbasa0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=kGZv9rQh; arc=none smtp.client-ip=217.70.183.200 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="kGZv9rQh" Received: by mail.gandi.net (Postfix) with ESMTPSA id A67E22000B; Wed, 10 Jul 2024 11:42:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720611760; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u2sYuS1K5dZ6Aq1gTipTywOPx8OLUbg/5RfC3uwk7QY=; b=kGZv9rQhhRxifG7dXUGbdb/2EgcZe1jBSv0ftotxh+GQMGFXYoMhofwqa3tSXeKJ1VUb+9 BZL2L8POD0smXnGvpTYJmqWgZtxmyETUlNy/W2GHTP1xS4k+gFGATx46EysUU0tq2rbWuE RqZBret80qrTsEdq5xOziZC+erMr5EfG92KS6AjWgca+qbfx1UK9Cmog6XHBXd6VtCnm8W as9Q8Ad3ahCGCQ6Abo+iMb4/fLZX2Pm/2k5RAc89vqOJvN6ZVoxKMHlLRJ2TAKUMhsxGye ltn+F/66ufIE94nADVSSVLos0jVyssuFUNLu/K2TicZ/ztEkhYjP89vcjnm2xg== From: Kory Maincent To: Andrew Lunn , Jakub Kicinski , "Kory Maincent (Dent Project)" , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: thomas.petazzoni@bootlin.com, Oleksij Rempel , "David S. Miller" , Eric Dumazet , Paolo Abeni Subject: [PATCH v2 2/2] net: ethtool: pse-pd: Fix possible null-deref Date: Wed, 10 Jul 2024 13:42:31 +0200 Message-Id: <20240710114232.257190-2-kory.maincent@bootlin.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240710114232.257190-1-kory.maincent@bootlin.com> References: <20240710114232.257190-1-kory.maincent@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-GND-Sasl: kory.maincent@bootlin.com X-Patchwork-Delegate: kuba@kernel.org Fix a possible null dereference when a PSE supports both c33 and PoDL, but only one of the netlink attributes is specified. The c33 or PoDL PSE capabilities are already validated in the ethnl_set_pse_validate() call. Signed-off-by: Kory Maincent Reported-by: Jakub Kicinski Closes: https://lore.kernel.org/netdev/20240705184116.13d8235a@kernel.org/ Fixes: 4d18e3ddf427 ("net: ethtool: pse-pd: Expand pse commands with the PSE PoE interface") --- net/ethtool/pse-pd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ethtool/pse-pd.c b/net/ethtool/pse-pd.c index 982995ff1628..776ac96cdadc 100644 --- a/net/ethtool/pse-pd.c +++ b/net/ethtool/pse-pd.c @@ -178,9 +178,9 @@ ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info) phydev = dev->phydev; /* These values are already validated by the ethnl_pse_set_policy */ - if (pse_has_podl(phydev->psec)) + if (tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]) config.podl_admin_control = nla_get_u32(tb[ETHTOOL_A_PODL_PSE_ADMIN_CONTROL]); - if (pse_has_c33(phydev->psec)) + if (tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL]) config.c33_admin_control = nla_get_u32(tb[ETHTOOL_A_C33_PSE_ADMIN_CONTROL]); /* Return errno directly - PSE has no notification