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: <20220512014128-mutt-send-email-mst@kernel.org>
Date:   Thu, 12 May 2022 01:57:20 -0400
From:   "Michael S. Tsirkin" <mst@...hat.com>
To:     Eli Cohen <elic@...dia.com>
Cc:     jasowang@...hat.com, virtualization@...ts.linux-foundation.org,
        linux-kernel@...r.kernel.org, si-wei.liu@...cle.com
Subject: Re: [PATCH v1] vdpa: Warn if MTU configured is too low

On Wed, May 11, 2022 at 01:56:42PM +0300, Eli Cohen wrote:
> Following the recommendation in virio spec 1.1, a device offering
> VIRTIO_NET_F_MTU should set the mtu to at least 1280 bytes.
> 
> Print a warning if this recommendation is not met.
> 
> Signed-off-by: Eli Cohen <elic@...dia.com>
> ---
> v0 -> v1:
>   chage pr_warn to netlink warning to userspace
> 
>  drivers/vdpa/vdpa.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
> index 91f4c13c7c7c..0fb4a615f267 100644
> --- a/drivers/vdpa/vdpa.c
> +++ b/drivers/vdpa/vdpa.c
> @@ -583,6 +583,9 @@ vdpa_nl_cmd_mgmtdev_get_dumpit(struct sk_buff *msg, struct netlink_callback *cb)
>  				 BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU)     | \
>  				 BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MAX_VQP))
>  
> +/* Recommended virtio spec 1.1 section 5.1.4.1 */

I'd add name of section here too.

> +#define VIRTIO_MIN_PREFERRED_MTU 1280
> +

Preferred is kind of confusing here. I guess you are trying to
say it's not mandatory but I don't think this conveys this information.

Recommended (matching text below)?


>  static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *info)
>  {
>  	struct vdpa_dev_set_config config = {};
> @@ -634,6 +637,10 @@ static int vdpa_nl_cmd_dev_add_set_doit(struct sk_buff *skb, struct genl_info *i
>  		err = PTR_ERR(mdev);
>  		goto err;
>  	}
> +	if ((mdev->supported_features & BIT_ULL(VIRTIO_NET_F_MTU)) &&
> +	    (config.mask & BIT_ULL(VDPA_ATTR_DEV_NET_CFG_MTU) &&
> +	    config.net.mtu < VIRTIO_MIN_PREFERRED_MTU))
> +		NL_SET_ERR_MSG_MOD(info->extack, "MTU is below recommended value\n");
>  	if ((config.mask & mdev->config_attr_mask) != config.mask) {
>  		NL_SET_ERR_MSG_MOD(info->extack,
>  				   "All provided attributes are not supported");


Pity we can't include the actual value here, but oh well. At least let's
include the recommended value, we can do that:
	"MTU is below recommended value of " __stringify(VIRTIO_MIN_PREFERRED_MTU) "\n"


> @@ -1135,7 +1142,7 @@ static const struct nla_policy vdpa_nl_policy[VDPA_ATTR_MAX + 1] = {
>  	[VDPA_ATTR_DEV_NAME] = { .type = NLA_STRING },
>  	[VDPA_ATTR_DEV_NET_CFG_MACADDR] = NLA_POLICY_ETH_ADDR,
>  	/* virtio spec 1.1 section 5.1.4.1 for valid MTU range */
> -	[VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, 68),
> +	[VDPA_ATTR_DEV_NET_CFG_MTU] = NLA_POLICY_MIN(NLA_U16, ETH_MIN_MTU),
>  };
>  
>  static const struct genl_ops vdpa_nl_ops[] = {
> -- 
> 2.35.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ