Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Jimmy Tran <jtoantran@google.com>
Cc: stable@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Borislav Petkov <bp@alien8.de>, Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	David Laight <david.laight@aculab.com>,
	x86@kernel.org, Andrei Vagin <avagin@gmail.com>
Subject: Re: [PATCH v1 0/6] Backport "x86: fix off-by-one in access_ok()" to 6.6.y
Date: Thu, 24 Jul 2025 12:47:31 +0100	[thread overview]
Message-ID: <20250724124731.3c594b23@pumpkin> (raw)
In-Reply-To: <20250723163209.1929303-1-jtoantran@google.com>

On Wed, 23 Jul 2025 16:32:03 +0000
Jimmy Tran <jtoantran@google.com> wrote:

> This patch series backports a critical security fix, identified as
> CVE-2020-12965 ("Transient Execution of Non-Canonical Accesses"), to the
> 6.6.y stable kernel tree.

You probably want to pick up the 'cmov' variant of:

+static inline void __user *mask_user_address(const void __user *ptr)
+{
+       unsigned long mask;
+
+       asm("cmp %1,%0\n\t"
+           "sbb %0,%0"
+                : "=r" (mask)
+                : "r" (ptr),
+                "0" (runtime_const_ptr(USER_PTR_MAX)));
+       return (__force void __user *)(mask | (__force unsigned long)ptr);
+}

Converting kernel addresses to USER_PTR_MAX instead of ~0 means that
is isn't critical that the base address is accessed first.
(I'm not sure that x86 completely disables mapping to user address zero.)

That is more problematic for 32bit (address masking wasn't enabled last
time I looked) because not all supported cpu support cmov.

	David

> 
> commit 573f45a9f9a47fed4c7957609689b772121b33d7 upstream.
> 
> David Laight (1):
>   x86: fix off-by-one in access_ok()
> 
> Linus Torvalds (5):
>   vfs: dcache: move hashlen_hash() from callers into d_hash()
>   runtime constants: add default dummy infrastructure
>   runtime constants: add x86 architecture support
>   arm64: add 'runtime constant' support
>   x86: fix user address masking non-canonical speculation issue
> 
>  arch/arm64/include/asm/runtime-const.h | 92 ++++++++++++++++++++++++++
>  arch/arm64/kernel/vmlinux.lds.S        |  3 +
>  arch/x86/include/asm/runtime-const.h   | 61 +++++++++++++++++
>  arch/x86/include/asm/uaccess_64.h      | 45 ++++++++-----
>  arch/x86/kernel/cpu/common.c           | 10 +++
>  arch/x86/kernel/vmlinux.lds.S          |  4 ++
>  arch/x86/lib/getuser.S                 |  9 ++-
>  fs/dcache.c                            | 17 +++--
>  include/asm-generic/Kbuild             |  1 +
>  include/asm-generic/runtime-const.h    | 15 +++++
>  include/asm-generic/vmlinux.lds.h      |  8 +++
>  11 files changed, 243 insertions(+), 22 deletions(-)
>  create mode 100644 arch/arm64/include/asm/runtime-const.h
>  create mode 100644 arch/x86/include/asm/runtime-const.h
>  create mode 100644 include/asm-generic/runtime-const.h
> 
> --
> 2.50.0.727.gbf7dc18ff4-goog
> 
> 


  parent reply	other threads:[~2025-07-24 11:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 16:32 [PATCH v1 0/6] Backport "x86: fix off-by-one in access_ok()" to 6.6.y Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 1/6] vfs: dcache: move hashlen_hash() from callers into d_hash() Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 2/6] runtime constants: add default dummy infrastructure Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 3/6] runtime constants: add x86 architecture support Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 4/6] arm64: add 'runtime constant' support Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 5/6] x86: fix user address masking non-canonical speculation issue Jimmy Tran
2025-07-23 16:32 ` [PATCH v1 6/6] x86: fix off-by-one in access_ok() Jimmy Tran
2025-07-23 17:13 ` [PATCH v1 0/6] Backport "x86: fix off-by-one in access_ok()" to 6.6.y Linus Torvalds
2025-07-24 11:47 ` David Laight [this message]
2025-07-28 17:56 ` [PATCH v2 0/7] x86: fix user address masking non-canonical Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 1/7] vfs: dcache: move hashlen_hash() from callers into d_hash() Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 2/7] runtime constants: add default dummy infrastructure Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 3/7] runtime constants: add x86 architecture support Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 4/7] arm64: add 'runtime constant' support Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 5/7] x86: fix user address masking non-canonical speculation issue Jimmy Tran
2025-07-28 17:56   ` [PATCH v2 6/7] x86: fix off-by-one in access_ok() Jimmy Tran
2025-07-28 17:57   ` [PATCH v2 7/7] x86: use cmov for user address masking Jimmy Tran
2025-08-05 22:36   ` [PATCH v2 0/7] x86: fix user address masking non-canonical Andrei Vagin

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=20250724124731.3c594b23@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=arnd@arndb.de \
    --cc=avagin@gmail.com \
    --cc=bp@alien8.de \
    --cc=brauner@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=david.laight@aculab.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jtoantran@google.com \
    --cc=mingo@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=will@kernel.org \
    --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