From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752844AbbFUGze (ORCPT ); Sun, 21 Jun 2015 02:55:34 -0400 Received: from mail-wg0-f52.google.com ([74.125.82.52]:35788 "EHLO mail-wg0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752149AbbFUGz2 (ORCPT ); Sun, 21 Jun 2015 02:55:28 -0400 Date: Sun, 21 Jun 2015 08:55:23 +0200 From: Ingo Molnar To: Alexey Dobriyan Cc: hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Denys Vlasenko , Andy Lutomirski , Brian Gerst Subject: Re: [PATCH 2/2] x86: fix incomplete clear by clear_user() Message-ID: <20150621065523.GA31829@gmail.com> References: <20150620214536.GA14099@p183.telecom.by> <20150620214715.GB14099@p183.telecom.by> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150620214715.GB14099@p183.telecom.by> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Alexey Dobriyan wrote: > clear_user() used MOVQ+MOVB and if MOVQ faults, code simply exits and > honestly returns remaining length. In case of unaligned area, unaligned > remainder would count towards return value (correctly) but not cleared > (lazy code at least): > > clear_user(p + 4096 - 4, 8) = 8 > > No one would have noticed but REP MOVSB addition to clear_user() > repertoire creates a problem: REP MOVSB does everything correctly, > clears and counts to the last possible byte, but REP STOSQ and MOVQ > variants DO NOT: > > MOVQ clear_user(p + 4096 - 4, 8) = 8 > REP STOSQ clear_user(p + 4096 - 4, 8) = 8 > REP STOSB clear_user(p + 4096 - 4, 8) = 4 > > Patch fixes incomplete clear on 32-bit and 64-bit REP STOSQ, MOVQ. So please flip the order of the changes around so that we never have this inconsistency observable: i.e. first update the existing clearing method, then move it and introduce the new variants without having to patch them. Thanks, Ingo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/