Skip to content

Commit

Permalink
ethtool: pse-pd: move pse validation into set
Browse files Browse the repository at this point in the history
Move validation into set, removing .set_validate operation as its current
implementation holds the rtnl lock for acquiring the PHY device, defeating
the intended purpose of checking before grabbing the lock.

Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=ec369e6d58e210135f71
Fixes: 3174876 ("net: ethtool: pse-pd: Target the command to the requested PHY")
Signed-off-by: Diogo Jahchan Koike <[email protected]>
Reviewed-by: Maxime Chevallier <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
Diogo Jahchan Koike authored and kuba-moo committed Aug 30, 2024
1 parent 6af91e3 commit cff69f7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions net/ethtool/pse-pd.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,10 @@ const struct nla_policy ethnl_pse_set_policy[ETHTOOL_A_PSE_MAX + 1] = {
};

static int
ethnl_set_pse_validate(struct ethnl_req_info *req_info, struct genl_info *info)
ethnl_set_pse_validate(struct phy_device *phydev, struct genl_info *info)
{
struct nlattr **tb = info->attrs;
struct phy_device *phydev;

phydev = ethnl_req_get_phydev(req_info, tb[ETHTOOL_A_PSE_HEADER],
info->extack);
if (IS_ERR_OR_NULL(phydev)) {
NL_SET_ERR_MSG(info->extack, "No PHY is attached");
return -EOPNOTSUPP;
Expand All @@ -254,20 +251,21 @@ ethnl_set_pse_validate(struct ethnl_req_info *req_info, struct genl_info *info)
return -EOPNOTSUPP;
}

return 1;
return 0;
}

static int
ethnl_set_pse(struct ethnl_req_info *req_info, struct genl_info *info)
{
struct nlattr **tb = info->attrs;
struct phy_device *phydev;
int ret = 0;
int ret;

phydev = ethnl_req_get_phydev(req_info, tb[ETHTOOL_A_PSE_HEADER],
info->extack);
if (IS_ERR_OR_NULL(phydev))
return -ENODEV;
ret = ethnl_set_pse_validate(phydev, info);
if (ret)
return ret;

if (tb[ETHTOOL_A_C33_PSE_AVAIL_PW_LIMIT]) {
unsigned int pw_limit;
Expand Down Expand Up @@ -314,7 +312,6 @@ const struct ethnl_request_ops ethnl_pse_request_ops = {
.fill_reply = pse_fill_reply,
.cleanup_data = pse_cleanup_data,

.set_validate = ethnl_set_pse_validate,
.set = ethnl_set_pse,
/* PSE has no notification */
};

0 comments on commit cff69f7

Please sign in to comment.