From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932156AbcA0LVe (ORCPT ); Wed, 27 Jan 2016 06:21:34 -0500 Received: from prv-mh.provo.novell.com ([137.65.248.74]:55976 "EHLO prv-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754499AbcA0LVb convert rfc822-to-8bit (ORCPT ); Wed, 27 Jan 2016 06:21:31 -0500 Message-Id: <56A8B64A02000078000CB830@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.0 Date: Wed, 27 Jan 2016 04:21:30 -0700 From: "Jan Beulich" To: , "Thomas Gleixner" , Cc: Subject: [PATCH v2] x86/mm: avoid premature success when changing page attributes References: <56A6615E02000078000CAC96@prv-mh.provo.novell.com> <56A8AD9E02000078000CB7CA@prv-mh.provo.novell.com> In-Reply-To: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8BIT Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When __change_page_attr() finds it necessary to call __cpa_process_fault(), it passes its return value directly up to its own caller, even if this indicates success. Success to the callers, however, means that whatever ->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() adjusting ->numpages). When a top level caller, like in the case of change_page_attr_set_clr() only meaning to alter _PAGE_NX, wants to suppress alias processing, the boolean value to indicate so results in __cpa_process_fault() taking its other successful exit path. Since ->numpages so far didn't get adjusted there, hitting either of the conditions that cause __cpa_process_fault() to get called meant early termination of the processing without having processed the entire range, yet still reporting success. Signed-off-by: Jan Beulich --- v2: Completely re-written description. --- arch/x86/mm/pageattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- 4.5-rc1/arch/x86/mm/pageattr.c +++ 4.5-rc1-x86-cpa-non-primary/arch/x86/mm/pageattr.c @@ -1122,8 +1122,10 @@ static int __cpa_process_fault(struct cp /* * 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