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]
Message-ID: <24ec1497-af03-4e65-abb4-db89590fb28e@intel.com>
Date: Tue, 10 Sep 2024 12:54:19 -0700
From: Dave Hansen <dave.hansen@...el.com>
To: Alexey Gladkov <legion@...nel.org>, linux-kernel@...r.kernel.org,
 linux-coco@...ts.linux.dev
Cc: Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>,
 Borislav Petkov <bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
 "H. Peter Anvin" <hpa@...or.com>,
 "Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
 Andrew Morton <akpm@...ux-foundation.org>, Yuan Yao <yuan.yao@...el.com>,
 Geert Uytterhoeven <geert@...ux-m68k.org>, Yuntao Wang <ytcoode@...il.com>,
 Kai Huang <kai.huang@...el.com>, Baoquan He <bhe@...hat.com>,
 Oleg Nesterov <oleg@...hat.com>, cho@...rosoft.com, decui@...rosoft.com,
 John.Starks@...rosoft.com, stable@...r.kernel.org
Subject: Re: [PATCH v6 1/6] x86/tdx: Fix "in-kernel MMIO" check

On 9/6/24 04:49, Alexey Gladkov wrote:
> +static inline bool is_kernel_addr(unsigned long addr)
> +{
> +	return (long)addr < 0;
> +}
> +
>  static int handle_mmio(struct pt_regs *regs, struct ve_info *ve)
>  {
>  	unsigned long *reg, val, vaddr;
> @@ -434,6 +439,11 @@ static int handle_mmio(struct pt_regs *regs, struct ve_info *ve)
>  			return -EINVAL;
>  	}
>  
> +	if (!user_mode(regs) && !is_kernel_addr(ve->gla)) {
> +		WARN_ONCE(1, "Access to userspace address is not supported");
> +		return -EINVAL;
> +	}

Should we really be open-coding a "is_kernel_addr" check?  I mean,
TASK_SIZE_MAX is there for a reason.  While I doubt we'd ever change the
positive vs. negative address space convention on 64-bit, I don't see a
good reason to write a 64-bit x86-specific is_kernel_addr() when a more
generic, portable and conventional idiom would do.

So, please use either a:

	addr < TASK_SIZE_MAX

check, or use fault_in_kernel_space() directly.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ