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:	Wed, 27 Jun 2007 11:53:46 -0700 (PDT)
From:	Casey Leedom <casey_leedom@...oo.com>
To:	linux-kernel@...r.kernel.org
Subject: Re: ZERO_PAGE() vs. loadable modules in Redhat 4.4 i386 kernels ...

--- Arjan van de Ven <arjan@...radead.org> wrote:

> you forgot to attach your source code or provide a URL to it.....

  Sorry, my bad.  I'm just diving into Linux for the first time and wasn't
aware of the protocols.  Here's the code fragment I'm currently using:

	address = skb_vaddr(skb) & PAGE_MASK;
	end = PAGE_ALIGN(skb_vaddr(skb) + len);

	down_read(&current->mm->mmap_sem);
	vma = find_vma(current->mm, skb_vaddr(skb));

	spin_lock(&current->mm->page_table_lock);
	for (i = 0; i < skb_shinfo(skb)->nr_frags; i++, address += PAGE_SIZE) { 
		pgd_t *pgd;
		pud_t *pud;
		pmd_t *pmd;
		pte_t *ptep;
		skb_frag_t *frag = &skb_shinfo(skb)->frags[i];

		/*
		 * If we're looking at the ZERO_PAGE() then we don't have to
		 * do anything.  It's never going to be modified.  See also
		 * where we avoid the ZERO_PAGE() in skb_dma_complete().
		 */
		if (frag->page == ZERO_PAGE(address))
			continue;

		atomic_inc(&frag->page->_mapcount);

		/*
		 * If we're not dealing with the ZERO_PAGE() then it should
		 * not be possible to end up without a mapping to the page.
		 * But just in case we check here and issue a BUG() if the
		 * mapping is missing ...
		 */
		if (unlikely((pgd = pgd_offset(current->mm, address),
			      pgd_none(*pgd)) ||
			     (pud = pud_offset(pgd, address),
			      pud_none(*pud)) ||
			     (pmd = pmd_offset(pud, address),
			      pmd_none(*pmd)) ||
			     (ptep = pte_offset_map(pmd, address),
			      pte_none(*ptep)))) {
			printk("skb_dma_pending: missing %s page mapping"
			       " for vaddr=%#lx, page=%p\n",
			       pgd_none(*pgd) ? "pgd"
			       : pud_none(*pud) ? "pud"
			       : pmd_none(*pmd) ? "pmd"
			       : "pte",
			       address, frag->page);
			BUG();
		}

		ptep_set_wrprotect(current->mm, address, ptep);
		pte_unmap(ptep);
	}
	spin_unlock(&current->mm->page_table_lock);
	flush_tlb_range(vma, address, end);

I hope that isn't too large but I wanted to provide sufficient context.

Casey
-
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