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, 16 Jun 2009 19:35:24 -0700
From:	Jared Hulbert <jaredeh@...il.com>
To:	Marco <marco.stornelli@...il.com>
Cc:	Linux FS Devel <linux-fsdevel@...r.kernel.org>,
	Linux Embedded <linux-embedded@...r.kernel.org>,
	Linux Kernel <linux-kernel@...r.kernel.org>,
	Daniel Walker <dwalker@....ucsc.edu>
Subject: Re: [PATCH 13/14] Pramfs: Write protection

> +/* init_mm.page_table_lock must be held before calling! */
> +static void pram_page_writeable(unsigned long addr, int rw)
> +{
> +       pgd_t *pgdp;
> +       pud_t *pudp;
> +       pmd_t *pmdp;
> +       pte_t *ptep;
> +
> +       pgdp = pgd_offset_k(addr);
> +       if (!pgd_none(*pgdp)) {
> +               pudp = pud_offset(pgdp, addr);
> +               if (!pud_none(*pudp)) {
> +                       pmdp = pmd_offset(pudp, addr);
> +                       if (!pmd_none(*pmdp)) {
> +                               pte_t pte;
> +                               ptep = pte_offset_kernel(pmdp, addr);
> +                               pte = *ptep;
> +                               if (pte_present(pte)) {
> +                                       pte = rw ? pte_mkwrite(pte) :
> +                                               pte_wrprotect(pte);
> +                                       set_pte(ptep, pte);
> +                               }
> +                       }
> +               }
> +       }
> +}

Wow.  Don't we want to do this pte walking in mm/ someplace?

Do you really intend to protect just the PTE in question rather than
the entire physical page, regardless of which PTE is talking to it?
Maybe I'm missing something.

> +/* init_mm.page_table_lock must be held before calling! */
> +void pram_writeable(void *vaddr, unsigned long size, int rw)
> +{
> +       unsigned long addr = (unsigned long)vaddr & PAGE_MASK;
> +       unsigned long end = (unsigned long)vaddr + size;
> +       unsigned long start = addr;
> +
> +       do {
> +               pram_page_writeable(addr, rw);
> +               addr += PAGE_SIZE;
> +       } while (addr && (addr < end));
> +
> +
> +       /*
> +        * NOTE: we will always flush just one page (one TLB
> +        * entry) except possibly in one case: when a new
> +        * filesystem is initialized at mount time, when pram_read_super
> +        * calls pram_lock_range to make the super block, inode
> +        * table, and bitmap writeable.
> +        */
> +#if defined(CONFIG_ARM) || defined(CONFIG_M68K) || defined(CONFIG_H8300) || \
> +       defined(CONFIG_BLACKFIN)
> +       /*
> +        * FIXME: so far only these archs have flush_tlb_kernel_page(),
> +        * for the rest just use flush_tlb_kernel_range(). Not ideal
> +        * to use _range() because many archs just flush the whole TLB.
> +        */
> +       if (end <= start + PAGE_SIZE)
> +               flush_tlb_kernel_page(start);
> +       else
> +#endif
> +               flush_tlb_kernel_range(start, end);
> +}

Why not just fix flush_tlb_range()?

If an arch has a flush_tlb_kernel_page() that works then it stands to
reason that the flush_tlb_kernel_range() shouldn't work with minimal
effort, no?
--
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