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: <20231025154023.576a2f7b@kernel.org>
Date: Wed, 25 Oct 2023 15:40:23 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: "Radu Pirea (NXP OSS)" <radu-nicolae.pirea@....nxp.com>
Cc: sd@...asysnail.net, davem@...emloft.net, edumazet@...gle.com,
 pabeni@...hat.com, andrew@...n.ch, hkallweit1@...il.com,
 linux@...linux.org.uk, richardcochran@...il.com,
 linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
 sebastian.tobuschat@....nxp.com
Subject: Re: [PATCH net-next v8 4/7] net: macsec: introduce
 mdo_insert_tx_tag

On Mon, 23 Oct 2023 12:43:24 +0300 Radu Pirea (NXP OSS) wrote:
> +	if (unlikely(skb_headroom(skb) < ops->needed_headroom ||
> +		     skb_tailroom(skb) < ops->needed_tailroom)) {

This sort of "if head / tail room is to small, realloc" helper would 
be more widely applicable, we should factor it out.

> +		struct sk_buff *nskb = skb_copy_expand(skb,

And this should perhaps be pskb_expand_head().

> +						       ops->needed_headroom,
> +						       ops->needed_tailroom,
> +						       GFP_ATOMIC);
> +		if (likely(nskb)) {
> +			consume_skb(skb);
> +			skb = nskb;
> +		} else {
> +			err = -ENOMEM;
> +			goto cleanup;
> +		}
> +	} else {
> +		skb = skb_unshare(skb, GFP_ATOMIC);

You don't need to unshare if tailroom is 0, you just need to call
skb_cow_head(). 

I think we have this sort of code in DSA already, IIRC Vladimir wrote
it. dsa_realloc_skb() ? Can we factor out / reuse that?

> +		if (!skb)
> +			return ERR_PTR(-ENOMEM);
> +	}
> +
> +	err = ops->mdo_insert_tx_tag(phydev, skb);
> +	if (unlikely(err))
> +		goto cleanup;
> +
> +	if (unlikely(skb->len - ETH_HLEN > macsec_priv(dev)->real_dev->mtu)) {

You can check that first, if the packet is going to be dropped no point
doing the expansions.

> +		err = -EINVAL;
> +		goto cleanup;
> +	}

Powered by blists - more mailing lists