From patchwork Thu Jul 11 13:55:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13730753 X-Patchwork-Delegate: kuba@kernel.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 B01F815F40A; Thu, 11 Jul 2024 13:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720706157; cv=none; b=nUZeQ2C2oUNjHB+zUCnzJWzM1lk5dLRXP26+A/niLcbybd8OZgSYpWjeSVO8CH5IZsrW9GYbBOQ8TjoaskFvECjdpvZwqe+KZnrOTqxVBo1WSCIrH5aIf364jtheP1oN9UlYMY6mgoPiEpc0YlRF6kbcW9diCF0m8yykeq7mkok= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720706157; c=relaxed/simple; bh=YqS9RdaQZvghw3onpj5/1G8LNAAYXaqJhpZuG4nEhZY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dC2nNHdI5/aoQbBhPuui+1bs1JdtVRxLEvH8YtIkNc5T6wXD8A4wrW/8jeUrrEuUb4hQgDU6/Sp4qcNMsaE5d+28CSf8jRBODEf6+EbaP/t78tBkL+TGotxFiNkiQ5fA6artMP2hopNEVsDOmw5zN3lULtOcCFsT6cdxicPuBFA= 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=M+Ze2f/H; arc=none smtp.client-ip=217.70.183.198 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="M+Ze2f/H" Received: by mail.gandi.net (Postfix) with ESMTPSA id 6EE73C0003; Thu, 11 Jul 2024 13:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720706153; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=J7XfW627Qfdj48cFxmYq/CvblcgTyZx62zXLjChHtNA=; b=M+Ze2f/HYeNQQ+Fny/Sv33v4j1WztYbvADEHSDE/OHP8bzcjXo+ZZZtV+ZGKpQDDr0h2ro gCya6B7A88Ainp7uTlU52xKM27b8nCKkHlcK/TT329zT1eM88qpJ3TFgsZFq2tq6GKc6uB Rs+pXenf23M8LwBwyS/sMVnM3Q6DxTXwdsKeLRl0twXX18CEqgjspgWeC1kLnjXgba/wzL fc9ctdbYQLZxXmIES5ENPA7PAH91/NqLrbQqodpjIsw7PE6QEQyE/XSFBO3+a2JDOVaYkz vuJiR6o8kiYm0f6A4AW8SLBHjM9sGIzoV8BMRFQegbM1HHYxYT7IR+Y/d5ZeKg== From: Kory Maincent Date: Thu, 11 Jul 2024 15:55:18 +0200 Subject: [PATCH net v3 1/2] net: pse-pd: Do not return EOPNOSUPP if config is null Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240711-fix_pse_pd_deref-v3-1-edd78fc4fe42@bootlin.com> References: <20240711-fix_pse_pd_deref-v3-0-edd78fc4fe42@bootlin.com> In-Reply-To: <20240711-fix_pse_pd_deref-v3-0-edd78fc4fe42@bootlin.com> To: Oleksij Rempel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: Simon Horman , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kory Maincent X-Mailer: b4 0.13.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 Thu Jul 11 13:55:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kory Maincent X-Patchwork-Id: 13730754 X-Patchwork-Delegate: kuba@kernel.org Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (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 3AB5215FCFB; Thu, 11 Jul 2024 13:55:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720706158; cv=none; b=p2/M874uPX4qtNzCI1HtZbFq9g61HF7pCvhN7UBU8fBohX/Mf9nQ5hAkiVYDGe/+wAo+3n0tGwoRAV3ohe46EHiYOVfgok6n+NReMs5oX9iItk+vzboMn9DfELxd9Rm9qq4WedMLav+wrRS4H4063VePb/uVz+kK5gPogrySwAM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720706158; c=relaxed/simple; bh=G4X0oC8pcsd+zN1erd0h6HCHhQkIQJkVQ1WK4rudAeo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PyhFqeKy/g0WhL4aV0BgS84VQ8fnHVuszvBPk5Zb9VpkrwO3XS0AGah5G8VHcR5n7VXeAx0oMWiQqC2SIk4GKs31M2g6sLq92hg7T98QM3+301uQc1/6P1bbVu0nYxLThJX3ubS6oE+vIhaDb2aMm+0ljbX39tsiMrPVHmo6jLY= 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=GJvh9JWt; arc=none smtp.client-ip=217.70.183.198 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="GJvh9JWt" Received: by mail.gandi.net (Postfix) with ESMTPSA id 04DF4C0006; Thu, 11 Jul 2024 13:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1720706154; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Q1/i67l0rh6zcxHO4vrNIsKxwOBneQPuzJf+8OC7dNo=; b=GJvh9JWtbOWDSRS7IzhXyHD6LqFMck+M7eyTFKNd8HJAriAbS7xT3KlrnpeoeoTeAiXbA5 gy5VRlt0xrIOC2rx17TO89hNMWzwpeYuc1IWGeOvp0l5RU+3P8xNQ31bOusHRfOKZQ75gT uj+oTJCZ7KK019tTMQH703/I4rrQ4msxyFWxljld+vVkl95prjf+ebixb70Fw4BlKvUgnJ zoxZu5AKlkCiacAW0ctKwcCnD/P9Zgx2MLFJwkGyNKrYIolv5G3240nansHFRpWcFOKp0S 6doMcsFpBTffA2gPyvn9QKjJymo4iMl4NMaRL2mS96wa76RlgHcKIN3HSsHZ3w== From: Kory Maincent Date: Thu, 11 Jul 2024 15:55:19 +0200 Subject: [PATCH net v3 2/2] net: ethtool: pse-pd: Fix possible null-deref Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240711-fix_pse_pd_deref-v3-2-edd78fc4fe42@bootlin.com> References: <20240711-fix_pse_pd_deref-v3-0-edd78fc4fe42@bootlin.com> In-Reply-To: <20240711-fix_pse_pd_deref-v3-0-edd78fc4fe42@bootlin.com> To: Oleksij Rempel , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn Cc: Simon Horman , Thomas Petazzoni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kory Maincent X-Mailer: b4 0.13.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