Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758513AbeAIAGi (ORCPT + 1 other); Mon, 8 Jan 2018 19:06:38 -0500 Received: from mga11.intel.com ([192.55.52.93]:35195 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252AbeAIAGg (ORCPT ); Mon, 8 Jan 2018 19:06:36 -0500 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,333,1511856000"; d="scan'208";a="193396840" Date: Mon, 8 Jan 2018 16:06:26 -0800 From: Andi Kleen To: Linus Torvalds Cc: David Woodhouse , David Woodhouse , Paul Turner , LKML , Greg Kroah-Hartman , Tim Chen , Dave Hansen , Thomas Gleixner , Kees Cook , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , One Thousand Gnomes Subject: Re: [PATCH v6 11/10] x86/retpoline: Avoid return buffer underflows on context switch Message-ID: <20180109000626.GE6718@tassilo.jf.intel.com> References: <1515363085-4219-1-git-send-email-dwmw@amazon.co.uk> <1515455051.15588.7.camel@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.1 (2017-09-22) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 08, 2018 at 03:56:30PM -0800, Linus Torvalds wrote: > On Mon, Jan 8, 2018 at 3:44 PM, David Woodhouse wrote: > > > > To guard against this fill the return buffer with controlled > > content during context switch. This prevents any underflows. > > Ugh. I really dislike this patch. Everything else in the retpoline > patches makes me go "ok, that's reasonable". This one makes me go > "Eww". > > It's hacky, it's ugly, and it looks pretty expensive too. Modern cores are quite fast at executing calls. > > Is there really nothing more clever we can do? We could be a cleverer in selecting how many dummy calls to do. But that would likely be fragile and hard to maintain and likely be more complicated, and I doubt it would buy that much. Don't really have a better proposal, sorry. -Andi