lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220901202159.2a600c70@kernel.org>
Date:   Thu, 1 Sep 2022 20:21:59 -0700
From:   Jakub Kicinski <kuba@...nel.org>
To:     Oleksij Rempel <o.rempel@...gutronix.de>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Heiner Kallweit <hkallweit1@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Russell King <linux@...linux.org.uk>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Jonathan Corbet <corbet@....net>,
        kernel test robot <lkp@...el.com>, kernel@...gutronix.de,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
        devicetree@...r.kernel.org, linux-doc@...r.kernel.org,
        David Jander <david@...tonic.nl>,
        Luka Perkov <luka.perkov@...tura.hr>,
        Robert Marko <robert.marko@...tura.hr>
Subject: Re: [PATCH net-next v5 5/7] ethtool: add interface to interact with
 Ethernet Power Equipment

On Wed, 31 Aug 2022 15:32:38 +0200 Oleksij Rempel wrote:
> +/**
> + * pse_ethtool_get_status - get status of PSE control
> + * @psec: PSE control pointer
> + * @extack: extack for reporting useful error messages
> + * @status: struct to store PSE status
> + */
> +int pse_ethtool_get_status(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   struct pse_control_status *status)
> +{
> +	const struct pse_controller_ops *ops;
> +	int err;
> +
> +	if (!psec)
> +		return 0;

Defensive programming?

> +	if (WARN_ON(IS_ERR(psec)))
> +		return -EINVAL;
> +
> +	ops = psec->pcdev->ops;
> +
> +	if (!ops->ethtool_get_status) {
> +		NL_SET_ERR_MSG(extack,
> +			       "PSE driver does not support status report");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	mutex_lock(&psec->pcdev->lock);
> +	err = ops->ethtool_get_status(psec->pcdev, psec->id, extack, status);
> +	mutex_unlock(&psec->pcdev->lock);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(pse_ethtool_get_status);
> +
> +/**
> + * pse_ethtool_set_config - set PSE control configuration
> + * @psec: PSE control pointer
> + * @extack: extack for reporting useful error messages
> + * @config: Configuration of the test to run
> + */
> +int pse_ethtool_set_config(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   const struct pse_control_config *config)
> +{
> +	const struct pse_controller_ops *ops;
> +	int err;
> +
> +	if (!psec)
> +		return 0;
> +
> +	if (WARN_ON(IS_ERR(psec)))
> +		return -EINVAL;

ditto

> +	ops = psec->pcdev->ops;
> +
> +	if (!ops->ethtool_set_config) {
> +		NL_SET_ERR_MSG(extack,
> +			       "PSE driver does not configuration");
> +		return -EOPNOTSUPP;
> +	}
> +
> +	mutex_lock(&psec->pcdev->lock);
> +	err = ops->ethtool_set_config(psec->pcdev, psec->id, extack, config);
> +	mutex_unlock(&psec->pcdev->lock);
> +
> +	return err;
> +}
> +EXPORT_SYMBOL_GPL(pse_ethtool_set_config);

> +int pse_ethtool_get_status(struct pse_control *psec,
> +			   struct netlink_ext_ack *extack,
> +			   struct pse_control_status *status)
> +{
> +	return -ENOTSUPP;

EOPNOTSUPP, please run checkpatch --strict on this patch.
All of the complaints look legit at a glance.


> +	ETHTOOL_MSG_PSE_NTF,

I don't see you calling the ethtool_notify() function, does this ever

> +static int pse_prepare_data(const struct ethnl_req_info *req_base,
> +			       struct ethnl_reply_data *reply_base,
> +			       struct genl_info *info)
> +{
> +	struct pse_reply_data *data = PSE_REPDATA(reply_base);
> +	struct net_device *dev = reply_base->dev;
> +	int ret;
> +
> +	ret = ethnl_ops_begin(dev);
> +	if (ret < 0)
> +		return 0;

humpf, return ret;?

> +	ret = pse_get_pse_attributs(dev, info->extack, data);
> +
> +	ethnl_ops_complete(dev);
> +
> +	return ret;
> +}
> +
> +static int pse_reply_size(const struct ethnl_req_info *req_base,
> +			  const struct ethnl_reply_data *reply_base)
> +{
> +	const struct pse_reply_data *data = PSE_REPDATA(reply_base);
> +	const struct pse_control_status *st = &data->status;
> +	int len = 0;
> +
> +	if (st->podl_admin_state >= 0)

UNKNOWN is now 1, should be > 0 ?

> +		len += nla_total_size(sizeof(u32)); /* _PODL_PSE_ADMIN_STATE */
> +	if (st->podl_pw_status >= 0)
> +		len += nla_total_size(sizeof(u32)); /* _PODL_PSE_PW_D_STATUS */
> +
> +	return len;
> +}

> +	if (!phydev)
> +		return -EOPNOTSUPP;
> +
> +	if (!phydev->psec)
> +		ret = -EOPNOTSUPP;

Would be good to slap an extack msg on the two errors here.

> +	else
> +		ret = pse_ethtool_set_config(phydev->psec, extack, &config);

And avoid indenting the success path. So the !phydev->psec should
contain a return.

> +	return ret;
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ