Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2814041imu; Thu, 29 Nov 2018 10:38:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/XTxlR5qwPCxoocRw7z7t1UfUopf7k2pRCS0gJQLgFUKi5iSt3g05jE/QfGLK+/or+WndQw X-Received: by 2002:a17:902:6946:: with SMTP id k6mr2589793plt.101.1543516680855; Thu, 29 Nov 2018 10:38:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543516680; cv=none; d=google.com; s=arc-20160816; b=FDSZc1CeKl2qI+GXjVaZD9CtaCpDZsA+cZosSFk9aQ22Uo10ZMmPRfhNua9vZvaaA+ cLvsgghwY0vEp7iHjqCHgWXCeuxBCIwqgjuXEwITnWHPIuSgPaMR/R1AZERC5tf3y63m p8XywTkvJCvzcNLj1r21SCPqpeLEthEBvx89CzSEmU1ILMZ3oXH+xf4ffO21C4RmGo2h g+7kLZzakveF/R1vLfOHvzV96/Kgld1ERsdUQvXuXiQC49e+VB4W3VKJXoHjNVJaUeMD NeUj0R/xg2RpYKaGUusxr2PyNkMAPldeeFMSpLFaNkuLavLGtlu2ofsBhXNrqfFqnRFa zV/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=VJT3Cqw1s+1LfZz1jZVQmfF+EB+6vDsy5FMvUfM+kJc=; b=rl+msKrwwzGR7BeX/K/ZZyF9MrOR0IFEWv0bb9vCUQq1o6ufSfAWydU678Hpy9gGWm inforAdNqGrQaXKyc2byhZjQTsfnH8b33OiJfVSb3whOM1kHV0AWlgu4YUlhdr9TPJFZ 6AM4dyKA3z43PfXFBeVu4/b+aiDXzS8UF8bGDm47Y1UfzUYdJ9LIqrIuXBFj9t9L5tsL esBIV9QGaFn2GNjUX1CHAAoUAY2ZUkzCbZSIkCDd3pZkP16hKByan5jCRetUyRoevfRL 0BNZJEJe1jxp/gIHiL0QRLNNtwwi1cRqN+zaMwuZJrSXddr2pczIEBeP4v4dIZmT4Cc5 AZ7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=avRx9ApN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o89si2966177pfk.223.2018.11.29.10.37.45; Thu, 29 Nov 2018 10:38:00 -0800 (PST) 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; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=avRx9ApN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730331AbeK3EI3 (ORCPT + 99 others); Thu, 29 Nov 2018 23:08:29 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39354 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729818AbeK3EI3 (ORCPT ); Thu, 29 Nov 2018 23:08:29 -0500 Received: by mail-pg1-f193.google.com with SMTP id w6so1192517pgl.6 for ; Thu, 29 Nov 2018 09:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VJT3Cqw1s+1LfZz1jZVQmfF+EB+6vDsy5FMvUfM+kJc=; b=avRx9ApNjygatqM/IP78x10vo+BDyCP2h1NYOfBFUEjOQJTj+NtKBC2w6ld9dIjEjL VRyj7QPtjBHkLLllohfpqf0a9PSdxwC3BVOvSvHzZ/8dAUZKyZpPIAJDw1jk4kAxLQxj K0kchWQOQm9VKNZPwSTEJXN9Hfvw4agQ8SBHs4WGaYTg+ecz+zyWZMRn2OGdO6a8c4yK aD4zaNnjfFwgZKPvzQKAhBpMtb+0Cj+HbkVg2CdXI9qjqplZcIMEMaoZ3LXItm7U2w9a y9w/TkvewtMTCjXW0CVHlUyTYyjtg6cdTt1++Rwfw/iZ9E7PAgMJma3Ejet7WTPX8XaN syDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=VJT3Cqw1s+1LfZz1jZVQmfF+EB+6vDsy5FMvUfM+kJc=; b=RB84+nd4PUJloZDXmKBZxUWKGnZnHMDQGCOViINSDqkN1EzB6x7ayRfIJnvTIU1o7G rIEM9clUg5SkXnThtmut/1BckiH5S9reN8g+5HzVxI1gM/WQU+qLtT9Hj0QqK255YIhc 5EyTb5SZz4gRJoGgvTGpmFzZnWgF7ZZ0R8bFw1DnrFgG14z/Wcy2umStA/Fe3Oxdlg4A rGqkBgQFiYJKO46kS8IrwrrO3hJ0U4GO2lZzMOFi3eU4inEubdVWwQ+6zB5V7in+b3ay byAwMfgs3SO4pdiDNPXM8NXeghjBi+Z92yCaYeJDrT2MoiIOsuRhZir4sUr88DJT0k3o Kc+Q== X-Gm-Message-State: AA+aEWa/PrMqaR0EbrvtbZcBAuaCpeAnz9KQySi1RBYbDF5zJy5PvmBA pmqy8J1wJavKWs5thrT0qpoZpg== X-Received: by 2002:a62:6d47:: with SMTP id i68mr2116783pfc.185.1543510946287; Thu, 29 Nov 2018 09:02:26 -0800 (PST) Received: from ?IPv6:2600:1010:b054:ff26:3849:a65d:14d0:f668? ([2600:1010:b054:ff26:3849:a65d:14d0:f668]) by smtp.gmail.com with ESMTPSA id h134sm3853363pfe.27.2018.11.29.09.02.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 09:02:25 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (1.0) Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64 From: Andy Lutomirski X-Mailer: iPhone Mail (16B92) In-Reply-To: Date: Thu, 29 Nov 2018 09:02:23 -0800 Cc: Josh Poimboeuf , Peter Zijlstra , Andrew Lutomirski , the arch/x86 maintainers , Linux List Kernel Mailing , Ard Biesheuvel , Steven Rostedt , Ingo Molnar , Thomas Gleixner , mhiramat@kernel.org, jbaron@akamai.com, Jiri Kosina , David.Laight@aculab.com, bp@alien8.de, julia@ni.com, jeyu@kernel.org, Peter Anvin Content-Transfer-Encoding: quoted-printable Message-Id: <0A629D30-ADCF-4159-9443-E5727146F65F@amacapital.net> References: <20181126160217.GR2113@hirez.programming.kicks-ass.net> <20181126171036.chcbmb35ygpxziub@treble> <20181126175624.bruqfbkngbucpvxr@treble> <20181126200801.GW2113@hirez.programming.kicks-ass.net> <20181126212628.4apztfazichxnt7r@treble> <20181127084330.GX2113@hirez.programming.kicks-ass.net> <20181129094210.GC2131@hirez.programming.kicks-ass.net> <20181129143853.GO2131@hirez.programming.kicks-ass.net> <20181129163342.tp5wlfcyiazwwyoh@treble> To: Linus Torvalds Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 29, 2018, at 8:50 AM, Linus Torvalds wrote: >=20 >> On Thu, Nov 29, 2018 at 8:33 AM Josh Poimboeuf wrot= e: >>=20 >> This seems to work... >>=20 >> + .if \create_gap =3D=3D 1 >> + .rept 6 >> + pushq 5*8(%rsp) >> + .endr >> + .endif >> + >> -idtentry int3 do_int3 has_error_code=3D= 0 >> +idtentry int3 do_int3 has_error_code=3D= 0 create_gap=3D1 >=20 > Ugh. Doesn't this entirely screw up the stack layout, which then > screws up task_pt_regs(), which then breaks ptrace and friends? >=20 > ... and you'd only notice it for users that use int3 in user space, > which now writes random locations on the kernel stack, which is then a > huge honking security hole. >=20 > It's possible that I'm confused, but let's not play random games with > the stack like this. The entry code is sacred, in scary ways. >=20 > So no. Do *not* try to change %rsp on the stack in the bp handler. > Instead, I'd suggest: >=20 > - just restart the instruction (with the suggested "ptregs->rip --") >=20 > - to avoid any "oh, we're not making progress" issues, just fix the > instruction yourself to be the right call, by looking it up in the > "what needs to be fixed" tables. >=20 > No? I thought that too. I think it deadlocks. CPU A does text_poke_bp(). CPU B= is waiting for a spinlock with IRQs off. CPU C holds the spinlock and hits= the int3. The int3 never goes away because CPU A is waiting for CPU B to h= andle the sync_core IPI. Or do you think we can avoid the IPI while the int3 is there?=