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:	Tue, 13 Feb 2007 02:55:53 +1100
From:	Herbert Xu <herbert@...dor.apana.org.au>
To:	Rusty Russell <rusty@...tcorp.com.au>
Cc:	Andrew Morton <akpm@...ux-foundation.org>,
	lkml - Kernel Mailing List <linux-kernel@...r.kernel.org>,
	virtualization <virtualization@...ts.osdl.org>,
	jgarzik <jgarzik@...ox.com>
Subject: Re: [PATCH 5/8] lguest: trivial guest network driver

On Mon, Feb 12, 2007 at 02:52:01PM +1100, Rusty Russell wrote:
>
> +static void skb_to_dma(const struct sk_buff *skb, unsigned int len,
> +		       struct lguest_dma *dma)
> +{
> +	unsigned int i, seg;
> +
> +	for (i = seg = 0; i < len; seg++, i += rest_of_page(skb->data + i)) {
> +		dma->addr[seg] = virt_to_phys(skb->data + i);
> +		dma->len[seg] = min((unsigned)(len - i),
> +				    rest_of_page(skb->data + i));
> +	}
> +	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, seg++) {
> +		const skb_frag_t *f = &skb_shinfo(skb)->frags[i];
> +		/* Should not happen with MTU less than 64k - 2 * PAGE_SIZE. */
> +		if (seg == LGUEST_MAX_DMA_SECTIONS) {
> +			printk("Woah dude!  Megapacket!\n");
> +			break;
> +		}
> +		dma->addr[seg] = page_to_phys(f->page) + f->page_offset;
> +		dma->len[seg] = f->size;
> +	}

The length field from the skb covers the fragmented parts as well.
So you don't want to use it as the boundary for the loop over the
skb header data.  As it is, if the skb has fragments, the first
loop will try to read them off the header.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@...dor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ