Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2697026imu; Thu, 29 Nov 2018 08:52:59 -0800 (PST) X-Google-Smtp-Source: AFSGD/UY0gZUAMI46f0eWsQdg3sgiPBzOUXeiFGa+BO5Xpux3cPweyR0gCsK7X1wItuUWY2a62Fu X-Received: by 2002:a17:902:1105:: with SMTP id d5mr2093035pla.47.1543510379214; Thu, 29 Nov 2018 08:52:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543510379; cv=none; d=google.com; s=arc-20160816; b=lPpM2PQFSBklA03eKWvsNIDHxBU7g9btBa0ZolpdO4EGRHkPuqoysvZi+SmfEpoPBF U0/qrJfLjdcfdYe1IbmeJOvz9wd1s6+oxm0YoZ+xqmQ/W6VrShPhaPprsdD9CnbA+k0s 7Z7iBmQ28oAU/opgz+aaY08jXySs8acLsRdcB016a7uAuluhKD7OBxQH7kE5Xb8iIOwe CNCpTBu6PeQc6KRFJhtiy8MXkOfpsZcrNpk98t0Sshj4CiFcq5b0rKlKBgMqPpoJkfVA 0E1Y/QFYm2n6vEnN8Qirjl5UfSmWbHvree39YxoUprhsMMOK8iGVAt+1r23/oy/lLkGV /JzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ieftWzuJk9u0tH0PSe3WttI77Vs/aPCC88uuLzGmMS8=; b=R+jIWXZno1NDd9d4/sjBoStsEYrwgTtc9qk3C56dtxWP6TizUeQonLk65Z3PlPq9R6 rg2gfYG1/ULupKz6dUBa3BaDHsa2dKcFVnP2TYg4K6WGZBEYiT2DNLQWAJPYM1nLrRdT +Tivjmz1/8O5YhNL9oEq8uVB1fgaELzvfnjklXClxXsNA5fd3sx5DMd0uaK6q9yPCZsh DftMwlI40piZ27DDvwBGGhGMkfRXM/cKZriP2grOn+1M+yutqmJK4wuBANkANwGzGcO4 ZWaTgS++71tVOUJF/5HiDBQRVPD4L5hUuaKW7pl5e8Pxbin5qXdNNeldtycVyZ3w9shR mfpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Lw+WefoL; 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 s8si2446857plq.345.2018.11.29.08.52.38; Thu, 29 Nov 2018 08:52:59 -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=@linux-foundation.org header.s=google header.b=Lw+WefoL; 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 S1729967AbeK3D4h (ORCPT + 99 others); Thu, 29 Nov 2018 22:56:37 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:38395 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729519AbeK3D4h (ORCPT ); Thu, 29 Nov 2018 22:56:37 -0500 Received: by mail-lj1-f195.google.com with SMTP id c19-v6so2365161lja.5 for ; Thu, 29 Nov 2018 08:50:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ieftWzuJk9u0tH0PSe3WttI77Vs/aPCC88uuLzGmMS8=; b=Lw+WefoLIrf861hhBL1Bedb3LogisHbVwscIAtmx+aGmZWSXnOCwJFzrhaA8ypf2HA Lib+eJawI0u3zA7qNExmQ9I/jqqM4eMTylaxQiArkYp5jMKb4En8CU2AbgpkSaYWZQdg 8u6S9NH5WotRwk8Z1JVR5akAKCPxszm8F+ukk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ieftWzuJk9u0tH0PSe3WttI77Vs/aPCC88uuLzGmMS8=; b=laY2mYgKwWa7paYJTvQ9psZD565CreN2EcoiMwYGAq63q22DEUertjpJUktYJ/ckkl D3dtURi3sBmyiQSfKvBXESP7v0p2O3C4W45o5dBpqV8MfPrUCquIhcsWsM+IEu/FgSWM 4aEpSs1AHHI1CTCmXCKJC0OK1iPSmsUqmf9YEaeK5wcJrMDWLER09SJqczGWmo9kg6+i YcRTgCxXn/7sh+aJST1Qn2WJoceO27VEPFbfa4inRRr/D6QboP0T5+xu5xw80UVKTRBi 2UW8Qi2wMADKYrTbLWeCtqICHxL3X1I/CJsDZiWvK8Pn99Wam07IdaKtFdEccZqCA5cO 9syg== X-Gm-Message-State: AA+aEWZ4OmarJTjWe7Cz703nsHO8JJvTHbnKOtMdAfQB3WTt3oOagpkt +tNY+BZ+vozNzzCO17ukP4drJP9ipkE= X-Received: by 2002:a2e:8449:: with SMTP id u9-v6mr1747290ljh.121.1543510235002; Thu, 29 Nov 2018 08:50:35 -0800 (PST) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com. [209.85.208.180]) by smtp.gmail.com with ESMTPSA id m13-v6sm378426ljg.56.2018.11.29.08.50.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 08:50:34 -0800 (PST) Received: by mail-lj1-f180.google.com with SMTP id v15-v6so2339173ljh.13 for ; Thu, 29 Nov 2018 08:50:33 -0800 (PST) X-Received: by 2002:a2e:3e04:: with SMTP id l4-v6mr1556647lja.148.1543510232957; Thu, 29 Nov 2018 08:50:32 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: <20181129163342.tp5wlfcyiazwwyoh@treble> From: Linus Torvalds Date: Thu, 29 Nov 2018 08:50:16 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 4/4] x86/static_call: Add inline static call implementation for x86-64 To: Josh Poimboeuf Cc: Peter Zijlstra , Andy Lutomirski , 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-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Nov 29, 2018 at 8:33 AM Josh Poimboeuf wrote: > > This seems to work... > > + .if \create_gap == 1 > + .rept 6 > + pushq 5*8(%rsp) > + .endr > + .endif > + > -idtentry int3 do_int3 has_error_code=0 > +idtentry int3 do_int3 has_error_code=0 create_gap=1 Ugh. Doesn't this entirely screw up the stack layout, which then screws up task_pt_regs(), which then breaks ptrace and friends? ... 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. 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. So no. Do *not* try to change %rsp on the stack in the bp handler. Instead, I'd suggest: - just restart the instruction (with the suggested "ptregs->rip --") - 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. No? Linus