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]
Date:	Wed, 29 Jun 2011 02:38:20 -0700
From:	Michel Lespinasse <walken@...gle.com>
To:	Steven Rostedt <rostedt@...dmis.org>
Cc:	linux-kernel@...r.kernel.org, linux-mm@...ck.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Russell King <rmk+kernel@....linux.org.uk>,
	Thomas Gleixner <tglx@...utronix.de>,
	Peter Zijlstra <peterz@...radead.org>,
	Hugh Dickins <hughd@...gle.com>,
	Rik van Riel <riel@...hat.com>, Avi Kivity <avi@...hat.com>,
	Marcelo Tosatti <mtosatti@...hat.com>
Subject: Re: [PATCH 1/2] mm: Remove use of ALLOW_RETRY when RETRY_NOWAIT is set

On Tue, Jun 28, 2011 at 9:47 AM, Steven Rostedt <rostedt@...dmis.org> wrote:
> From: Steven Rostedt <srostedt@...hat.com>
>
> The only user of FAULT_FLAG_RETRY_NOWAIT also sets the
> FAULT_FLAG_ALLOW_RETRY flag. This makes the check in the
> __lock_page_or_retry redundant as it checks the RETRY_NOWAIT
> just after checking ALLOW_RETRY and then returns if it is
> set.  The FAULT_FLAG_ALLOW_RETRY does not make any other
> difference in this path.
>
> Setting both and then ignoring one is quite confusing,
> especially since this code has very subtle locking issues
> when it comes to the mmap_sem.
>
> Only set the RETRY_WAIT flag and have that do the necessary
> work instead of confusing reviewers of this code by setting
> ALLOW_RETRY and not releasing the mmap_sem.
>
> --- a/include/linux/mm.h
> +++ b/include/linux/mm.h
> @@ -151,8 +151,8 @@ extern pgprot_t protection_map[16];
>  #define FAULT_FLAG_WRITE       0x01    /* Fault was a write access */
>  #define FAULT_FLAG_NONLINEAR   0x02    /* Fault was via a nonlinear mapping */
>  #define FAULT_FLAG_MKWRITE     0x04    /* Fault was mkwrite of existing pte */
> -#define FAULT_FLAG_ALLOW_RETRY 0x08    /* Retry fault if blocking */
> -#define FAULT_FLAG_RETRY_NOWAIT        0x10    /* Don't drop mmap_sem and wait when retrying */
> +#define FAULT_FLAG_ALLOW_RETRY 0x08    /* Retry fault if blocking (drops mmap_sem) */
> +#define FAULT_FLAG_RETRY_NOWAIT        0x10    /* Wait when retrying (don't drop mmap_sem) */

You want to say "DONT wait when retrying" here...

Also - you argued higher up that having both flags set at once is
confusing, but I find it equally confusing to pass a flag to specify
you don't want to wait on retry if the flag that allows retry is not
set. I think the confusion comes from the way the nowait semantics got
bolted on the retry code for virtualization, even though (if I
understand the virtualization use case correctly) they dont actually
want to retry there, they just want to give up without blocking.


Would the following proposal make more sense to you ?

FAULT_FLAG_ALLOW_ASYNC: allow returning a VM_FAULT_ASYNC error code if
the page can't be obtained immediately (major fault).
FAULT_FLAG_ASYNC_WAIT: before returning VM_FAULT_ASYNC, drop the
mmap_sem and wait for major fault to complete.

existing uses of FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_RETRY_NOWAIT
become FAULT_FLAG_ASYNC
existing uses of FAULT_FLAG_ALLOW_RETRY alone become FAULT_FLAG_ASYNC
| FAULT_FLAG_ASYNC_WAIT
existing uses of VM_FAULT_RETRY become VM_FAULT_ASYNC

This may also help your documentation proposal since the flags would
now work together rather than having one be an exception to the other.

-- 
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.
--
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