Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2580044yba; Mon, 6 May 2019 08:16:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqy1HohY5JQ5LY4QzA8HLvj91efsXyPADHFFTcTSkEIj0ztfICFXYndV4AIFo+ORAqOCV17+ X-Received: by 2002:a17:902:e48b:: with SMTP id cj11mr32068815plb.223.1557155816633; Mon, 06 May 2019 08:16:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557155816; cv=none; d=google.com; s=arc-20160816; b=bWNJDWRXVSW0lBVXzjnuYbJy5m5pWLsUAakcvFKiP1lk6YiTN+sCLhgLMqpasuT3C6 DUChat0JqftAXp4FD8jz2mkdUsJgOYNcRA81JYB2rn6ebCvRucFgjGRu/gDCrXE351H6 qkz8HBP95/+5ST1Y69ryp4fDloTZDfhgjB4MH1k0fniO1WolhpdKZBFmWg7wsP80YFOm fRO1nyD/z8HilPp0bG3Wy+M2Iy0jnyMpQeW/DwsHbgfkhBUfXi5QibQlZvdFIBuBP1LO zpkivUSP4RIOZk7pKlzG+oqR19wySyOlHGk9E9qvlqGYTjSSdJHEkZBzI/ajlV88iiZi j3Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=Ylli8Kw4Bruzy1ATfSM1hCqG+M26Jxwnb0+1+xFjGYc=; b=bfsTFWU2ic8r2liMpc/15x2fuOk8i/FdicTDVn9nX1GZeuJR4bBUSziuZTBMuuXiij kUIPAPIR8G7TUYmIpn0HrPU9J8pSspsyXrrSZw+RgoppsVTPFfrtI2k7yi6C4D/kdf1t S/rAGr0CFteN5Fc681idazWKqFyOW9GYsyNbE9jPp6lNp+fx+tl5lduL07aSZzrtALFl C0h8iDaVkU1SLv6hsAKwaN0WruOvzf/MTtZE47VPijESv2xFvXQ6Ewlmls8S/BxKl+an IZjbbOGWVyNN9xwmImP+otBTyNgfUZPI/qO+P9sjaJjaMbMtjchHBU+6kV5AkD7ChQ3K TZpw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b15si4071912plz.338.2019.05.06.08.16.40; Mon, 06 May 2019 08:16:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726512AbfEFPOj (ORCPT + 99 others); Mon, 6 May 2019 11:14:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38530 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726322AbfEFPOj (ORCPT ); Mon, 6 May 2019 11:14:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C23E6307D942; Mon, 6 May 2019 15:14:38 +0000 (UTC) Received: from treble (ovpn-122-172.rdu2.redhat.com [10.10.122.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 433C65F9D6; Mon, 6 May 2019 15:14:30 +0000 (UTC) Date: Mon, 6 May 2019 10:14:28 -0500 From: Josh Poimboeuf To: Linus Torvalds Cc: Peter Zijlstra , Steven Rostedt , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , Andy Lutomirski , Nicolai Stange , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , the arch/x86 maintainers , Jiri Kosina , Miroslav Benes , Petr Mladek , Joe Lawrence , Shuah Khan , Konrad Rzeszutek Wilk , Tim Chen , Sebastian Andrzej Siewior , Mimi Zohar , Juergen Gross , Nick Desaulniers , Nayna Jain , Masahiro Yamada , Joerg Roedel , "open list:KERNEL SELFTEST FRAMEWORK" , stable Subject: Re: [RFC][PATCH 1/2] x86: Allow breakpoints to emulate call functions Message-ID: <20190506151428.r6fhirmoz5nrmiu5@treble> References: <20190501202830.347656894@goodmis.org> <20190501203152.397154664@goodmis.org> <20190501232412.1196ef18@oasis.local.home> <20190502162133.GX2623@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 06 May 2019 15:14:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 02, 2019 at 11:02:40AM -0700, Linus Torvalds wrote: > On Thu, May 2, 2019 at 9:21 AM Peter Zijlstra wrote: > > > > TL;DR, on x86_32 kernel->kernel IRET frames are only 3 entries and do > > not include ESP/SS, so not only wasn't regs->sp setup, if you changed it > > it wouldn't be effective and corrupt random stack state. > > Indeed, the 32-bit case for same-RPL exceptions/iret is entirely > different, and I'd forgotten about that. > > And honestly, this makes the 32-bit case much worse. Now the entry > stack modifications of int3 suddenly affect not just the entry, but > every exit too. > > This is _exactly_ the kind of subtle kernel entry/exit code I wanted > us to avoid. I actually love this patch (absent the bugs). This is already something that has been sorely needed for years. The "struct pt_regs is incomplete on x86-32" thing is a monstrosity which has long been a source of confusion and bugs. Sure, this patch adds some complexity to the entry code, but on the other hand it actually makes it possible to use pt_regs sanely: regs->sp is no longer uninitialized. So a class of (very non-obvious) bugs is eliminated. I don't think it would make sense to make this change for int3 only, because the benefits are global. -- Josh