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]
Date:	Thu, 24 Oct 2013 09:43:38 +0100
From:	"David Laight" <David.Laight@...LAB.COM>
To:	"Antonio Quartulli" <antonio@...hcoding.com>,
	"David Miller" <davem@...emloft.net>
Cc:	<netdev@...r.kernel.org>
Subject: RE: [PATCHv2 net] netpoll: fix rx_hook() interface by passing the skb

> Subject: [PATCHv2 net] netpoll: fix rx_hook() interface by passing the skb
> 
> Right now skb->data is passed to rx_hook() even if the skb
> has not been linearised and without giving rx_hook() a way
> to linearise it.
> 
> Change the rx_hook() interface and make it accept the skb
> and the offset to the UDP payload as arguments. rx_hook() is
> also renamed to rx_skb_hook() to ensure that out of the tree
> users notice the API change.
> 
> In this way any rx_skb_hook() implementation can perform all
> the needed operations to properly (and safely) access the
> skb data.
...
> @@ -820,7 +823,10 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
> 
>  		len -= iph->ihl*4;
>  		uh = (struct udphdr *)(((char *)iph) + iph->ihl*4);
> +		offset = (unsigned char *)(uh + 1) - skb->data;
>  		ulen = ntohs(uh->len);
> +		data_len = skb->len - offset;
> +		source = ntohs(uh->source);
> 
>  		if (ulen != len)
>  			goto out;
> @@ -834,9 +840,7 @@ int __netpoll_rx(struct sk_buff *skb, struct netpoll_info *npinfo)
>  			if (np->local_port && np->local_port != ntohs(uh->dest))
>  				continue;
> 
> -			np->rx_hook(np, ntohs(uh->source),
> -				       (char *)(uh+1),
> -				       ulen - sizeof(struct udphdr));
> +			np->rx_skb_hook(np, source, skb, offset, data_len);
>  			hits++;
>  		}
>  	} else {

>From a code optimisation point of view you probably don't want to be
calculating the source, offset and length early.
It is quite likely that the local variables will have to be written
to the stack (because of the function calls) - so it is almost
certainly more efficient to calculate them just before the call.

	David



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ