From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753949AbbCQOgW (ORCPT ); Tue, 17 Mar 2015 10:36:22 -0400 Received: from mail-we0-f174.google.com ([74.125.82.174]:34665 "EHLO mail-we0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752814AbbCQOgV (ORCPT ); Tue, 17 Mar 2015 10:36:21 -0400 Date: Tue, 17 Mar 2015 15:36:14 +0100 From: Ingo Molnar To: Denys Vlasenko Cc: Linus Torvalds , Steven Rostedt , Borislav Petkov , "H. Peter Anvin" , Andy Lutomirski , Oleg Nesterov , Frederic Weisbecker , Alexei Starovoitov , Will Drewry , Kees Cook , x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2 v2] x86/asm/entry/64: Enable interrupts *after* we fetch PER_CPU_VAR(old_rsp) Message-ID: <20150317143614.GA18462@gmail.com> References: <1426600344-8254-1-git-send-email-dvlasenk@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426600344-8254-1-git-send-email-dvlasenk@redhat.com> 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 * Denys Vlasenko wrote: > Without this change, it is still not possible to get rid of > PER_CPU_VAR(old_rsp) usage in switch_to: if preemption happens > while we did not fetch PER_CPU_VAR(old_rsp) and stored it in pt_regs->sp, > PER_CPU_VAR(old_rsp) gets corrupted by other task's user sp. Well, wouldn't this be a much clearer explanation: "We want to use PER_CPU_VAR(old_rsp) as a simple temporary register, to shuffle user-space RSP into (and from) when we set up the system call stack frame. At that point we cannot shuffle values into general purpose registers, because we have not saved them yet. To be able to do this shuffling into a memory location, we must be atomic and must not be preempted while we do the shuffling, otherwise the 'temporary' register gets overwritten by some other task's temporary register contents ..." Agreed? Thanks, Ingo