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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Fri, 24 Oct 2014 14:49:53 +0200 (CEST)
From:	Thomas Gleixner <tglx@...utronix.de>
To:	Qiaowei Ren <qiaowei.ren@...el.com>
cc:	"H. Peter Anvin" <hpa@...or.com>, Ingo Molnar <mingo@...hat.com>,
	Dave Hansen <dave.hansen@...el.com>, x86@...nel.org,
	linux-mm@...ck.org, linux-kernel@...r.kernel.org,
	linux-ia64@...r.kernel.org, linux-mips@...ux-mips.org
Subject: Re: [PATCH v9 10/12] x86, mpx: add prctl commands PR_MPX_ENABLE_MANAGEMENT,
 PR_MPX_DISABLE_MANAGEMENT

On Sun, 12 Oct 2014, Qiaowei Ren wrote:
> +int mpx_enable_management(struct task_struct *tsk)
> +{
> +	struct mm_struct *mm = tsk->mm;
> +	void __user *bd_base = MPX_INVALID_BOUNDS_DIR;

What's the point of initializing bd_base here. I had to look twice to
figure out that it gets overwritten by task_get_bounds_dir()

> @@ -285,6 +285,7 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
>  	struct xsave_struct *xsave_buf;
>  	struct task_struct *tsk = current;
>  	siginfo_t info;
> +	int ret = 0;
>  
>  	prev_state = exception_enter();
>  	if (notify_die(DIE_TRAP, "bounds", regs, error_code,
> @@ -312,8 +313,35 @@ dotraplinkage void do_bounds(struct pt_regs *regs, long error_code)
>  	 */
>  	switch (status & MPX_BNDSTA_ERROR_CODE) {
>  	case 2: /* Bound directory has invalid entry. */
> -		if (do_mpx_bt_fault(xsave_buf))
> +		down_write(&current->mm->mmap_sem);

The handling of mm->mmap_sem here is horrible. The only reason why you
want to hold mmap_sem write locked in the first place is that you want
to cover the allocation and the mm->bd_addr check.

I think it's wrong to tie this to mmap_sem in the first place. If MPX
is enabled then you should have mm->bd_addr and an explicit mutex to
protect it.

So the logic would look like this:

   mutex_lock(&mm->bd_mutex);
   if (!kernel_managed(mm))
      do_trap();
   else if (do_mpx_bt_fault())
      force_sig();
   mutex_unlock(&mm->bd_mutex);
   
No tricks with mmap_sem, no special return value handling. Straight
forward code instead of a convoluted and error prone mess.

Hmm?

Thanks,

	tglx
--
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