From: tip-bot for Jan Beulich <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org,
JBeulich@suse.com, jbeulich@suse.com, a.p.zijlstra@chello.nl,
mingo@kernel.org, hpa@zytor.com
Subject: [tip:x86/mm] x86/mm: Avoid premature success when changing page attributes
Date: Thu, 25 Feb 2016 01:45:35 -0800 [thread overview]
Message-ID: <tip-405e1133d00e0271cedef75c17ecb773ff3e2732@git.kernel.org> (raw)
In-Reply-To: <56BB0AD402000078000D05BF@prv-mh.provo.novell.com>
Commit-ID: 405e1133d00e0271cedef75c17ecb773ff3e2732
Gitweb: http://git.kernel.org/tip/405e1133d00e0271cedef75c17ecb773ff3e2732
Author: Jan Beulich <JBeulich@suse.com>
AuthorDate: Wed, 10 Feb 2016 02:03:00 -0700
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Thu, 25 Feb 2016 10:41:43 +0100
x86/mm: Avoid premature success when changing page attributes
set_memory_nx() (and set_memory_x()) currently differ in behavior from
all other set_memory_*() functions when encountering a virtual address
space hole within the kernel address range: They stop processing at the
hole, but nevertheless report success (making the caller believe the
operation was carried out on the entire range). While observed to be a
problem - triggering the CONFIG_DEBUG_WX warning - only with out of
tree code, I suspect (but didn't check) that on x86-64 the
CONFIG_DEBUG_PAGEALLOC logic in free_init_pages() would, when called
from free_initmem(), have the same effect on the set_memory_nx() called
from mark_rodata_ro().
This unexpected behavior is a result of change_page_attr_set_clr()
special casing changes to only the NX bit, in that it passes "false" as
the "checkalias" argument to __change_page_attr_set_clr(). Since this
flag becomes the "primary" argument of both __change_page_attr() and
__cpa_process_fault(), the latter would so far return success without
adjusting cpa->numpages. Success to the higher level callers, however,
means that whatever cpa->numpages currently holds is the count of
successfully processed pages. The cases when __change_page_attr() calls
__cpa_process_fault(), otoh, don't generally mean the entire range got
processed (as can be seen from one of the two success return paths in
__cpa_process_fault() already adjusting ->numpages).
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/56BB0AD402000078000D05BF@prv-mh.provo.novell.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
arch/x86/mm/pageattr.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
index 2440814..3dd6afd 100644
--- a/arch/x86/mm/pageattr.c
+++ b/arch/x86/mm/pageattr.c
@@ -1122,8 +1122,10 @@ static int __cpa_process_fault(struct cpa_data *cpa, unsigned long vaddr,
/*
* Ignore all non primary paths.
*/
- if (!primary)
+ if (!primary) {
+ cpa->numpages = 1;
return 0;
+ }
/*
* Ignore the NULL PTE for kernel identity mapping, as it is expected
prev parent reply other threads:[~2016-02-25 9:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-25 16:54 [PATCH] x86/mm: avoid " Jan Beulich
2016-01-27 10:05 ` Thomas Gleixner
2016-01-27 10:44 ` Jan Beulich
2016-01-27 10:53 ` Thomas Gleixner
2016-01-27 11:10 ` Jan Beulich
2016-01-27 11:21 ` [PATCH v2] " Jan Beulich
2016-01-28 8:42 ` Ingo Molnar
2016-02-02 8:46 ` Jan Beulich
2016-02-09 14:30 ` Ingo Molnar
2016-02-10 9:03 ` [PATCH v3] " Jan Beulich
2016-02-25 9:45 ` tip-bot for Jan Beulich [this message]
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=tip-405e1133d00e0271cedef75c17ecb773ff3e2732@git.kernel.org \
--to=tipbot@zytor.com \
--cc=JBeulich@suse.com \
--cc=a.p.zijlstra@chello.nl \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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
Powered by JetHome