Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756145AbdCXUW7 (ORCPT ); Fri, 24 Mar 2017 16:22:59 -0400 Received: from merlin.infradead.org ([205.233.59.134]:34374 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755897AbdCXUWx (ORCPT ); Fri, 24 Mar 2017 16:22:53 -0400 Date: Fri, 24 Mar 2017 21:22:42 +0100 From: Peter Zijlstra To: Andy Lutomirski Cc: Dmitry Vyukov , Andrew Morton , Andy Lutomirski , Borislav Petkov , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Josh Poimboeuf , Linus Torvalds , Paul McKenney , Thomas Gleixner , Ingo Molnar , LKML Subject: Re: locking/atomic: Introduce atomic_try_cmpxchg() Message-ID: <20170324202242.GA5680@worktop> References: <20170324142140.vpyzl755oj6rb5qv@hirez.programming.kicks-ass.net> <20170324164108.ibcxxqbhvx6ao54r@hirez.programming.kicks-ass.net> <20170324172342.radlrhk2z6mwmdgk@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 664 Lines: 19 On Fri, Mar 24, 2017 at 11:45:46AM -0700, Andy Lutomirski wrote: > After playing with it a bit, I found some of the problem: you're > passing val into EXCEPTION_VALUE, which keeps it live. If I get rid > of that, the generated code is great. Right, so I needed that because I land on ud2 through 2 different paths: - newly saturated - use-after-free And the exception handler can figure out which of the two by looking at the variable, but then of course, it needs to be life. For the full horror of how to do this, look here: http://paste.debian.net/924190/ But I didn't just show you that, so you can't blame me for any damage that might've done you.