From: sashiko-bot@kernel.org
To: "Christian Marangi" <ansuelsmth@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v15 02/12] net: phylink: introduce internal phylink PCS handling
Date: Wed, 02 Sep 2026 08:30:53 +0000 [thread overview]
Message-ID: <20260902083054.10DB01F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260901083001.8044-3-ansuelsmth@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] phylink_validate_mac_and_pcs() fails to reject interfaces when a required PCS is not found, leading to invalid link configurations being accepted.
- [High] phylink_create() improperly unions MAC and PCS supported interfaces, leaking unsupported generic PCS modes to the phylink configuration.
--
commit 29d359b25a130406a2e1a1837648f9bffccf1373
Author: Christian Marangi <ansuelsmth@gmail.com>
net: phylink: introduce internal phylink PCS handling
Introduce internal handling of PCS for phylink. This is an alternative
way to .mac_select_pcs that moves the selection logic of the PCS entirely
to phylink with the usage of the supported_interface value in the PCS
struct.
> diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
> index 7f7a7328124f2..d7391a60f01f6 100644
> --- a/drivers/net/phy/phylink.c
> +++ b/drivers/net/phy/phylink.c
[ ... ]
> @@ -530,6 +549,21 @@ static int phylink_validate_mac_and_pcs(struct phylink *pl,
> pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
> if (IS_ERR(pcs))
> return PTR_ERR(pcs);
> + /*
> + * Find a PCS in available PCS list for the requested interface.
> + *
> + * Skip searching if the MAC doesn't require a dedicated PCS for
> + * the requested interface.
> + */
> + } else if (test_bit(state->interface, pl->config->pcs_interfaces)) {
> + struct phylink_pcs *tmp;
> +
> + list_for_each_entry(tmp, &pl->pcs_list, list) {
> + if (!phylink_validate_pcs_interface(tmp, state->interface)) {
> + pcs = tmp;
> + break;
> + }
> + }
> }
>
> if (pcs) {
[Severity: High]
If a MAC declares pcs_interfaces for a mode, but no PCS in the list matches
that interface, pcs remains NULL. Does this code incorrectly proceed to
validate the MAC capabilities without returning an error (such as -EINVAL)
when a required PCS is missing?
[ ... ]
> @@ -1909,16 +2028,31 @@ struct phylink *phylink_create(struct phylink_config *config,
> __set_bit(PHYLINK_DISABLE_STOPPED, &pl->phylink_disable_state);
> timer_setup(&pl->link_poll, phylink_fixed_poll, 0);
>
> + /* Fill the PCS list with available PCS from phylink config */
> + ret = phylink_fill_available_pcs(pl, config);
> + if (ret < 0)
> + goto free_pl;
> +
> + /* Link available PCS to phylink */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + pcs->phylink = pl;
> +
> phy_interface_copy(pl->supported_interfaces,
> pl->config->supported_interfaces);
>
> + /* Update supported interfaces */
> + list_for_each_entry(pcs, &pl->pcs_list, list)
> + phy_interface_or(pl->supported_interfaces,
> + pl->supported_interfaces,
> + pcs->supported_interfaces);
> +
[Severity: High]
Does this unintentionally leak unsupported generic PCS modes to the phylink
configuration?
By ORing the PCS interfaces into pl->supported_interfaces, the phylink
instance may falsely advertise support for modes that the PCS supports but
the MAC hardware does not natively support, bypassing the MAC capability
restrictions. Should this restrict to the intersection instead?
> linkmode_fill(pl->supported);
> linkmode_copy(pl->link_config.advertising, pl->supported);
> phylink_validate(pl, pl->supported, &pl->link_config);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260901083001.8044-1-ansuelsmth@gmail.com?part=2
next prev parent reply other threads:[~2026-09-02 8:30 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 8:29 [PATCH net-next v15 00/12] net: pcs: Introduce support for fwnode PCS Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 01/12] net: phylink: keep and use MAC supported_interfaces in phylink struct Christian Marangi
2026-09-02 8:30 ` sashiko-bot
2026-09-01 8:29 ` [PATCH net-next v15 02/12] net: phylink: introduce internal phylink PCS handling Christian Marangi
2026-09-02 8:30 ` sashiko-bot [this message]
2026-09-01 8:29 ` [PATCH net-next v15 03/12] net: pcs: implement Firmware node support for PCS driver Christian Marangi
2026-09-02 8:30 ` sashiko-bot
2026-09-01 8:29 ` [PATCH net-next v15 04/12] net: phylink: save phylink instance fwnode on phylink_create Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 05/12] net: phylink: support PCS provider release Christian Marangi
2026-09-02 8:30 ` sashiko-bot
2026-09-01 8:29 ` [PATCH net-next v15 06/12] net: phylink: support late PCS provider attach Christian Marangi
2026-09-02 8:30 ` sashiko-bot
2026-09-01 8:29 ` [PATCH net-next v15 07/12] net: Document PCS subsystem Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 08/12] MAINTAINERS: add myself as PCS subsystem maintainer Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 09/12] net: phylink: add .pcs_link_down PCS OP Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 10/12] dt-bindings: net: pcs: Document support for Airoha Ethernet PCS Christian Marangi
2026-09-01 8:29 ` [PATCH net-next v15 11/12] net: pcs: airoha: add PCS driver for Airoha AN7581 SoC Christian Marangi
2026-09-02 8:30 ` sashiko-bot
2026-09-01 8:29 ` [PATCH net-next v15 12/12] net: airoha: add phylink support Christian Marangi
2026-09-01 9:05 ` Lorenzo Bianconi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902083054.10DB01F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ansuelsmth@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox