The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Sami Tolvanen <samitolvanen@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	"H . Peter Anvin" <hpa@zytor.com>,
	x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: use the correct function type for native_set_fixmap
Date: Mon, 23 Sep 2019 16:27:56 -0700	[thread overview]
Message-ID: <201909231626.A912664DA1@keescook> (raw)
In-Reply-To: <20190913211402.193018-1-samitolvanen@google.com>

On Fri, Sep 13, 2019 at 02:14:02PM -0700, Sami Tolvanen wrote:
> We call native_set_fixmap indirectly through the function pointer
> struct pv_mmu_ops::set_fixmap, which expects the first parameter to be
> 'unsigned' instead of 'enum fixed_addresses'. This patch changes the
> function type for native_set_fixmap to match the pointer, which fixes
> indirect call mismatches with Control-Flow Integrity (CFI) checking.
> 
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

Is it correct that pv_mmu_ops can't be changed since this is an external
API?

Assuming so, then:

Reviewed-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  arch/x86/include/asm/fixmap.h | 2 +-
>  arch/x86/mm/pgtable.c         | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
> index 9da8cccdf3fb..6a295acd3de6 100644
> --- a/arch/x86/include/asm/fixmap.h
> +++ b/arch/x86/include/asm/fixmap.h
> @@ -157,7 +157,7 @@ extern pte_t *kmap_pte;
>  extern pte_t *pkmap_page_table;
>  
>  void __native_set_fixmap(enum fixed_addresses idx, pte_t pte);
> -void native_set_fixmap(enum fixed_addresses idx,
> +void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
>  		       phys_addr_t phys, pgprot_t flags);
>  
>  #ifndef CONFIG_PARAVIRT_XXL
> diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
> index 44816ff6411f..d0ad35e3de74 100644
> --- a/arch/x86/mm/pgtable.c
> +++ b/arch/x86/mm/pgtable.c
> @@ -647,8 +647,8 @@ void __native_set_fixmap(enum fixed_addresses idx, pte_t pte)
>  	fixmaps_set++;
>  }
>  
> -void native_set_fixmap(enum fixed_addresses idx, phys_addr_t phys,
> -		       pgprot_t flags)
> +void native_set_fixmap(unsigned /* enum fixed_addresses */ idx,
> +		       phys_addr_t phys, pgprot_t flags)
>  {
>  	/* Sanitize 'prot' against any unsupported bits: */
>  	pgprot_val(flags) &= __default_kernel_pte_mask;
> -- 
> 2.23.0.237.gc6a4ce50a0-goog
> 

-- 
Kees Cook

  reply	other threads:[~2019-09-23 23:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-13 21:14 [PATCH] x86: use the correct function type for native_set_fixmap Sami Tolvanen
2019-09-23 23:27 ` Kees Cook [this message]
2019-09-24 19:51   ` Sami Tolvanen
2019-10-08 22:18     ` Sami Tolvanen
2019-10-11 11:22 ` [tip: x86/entry] x86/mm: Use the correct function type for native_set_fixmap() tip-bot2 for Sami Tolvanen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201909231626.A912664DA1@keescook \
    --to=keescook@chromium.org \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=samitolvanen@google.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox