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] [day] [month] [year] [list]
Message-ID: <CAMuHMdXB1fK_G=QZ59qkJWXhb61TyLRMwH3qo_0sSmW0Cfv8hA@mail.gmail.com>
Date:   Mon, 22 May 2023 12:11:27 +0200
From:   Geert Uytterhoeven <geert@...ux-m68k.org>
To:     Linus Walleij <linus.walleij@...aro.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Vineet Gupta <vgupta@...nel.org>,
        Catalin Marinas <catalin.marinas@....com>,
        Will Deacon <will@...nel.org>, Arnd Bergmann <arnd@...db.de>,
        Russell King <linux@...linux.org.uk>,
        Greg Ungerer <gerg@...ux-m68k.org>, linux-mm@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-m68k@...ts.linux-m68k.org,
        linux-snps-arc@...ts.infradead.org, linux-fsdevel@...r.kernel.org,
        linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org,
        linux-arm-kernel@...ts.infradead.org, linux-arch@...r.kernel.org
Subject: Re: [PATCH v2 02/12] m68k: Pass a pointer to virt_to_pfn() virt_to_page()

Hi Linus,

On Mon, May 22, 2023 at 9:00 AM Linus Walleij <linus.walleij@...aro.org> wrote:
> Functions that work on a pointer to virtual memory such as
> virt_to_pfn() and users of that function such as
> virt_to_page() are supposed to pass a pointer to virtual
> memory, ideally a (void *) or other pointer. However since
> many architectures implement virt_to_pfn() as a macro,
> this function becomes polymorphic and accepts both a
> (unsigned long) and a (void *).
>
> Fix up the offending calls in arch/m68k with explicit casts.
>
> The page table include <asm/pgtable.h> will include different
> variants of the defines depending on whether you build for
> classic m68k, ColdFire or Sun3, so fix all variants.
>
> Tested-by: Geert Uytterhoeven <geert@...ux-m68k.org>
> Signed-off-by: Linus Walleij <linus.walleij@...aro.org>

Thanks for the update!

> ---
> ChangeLog v2->v3:

v3?

> - Fix the sun3 pgtable macro to not cast to unsigned long.
> - Make a similar change to the ColdFire include.

The ColdFire change is not correct, cfr. below...

> ChangeLog v1->v2:
> - Add an extra parens around the page argument to the
>   PD_PTABLE() macro, as is normally required.
> ---
>  arch/m68k/include/asm/mcf_pgtable.h  | 4 ++--
>  arch/m68k/include/asm/sun3_pgtable.h | 4 ++--
>  arch/m68k/mm/mcfmmu.c                | 3 ++-
>  arch/m68k/mm/motorola.c              | 4 ++--
>  arch/m68k/mm/sun3mmu.c               | 2 +-
>  arch/m68k/sun3/dvma.c                | 2 +-
>  arch/m68k/sun3x/dvma.c               | 2 +-
>  7 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/arch/m68k/include/asm/mcf_pgtable.h b/arch/m68k/include/asm/mcf_pgtable.h
> index d97fbb812f63..f67c59336ab4 100644
> --- a/arch/m68k/include/asm/mcf_pgtable.h
> +++ b/arch/m68k/include/asm/mcf_pgtable.h
> @@ -115,8 +115,8 @@ static inline void pgd_set(pgd_t *pgdp, pmd_t *pmdp)
>         pgd_val(*pgdp) = virt_to_phys(pmdp);
>  }
>
> -#define __pte_page(pte)        ((unsigned long) (pte_val(pte) & PAGE_MASK))
> -#define pmd_page_vaddr(pmd)    ((unsigned long) (pmd_val(pmd)))
> +#define __pte_page(pte)        (__va (pte_val(pte) & PAGE_MASK))

I guess "__va(...)" should be "(void *)..." instead?

However, that will cause an issue below, as

    #define pte_pagenr(pte)        ((__pte_page(pte) - PAGE_OFFSET) >>
PAGE_SHIFT)

does depend on __pte_page() returning "unsigned long".
Fortunately pte_pagenr() appears unused, so it can be removed.

So for now, it might be simpler to add the cast to the caller.


> +#define pmd_page_vaddr(pmd)    (__va (pmd_val(pmd)))

This looks bogus, too, as it should return "unsigned long".

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ